motd.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. DISTRIB_DESCRIPTION=$(cat /etc/centos-release)
  3. #change 'CentOS' to something else, if you want to name your server or display a phrase
  4. DISPLAYNAME=CentOS
  5. LOLCAT=/usr/local/bin/lolcat #whereis lolcat if your system put it somewhere else
  6. figlet $DISPLAYNAME -c | $LOLCAT -f
  7. printf "\n"
  8. printf "\t%s \tKernel: %s\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
  9. printf "\n"
  10. date=$(date)
  11. LOAD1=$(cat /proc/loadavg | awk '{print $1}')
  12. LOAD5=$(cat /proc/loadavg | awk '{print $2}')
  13. LOAD15=$(cat /proc/loadavg | awk '{print $3}')
  14. # uptime
  15. uptime=$(cat /proc/uptime | cut -f1 -d.)
  16. upDays=$((uptime/60/60/24))
  17. upHours=$((uptime/60/60%24))
  18. upMins=$((uptime/60%60))
  19. upSecs=$((uptime%60))
  20. # filesystem info
  21. root_usage=$(df -h / | awk '/\// {print $4}'|grep -v "^$")
  22. # memory
  23. memory_usage=$(free -t -g | grep Total | awk '{print $3;}')
  24. total_memory=$(free -t -g | grep "Mem" | awk '{print $2" GB";}')
  25. swap_usage=$(free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }')
  26. # users
  27. users=$(users | wc -w)
  28. # processes
  29. processes=$(ps aux | wc -l)
  30. printf "\tSystem information as of: %s\n\n" "$date"
  31. printf "\tSystem Load:\t%s %s %s\tSystem Uptime:\t\t%s days %s hours %s min %s sec\n" "$LOAD1", "$LOAD5", "$LOAD15" "$upDays" "$upHours" "$upMins" "$upSecs"
  32. printf "\tMemory Usage:\t%s\t\t\tSwap Usage:\t\t%s\n" "$memory_usage"/"$total_memory" "$swap_usage"
  33. printf "\tUsage:\t\t%s\t\t\tSFTP Accounts:\t\t%s\n" "$root_usage" "$users"
  34. printf "\tProcesses:\t%s\t\t\t\n\n" "$processes"
  35. #include the updater; sourced from update-check.sh
  36. source /etc/update-motd.d/90-updates-available
  37. printf "\n\n"