-
-
Save TinnyTerr/13af5600219aab8678ef99406f385f22 to your computer and use it in GitHub Desktop.
Example motd I use all the time
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/bash | |
# Get hostname | |
hostname=$(hostname) | |
# CPU usage | |
cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') | |
# Memory usage | |
memory_usage=$(free -m | awk '/^Mem/{printf("%.2f%%", $3/$2*100.0)}') | |
# External IP | |
external_ip=$(curl -s https://api.ipify.org) | |
# Big hostname | |
if command -v figlet &> /dev/null; then | |
bigHostname=$(figlet -f standard $hostname) | |
else | |
bigHostname="Figlet not installed. Install using package manager (eg debian='sudo apt install figlet')" | |
fi | |
# External IP | |
user=$(whoami) | |
# Colouring | |
RED="\e[31m" | |
CYAN="\e[36m" | |
NC="\e[0m" # No Color | |
# Message | |
printf "${RED}" | |
echo -e "${RED} $bigHostname ${NC}" | |
echo -e "${CYAN}-----------------------------------------------------------${NC}" | |
echo -e "${CYAN} CPU usage:${NC} $cpu_usage" | |
echo -e "${CYAN} Memory usage:${NC} $memory_usage" | |
echo -e "${CYAN} External IP:${NC} $external_ip" | |
echo -e "${CYAN} System Boot:${NC} $(uptime -s) ($(uptime -p))" | |
echo -e "${CYAN} Users logged in:${NC} $(who | wc -l)" | |
echo -e "${CYAN} Welcome${NC} $user${CYAN}! " | |
echo -e "${CYAN}-----------------------------------------------------------${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment