MOTD login display

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
Reaction score
1
Location
127.0.0.1
I have recently set up my home router/firewall box, and at the moment I am just messing about with it. I have just been setting up /etc/motd so I can have a pretty message greet me when I log in. What I would like to know is if there is any way to display useful information in the MOTD (i.e. system uptime, disk usage, etc.)?
 
Why update information in MOTD? IMHO, the best place to call information would be in ~/.login
 
Here's my desktop version of /etc/profile.d/motd.sh:

There's some bash specific stuff in there so you might want to change /bin/sh to /bin/bash on Ubuntu etc. Could do a csh version too if needed. It's just that bash is my default sh on FreeBSD and Slack.

Code:
#!/bin/sh
nCPU=`cat /proc/cpuinfo | grep -c 'processor'`
declare -a CPU[${nCPU}]
MEM=`free -t | grep -w 'Mem' | awk '{print $2}'`
SWAP=`free -t | grep -w 'Swap' | awk '{print $2}'`
let MEM="$MEM/1024"
let SWAP="$SWAP/1024"
echo
for i in `seq 1 ${nCPU}`
do
    CPUMOD=`cat /proc/cpuinfo | grep -m 1 -w 'model name' | awk -F: '{print $2}'`
    CPUSPEC=`cat /proc/cpuinfo | grep -m 1 -w 'cpu MHz' | awk -F: '{print $2}'`
    echo "CPU[${i}]:${CPUMOD} @${CPUSPEC} MHz"
done
if [ ! -z ${JAVA_HOME} ]; then
    echo "JRE   : ${JAVA_HOME}"
fi
echo "MEM   : ${MEM}MB"
echo "SWAP  : ${SWAP}MB"
echo
 
Here's my desktop version of /etc/profile.d/motd.sh:

There's some bash specific stuff in there so you might want to change /bin/sh to /bin/bash on Ubuntu etc. Could do a csh version too if needed. It's just that bash is my default sh on FreeBSD and Slack.

Code:
#!/bin/sh
nCPU=`cat /proc/cpuinfo | grep -c 'processor'`
declare -a CPU[${nCPU}]
MEM=`free -t | grep -w 'Mem' | awk '{print $2}'`
SWAP=`free -t | grep -w 'Swap' | awk '{print $2}'`
let MEM="$MEM/1024"
let SWAP="$SWAP/1024"
echo
for i in `seq 1 ${nCPU}`
do
    CPUMOD=`cat /proc/cpuinfo | grep -m 1 -w 'model name' | awk -F: '{print $2}'`
    CPUSPEC=`cat /proc/cpuinfo | grep -m 1 -w 'cpu MHz' | awk -F: '{print $2}'`
    echo "CPU[${i}]:${CPUMOD} @${CPUSPEC} MHz"
done
if [ ! -z ${JAVA_HOME} ]; then
    echo "JRE   : ${JAVA_HOME}"
fi
echo "MEM   : ${MEM}MB"
echo "SWAP  : ${SWAP}MB"
echo

That's quite impressive.

Thanks :)
 
Top
Sign up to the MyBroadband newsletter
X