Created
March 9, 2021 14:00
-
-
Save Sabrimjd/b736b86e6d4c9a2fac33d0e8d739f8e2 to your computer and use it in GitHub Desktop.
Dynamic motd - requirements : figlet
This file contains hidden or 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 | |
[ -r /etc/lsb-release ] && . /etc/lsb-release | |
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; | |
then | |
# Fall back to using the very slow lsb_release utility | |
DISTRIB_DESCRIPTION=$(lsb_release -s -d) | |
fi | |
#figlet $(hostname) | |
#printf "\n" | |
printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)" | |
printf "\n" | |
figlet $(hostname) | |
printf "\n" | |
#!/bin/bash | |
GREEN='\033[00;32m' | |
CYAN='\033[00;36m' | |
NC='\033[0m' | |
date=$(date) | |
load=$(cat /proc/loadavg | awk '{print $1}') | |
root_usage=$(df -h / | awk '/\// {print $(NF-1)}') | |
var_usage=$(df -h /var | awk '/\// {print $(NF-1)}') | |
memory_usage=$(free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ {used=$3 } END { printf("%3.1f%%", used/total*100)}') | |
users=$(users | wc -w) | |
time=$(uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{printf $2" "$3 }') | |
processes=$(ps aux | wc -l) | |
ip=$(ip a show dev eth0 | grep "inet " | awk '{ print $2 }') | |
activehost=$(cat /var/tmp/activehost) | |
echo "System information as of: $date" | |
echo | |
printf "System load:\t%s\tIP Address:\t${GREEN}%s${NC}\n" $load $ip | |
printf "Memory usage:\t%s\tSystem uptime:\t%s\n" $memory_usage "$time" | |
printf "Usage on /:\t${CYAN}%s${NC}\tUsage on /var:\t${CYAN}%s${NC}\t\n" $root_usage $var_usage | |
printf "Local Users:\t%s\tProcesses:\t%s\n" $users $processes | |
echo -e "${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment