When obtaining usage information, there are primarily 3 details you want to look at (for my needs, yours may vary) being CPU, RAM, Hard Disk. On many systems you can use the below commands:
1 2 3 |
cat /proc/cpuinfo | grep processor | wc –l free df –h |
On newer machines ( I think RHEL 6 and newer) you can use nproc in place of the first command:
1 2 3 |
nproc free df –h |
There is also this very straight forward method below:
1 |
HOSTNAME=$(hostname | tr [A–Z] [a–z] | sed –e ‘s/.example.com//’); PROCS=$(cat /proc/cpuinfo | grep processor | wc –l); MEMTOTAL=$(echo “scale = 2; $(free | grep ‘Mem:’ | awk ‘{print $2}’)/1048576” | bc); MEMUSED=$(echo “scale = 2; $(free | grep ‘Mem:’ | awk ‘{print $3}’)/1048576” | bc); HDTOTAL=$(df –h | grep –v ‘nas’ | grep “/\$” | awk ‘{print $1}’); HDUSED=$(df –h | grep –v ‘nas’ | grep “/\$” | awk ‘{print $2}’); echo –e ‘\n\n’$HOSTNAME‘:\nCPU: ‘$PROCS‘ cores\nRAM: ‘$MEMUSED‘G Used / ‘$MEMTOTAL‘G Total\nHD: ‘$HDUSED‘ Used / ‘$HDTOTAL‘ Total\n’ |
Leave a Reply