Segue um script para configurar o MOTD em servidores linux.
#!/bin/bash # # Server Status Script CPUTIME=$(ps -eo pcpu | awk 'NR>1' | awk '{tot=tot+$1} END {print tot}') CPUCORES=$(cat /proc/cpuinfo | grep -c processor) UP=$(echo `uptime` | awk '{ print $3 " " $4 }') echo " System Status Updated: `date` - Server Name = `hostname` - Public IP = `dig +short txt ch whoami.cloudflare @1.0.0.1` - OS Version = `lsb_release -c | awk {'print $2'}` - Load Averages = `cat /proc/loadavg` - System Uptime = `echo $UP` - Platform Data = `uname -a` - CPU Usage (average) = `echo $CPUTIME / $CPUCORES | bc`% - Memory free (real) = `free -m | head -n 2 | tail -n 1 | awk {'print $4'}` Mb - Memory free (cache) = `free -m | head -n 3 | tail -n 1 | awk {'print $3'}` Mb - Swap in use = `free -m | tail -n 1 | awk {'print $3'}` Mb - Disk Total = `df -h | grep /dev/sda | awk '{ a = $2 } END { print a }'` - Disk Usado = `df -h | grep /dev/sda | awk '{ a = $3 } END { print a }'` - Disk Disponivel = `df -h | grep /dev/sda | awk '{ a = $4 } END { print a }'` " > /etc/motd # End of script