#!/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