-
Notifications
You must be signed in to change notification settings - Fork 3
/
motd-sysinfo
executable file
·36 lines (29 loc) · 1.01 KB
/
motd-sysinfo
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
#!/usr/bin/env bash
# os available ?
if [ -f /etc/os-release ]; then
source /etc/os-release
else
PRETTY_NAME="Linux"
fi
# Welcome Message
printf "\n%s\n" "$(date)"
printf "%s | %s\n" "$PRETTY_NAME" "$(uname -r)"
# Show Hostname
printf "\033[1;34m"
figlet $(hostname --short)
printf "\033[0m"
# System Params
load=`cat /proc/loadavg | awk '{print $2}'`
memory_usage=`free -m | awk '/Mem/ { printf("%3.1f%%", $3/($2+1)*100) }'`
memory_total=`free -g | awk '/Mem/ { printf("%3.0f", $2) }'`
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/($2+1)*100) }'`
swap_total=`free -g | awk '/Swap/ { printf("%3.0f", $2) }'`
users=`users | wc -w`
echo ""
printf "System load:\t%s\t\tMemory usage:\t%s of %sG\n" $load $memory_usage $memory_total
printf "Local users:\t%s\t\tSwap usage:\t%s of %sG\n" $users $swap_usage $swap_total
echo ""
# Get disk usage (use 2s timeout for weak nfs mounts)
timeout --signal=kill 2s df -h | grep -E "^(/dev/|Filesystem)"
# empty line
echo ""