Skip to content

Instantly share code, notes, and snippets.

@ngfw
Last active May 6, 2016 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngfw/e3754e645da180eb655b79e8e1c3a47d to your computer and use it in GitHub Desktop.
Save ngfw/e3754e645da180eb655b79e8e1c3a47d to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Server Status Script
# Version 1
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 = `ifconfig | grep inet | head -n 1 | awk '/inet addr/ {gsub("addr:", "", $2); print $2}'`
- OS Version = `lsb_release -d | awk {'print $2 " " $3 " " $4'}`
- Load Averages = `cat /proc/loadavg`
- System Uptime = `echo $UP`
- Platform Data = `uname -orpi`
- CPU Usage (average) = `echo $CPUTIME / $CPUCORES | bc`%
- Memory = `free -m | head -n 2 | tail -n 1 | awk {'print $2'}` Mb
- 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 -h | grep '/dev/' | awk {'print $3 "/" $2'}`
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment