Stats32 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. #
  3. # Stats32 script generate some system infos for the motd file.
  4. # Date: 08/2017
  5. #
  6. # _______ __ __ ______ ______
  7. # | __| |_.---.-.| |_.-----.|__ |__ |
  8. # |__ | _| _ || _|__ --||__ | __|
  9. # |_______|____|___._||____|_____||______|______|
  10. #
  11. # by Erreur32
  12. #
  13. ## need figlet (auto installing with the ./install.sh)
  14. # figlet -f wideterm
  15. figlet -f chunky $(hostname)
  16. echo -e "\033[0m"
  17. [ -r /etc/lsb-release ] && . /etc/lsb-release
  18. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  19. # Fall back to using the very slow lsb_release utility
  20. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  21. fi
  22. printf "\033[5m%s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
  23. echo -e "\e[0mKernel Info: \033[5m " `uname -smr`;
  24. echo -e "Shell: $SHELL \e[0m"
  25. echo -e 'Last SSH:\e[1;30m'; last -a | grep pts | head -3
  26. echo -e "\e[0m"
  27. load=`cat /proc/loadavg | awk '{print $1}'`
  28. root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
  29. memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'`
  30. swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", "exit !$2;$3/$2*100") }'`
  31. users=`users | wc -w`
  32. time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'`
  33. processes=`ps aux | wc -l`
  34. ip=`hostname -i`
  35. # if IP fail try this
  36. # ip=`hostname -i | awk '{ printf $2 }'`
  37. printf "%s-----------\t---\t------------\t----------\n"
  38. printf "System load :\t%s\tIP Address:\t%s\n" $load $ip
  39. printf "Memory usage:\t%s\tSystem uptime:\t%s\n" $memory_usage "$time"
  40. printf "Usage on / :\t%s\tSwap usage:\t%s\n" $root_usage $swap_usage
  41. printf "Local Users :\t%s\tProcesses:\t%s\n" $users $processes
  42. printf "%s-----------\t---\t------------\t----------\n"
  43. echo -e "\n\e[93m Generated by MOTDs32\e[0m"