In order to produce a «System Status» Message Of The Day (MOTD) file in openSUSE, a-la Ubuntu, you should write this script (as systemstats.sh) in /usr/local/bin
#!/bin/bash
#
# Server Status Script
# Version 0.1.3 m
# Updated: July 26th 2011 m
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`
– OS Version = `grep openSUSE /etc/SuSE-release`
– Load Averages = `cat /proc/loadavg | awk {‘print $1″ «$2» «$3’}`
– System Uptime = `uptime | awk {‘print $3» «$4’}`
– Platform Data = `uname -orpi| awk {‘print $1» «$4’}`
– 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 -h / | awk ‘{ a = $4 } END { print a }’`
****************************************************************************
» > /etc/motd
# End of Script
Remember to make it executable (as root or sudo)
chmod +x /usr/local/bin/systemstats.sh
To make the script update the information automatically, you should edit /etc/crontab as root, and add this two lines at the end of the file
# Status Script
*/5 * * * * root /usr/local/bin/systemstats.sh
After you update the /etc/motd file (by running as root /usr/local/bin/systemstats.sh), it should look like something like this:
david@virtual:~> cat /etc/motd
****************************************************************************
System Status
Updated: Thu Oct 20 01:55:01 CEST 2011
– Server Name = virtual
– OS Version = openSUSE 11.4 (x86_64)
– Load Averages = 0.00 0.01 0.05
– System Uptime = 2:22, 1
– Platform Data = 2.6.37.6-0.7-desktop GNU/Linux
– CPU Usage (average) = 0%
– Memory free (real) = 3667 Mb
– Memory free (cache) = 138 Mb
– Swap in use = 0 Mb
– Disk Space Used = 9.5G
****************************************************************************
Based on the information found in http://www.md3v.com/create-a-linux-server-status-motd