-
Notifications
You must be signed in to change notification settings - Fork 2
/
dynmotd
executable file
·89 lines (77 loc) · 3.39 KB
/
dynmotd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/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
# #requires fortune cowsay, lm_sensors
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'`
NUM_UNIQUE_USERS=`users | tr ' ' '\n' | sort | uniq | wc -w`
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`
TEMPERATURE=`sensors | grep Core | awk {'print $3'} | xargs`
#weather
#URL='http://www.accuweather.com/en/gb/edinburgh/eh1-3/weather-forecast/327336'
#WEATHER=`wget -q -O- --timeout=2 "$URL" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $2": "$16", "$12"°" }'| head -1`
# 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=`expr $uptime / 60 / 60 / 24`
upHours=`expr $uptime / 60 / 60 % 24`
upMins=`expr $uptime / 60 % 60`
upSecs=`expr $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'}`
COLOR_COLUMN="\e[1m-"
COLOR_VALUE="\e[31m"
RESET_COLORS="\e[0m"
echo ""
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
echo ""
MESSAGE=`/usr/bin/fortune | /usr/bin/cowsay`
echo -e " $MESSAGE"
RULES="$RESET_COLORS\e[32m
::::::::::::::::::::::::::::::::::-RULES-::::::::::::::::::::::::::::::::::
This is a private system that you are not to give out access to anyone
without permission from the admin. No illegal files or activity. Stay,
in your home directory, keep the system clean, and make regular backups.
-== DISABLE YOUR PROGRAMS FROM KEEPING SENSITIVE LOGS OR HISTORY ==-$RESET_COLORS"
echo -e " $RULES"
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 $NUM_UNIQUE_USERS DIFFERENT user(s) logged on $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- Cores Temperature$RESET_COLORS...: $COLOR_VALUE $TEMPERATURE $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 HOME$RESET_COLORS.....: $COLOR_VALUE $HOME remaining $RESET_COLORS
"