Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save knotman90/1daba2d757e2fc29b403dc4fe958f2fc to your computer and use it in GitHub Desktop.
Save knotman90/1daba2d757e2fc29b403dc4fe958f2fc to your computer and use it in GitHub Desktop.
#!/bin/bash
# Installation:
#
# 1. vim /etc/ssh/sshd_config
# PrintMotd no
#
# 2. vim /etc/pam.d/login
# # session optional pam_motd.so
#
# 3. vim /etc/profile
# /usr/local/bin/dynmotd # Place at the bottom
#
# 4. Then of course drop this file at
# /usr/local/bin/dynmotd
#
USER=`whoami`
HOSTNAME=`uname -n`
IP=`hostname -i`
ROOT=`df -Ph | grep root | awk '{print $4}' | tr -d '\n'`
HOME=`df -Ph | grep home | awk '{print $4}' | tr -d '\n'`
BACKUP=`df -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
MEMORY=`free -m | grep "Mem" | awk '{print $2,"-",$3,"-",$4}'`
SWAP=`free -m | grep "Swap" | awk '{print $2,"-",$3,"-",$4}'`
PSA=`ps -Afl | wc -l`
# time of day
HOUR=$(date +"%H")
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
then TIME="morning"
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
then TIME="afternoon"
else
TIME="evening"
fi
#System uptime
uptime=`cat /proc/uptime | cut -f1 -d.`
upDays=$((uptime/60/60/24))
upHours=$((uptime/60/60%24))
upMins=$((uptime/60%60))
upSecs=$((uptime%60))
#System load
LOAD1=`cat /proc/loadavg | awk {'print $1'}`
LOAD5=`cat /proc/loadavg | awk {'print $2'}`
LOAD15=`cat /proc/loadavg | awk {'print $3'}`
echo ""
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
echo ""
MESSAGE=`/usr/bin/fortune | /usr/bin/cowsay`
echo -e " $MESSAGE"
COLOR_COLUMN="\e[1m-"
COLOR_VALUE="\e[31m"
RESET_COLORS="\e[0m"
echo -e "
===========================================================================
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
$COLOR_COLUMN- IP Address$RESET_COLORS..........: $COLOR_VALUE $IP $RESET_COLORS
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE `cat /etc/redhat-release` $RESET_COLORS
$COLOR_COLUMN- Users$RESET_COLORS...............: $COLOR_VALUE Currently `users | wc -w` user(s) logged on $RESET_COLORS
=========================================================================== $RESET_COLORS
$COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $RESET_COLORS
$COLOR_COLUMN- CPU usage$RESET_COLORS...........: $COLOR_VALUE $LOAD1 - $LOAD5 - $LOAD15 (1-5-15 min) $RESET_COLORS
$COLOR_COLUMN- Memory used$RESET_COLORS.........: $COLOR_VALUE $MEMORY (total-free-used) $RESET_COLORS
$COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $RESET_COLORS
$COLOR_COLUMN- Processes$RESET_COLORS...........: $COLOR_VALUE $PSA running $RESET_COLORS
$COLOR_COLUMN- System uptime$RESET_COLORS.......: $COLOR_VALUE $upDays days $upHours hours $upMins minutes $upSecs seconds $RESET_COLORS
$COLOR_COLUMN- Disk space ROOT$RESET_COLORS.....: $COLOR_VALUE $ROOT remaining $RESET_COLORS
$COLOR_COLUMN- Disk space HOME$RESET_COLORS.....: $COLOR_VALUE $HOME remaining $RESET_COLORS
$COLOR_COLUMN- Disk space BACK$RESET_COLORS.....: $COLOR_VALUE $BACKUP remaining $RESET_COLORS
===========================================================================
"
@vmanyushin
Copy link

you have a mistake on total-free-used memory, the order must be total-used-free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment