dynmotd/templates/motd_system_info.erb

49 lines
1.6 KiB
Plaintext
Executable File

#! /usr/bin/env sh
#############################################################################
#
# Usage:
#
#############################################################################
#### Colors definition
BLACK='\033[30;40m'
RED='\033[0;31m'
REDB='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[34;40m'
MAGENTA='\033[0;35m'
CYAN='\033[36;40m'
WHITE='\033[0;37m'
WHITEB='\033[1;37m'
RESET='\033[0m'
#+++++++++++++++++++: System Data :+++++++++++++++++++
HOSTNAME=$(hostname)
NET_ADDR=$(hostname -I)
KERNEL_VER=$(uname -r)
UPTIME=$(uptime | sed 's/.*up ([^,]*), .*/1/')
CORE_NUMBER=$(grep "model name" /proc/cpuinfo | wc -l)
CPU_MODEL=$(grep -m1 "model name" /proc/cpuinfo | awk -F: '{print $2}')
MEM_FREE=$(grep MemFree /proc/meminfo | awk '{print $2}')
MEM_TOTAL=$(grep MemTotal /proc/meminfo | awk '{print $2}')
SWAP_FREE=$(grep SwapFree /proc/meminfo | awk '{print $2}')
SWAP_TOTAL=$(grep SwapTotal /proc/meminfo | awk '{print $2}')
printf '%b' "${RESET}${MAGENTA}+++++++++++++++++++: ${WHITE}System Data${MAGENTA} :+++++++++++++++++++++${RESET}
${MAGENTA}+ ${WHITE}Hostname\t${MAGENTA}= ${GREEN}${HOSTNAME}
${MAGENTA}+ ${WHITE}Addresses\t${MAGENTA}= ${GREEN}${NET_ADDR}
${MAGENTA}+ ${WHITE}Kernel\t${MAGENTA}= ${GREEN}${KERNEL_VER}
${MAGENTA}+ ${WHITE}Uptime\t${MAGENTA}=${GREEN}${UPTIME}
${MAGENTA}+ ${WHITE}CPU\t\t${MAGENTA}= ${GREEN}${CORE_NUMBER}x${CPU_MODEL}
${MAGENTA}+ ${WHITE}Memory\t${MAGENTA}= ${GREEN}${MEM_FREE}(free)/${MEM_TOTAL}(total) kB
${MAGENTA}+ ${WHITE}Swap\t\t${MAGENTA}= ${GREEN}${SWAP_FREE}(free)/${SWAP_TOTAL}(total) kB"
printf '%b' "${RESET}\n"