save point and addition of sys module
This commit is contained in:
parent
d578028a7b
commit
38f475d045
2 changed files with 38 additions and 8 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
# 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"'
|
||||
|
||||
|
||||
|
|
36
sys.bash
Executable file
36
sys.bash
Executable file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue