-
-
Save bearlikelion/4feaa1ffbb64e6c22b99c0c7161c197d to your computer and use it in GitHub Desktop.
Alpine Linux Dynamic MOTD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#/etc/periodic/15min/motd | |
UPTIME_DAYS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 / 86400) | |
UPTIME_HOURS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 / 3600) | |
UPTIME_MINUTES=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 % 3600 / 60) | |
cat > /etc/motd << EOF | |
%--------------------------------------------------------------% | |
Hostname: `hostname`.`dnsdomainname` | |
Uptime: $UPTIME_DAYS days, $UPTIME_HOURS hours, $UPTIME_MINUTES minutes | |
Distro: `uname -v` with `uname -r` | |
CPU: `cat /proc/loadavg | awk '{print $1 ", " $2 ", " $3}'` | |
Disk: `df -h / | tail -n 1 | awk {'print $3'}` / `df -h / | tail -n 1 | awk {'print $2'}` (`df -h / | tail -n 1 | awk {'print $5'}` used) | |
Memory: `free -m | head -n 2 | tail -n 1 | awk {'print $3'}`M / `free -m | head -n 2 | tail -n 1 | awk {'print $2'}`M | |
Swap: `free -m | tail -n 1 | awk {'print $3'}`M / `free -m | tail -n 1 | awk {'print $4'}`M | |
IP Address: `ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` | |
%--------------------------------------------------------------% | |
EOF |
Author
bearlikelion
commented
Jan 7, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment