-
-
Save djdagovs/6e4a3fdd68fe6528b87a19423b749c7c to your computer and use it in GitHub Desktop.
/usr/local/bin/systemstats.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Server Status Script | |
| # Version 0.1.5 | |
| # Updated: September 15th 2017 | |
| CPUTIME=$(ps -eo pcpu | awk 'NR>1' | awk '{tot=tot+$1} END {print tot}') | |
| CPUCORES=$(cat /proc/cpuinfo | grep -c processor) | |
| UP=$(echo `uptime` | awk '{ print $3 " " $4 }') | |
| echo " | |
| System Status updated: `date` | |
| - Server Name = `hostname` | |
| - Public IP = `dig +short myip.opendns.com @resolver1.opendns.com` | |
| - OS Version = `cat /etc/redhat-release` | |
| - Platform Data = `uname -orpi` | |
| - System Uptime = `echo $UP` | |
| - Load Averages = `cat /proc/loadavg` | |
| - CPU Usage (average) = `echo $CPUTIME / $CPUCORES | bc`% | |
| - Memory free (real) = `free -m | head -n 2 | tail -n 1 | awk {'print $4'}` Mb | |
| - Memory free (cache) = `free -m | head -n 3 | tail -n 1 | awk {'print $3'}` Mb | |
| - Swap in use = `free -m | tail -n 1 | awk {'print $3'}` Mb | |
| - Disk space used = `df --total -h | tail -1 | awk '{ a = $3; b = $2; c = $5 } END { print c, "(", a, "/", b, ")" }'` | |
| - Disk space available = `df --total -h | tail -1 | awk '{ a = $4; b = $2; c = $5 } END { print (100-c)"%", "(", a, "/", b, ")" }'` | |
| " > /etc/motd.d/root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment