diff --git a/script.bash b/script.bash index 9801cde..35cdf3f 100644 --- a/script.bash +++ b/script.bash @@ -1,8 +1,8 @@ #!/bin/bash -# this is the main script template +# this is the main script template -set -eo pipefail +set -eo pipefail #these can cause problems when you want stuff to keep going if [[ -n "${BASHD_DEBUG}" ]]; then # a inevitability that this will be used set -x @@ -23,10 +23,4 @@ source ./config_json.bash # can be json or ini, I preffer json # Code goes here -eval "echo "Hello World"" -eval "moo" -eval "echo "cow"" -#runcmd 'false' -#runcmd 'echo "moo"' - diff --git a/sys.bash b/sys.bash new file mode 100755 index 0000000..9d18dce --- /dev/null +++ b/sys.bash @@ -0,0 +1,36 @@ +#!/bin/bash +set -x +# a bash file that can provide various bits of info about the system + +function cpuinfo() { + + # now lets extract the number of core and the architecture + num_cores=$(lscpu | grep -E "^CPU\(s\):" | awk '{print $2}') + architecture=$(lscpu | grep -E "^Architecture:" | awk '{print $2}') + # get cpu usage + cpu_usage=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}') + + echo "$num_cores cores, $architecture architecture, CPU usage: $cpu_usage" +} + +function meminfo() { + echo "Memory:" + # We will get to this later + #total=$(free -h| grep ) #| grep -E "Mem|Swap" +} + +function diskinfo() { + echo "Disk:" + # We will get to this later +} + +function networkinfo() { + echo "Network:" + # We will get to this later + +} + +# This seems to be a good layout for sys.bash for now + +cpuinfo +meminfo \ No newline at end of file