Dynmotd: some fix (tabs instead of white spaces, $(cmd) instead of

`cmd`, ... )
This commit is contained in:
Jeremy Gardais 2015-01-28 16:29:24 +01:00
parent 58ad3f3232
commit f001d412de
1 changed files with 17 additions and 17 deletions

34
dynmotd
View File

@ -56,7 +56,7 @@ service_info() {
# If a port listen
if (netstat -lnt|grep -m1 ${PORT} > /dev/null); then
# Example: "tcp/127.0.0.1:25"
MSG="${MSG}${GREEN}`netstat -lnt|grep -m1 ${PORT}|awk '{print $1"/"$4}'`${RESET} "
MSG="${MSG}${GREEN}$(netstat -lnt|grep -m1 ${PORT}|awk '{print $1"/"$4}')${RESET} "
else
# Example: "22: NOT LISTENING"
MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} "
@ -81,9 +81,10 @@ SWAP_TOTAL=$(grep SwapTotal /proc/meminfo | awk '{print $2}')
#++++++++++++++++++++: User Data :++++++++++++++++++++++
USERNAME=$(whoami)
USER_SESSION=$(who | grep $USER | wc -l)
PROC_COUNT=`ps -Afl | wc -l`
PROC_COUNT=`expr $PROC_COUNT - 5`
#PROC_LIMIT=$(ulimit -u)
PROC_COUNT=$(ps -Afl | wc -l)
PROC_COUNT=$(expr $PROC_COUNT - 5)
# The "ulimit" from sh don't support the -u option
PROC_LIMIT=$(ulimit)
#++++++++++++: Authentication Information :+++++++++++++
#AUTH_LOG_FILE=$(find /var/log -iname "auth.log")
@ -105,19 +106,19 @@ fi
printf "%b" "\n${RESET}${MAGENTA}+++++++++++++++++++: ${WHITE}System Data${MAGENTA} :+++++++++++++++++++++${RESET}
${MAGENTA}+ ${WHITE}Hostname ${MAGENTA}= ${GREEN}${HOSTNAME}
${MAGENTA}+ ${WHITE}Addresses ${MAGENTA}= ${GREEN}${NET_ADDR}
${MAGENTA}+ ${WHITE}Kernel ${MAGENTA}= ${GREEN}${KERNEL_VER}
${MAGENTA}+ ${WHITE}Uptime ${MAGENTA}=${GREEN}${UPTIME}
${MAGENTA}+ ${WHITE}CPU ${MAGENTA}= ${GREEN}${CORE_NUMBER}x${CPU_MODEL}
${MAGENTA}+ ${WHITE}Memory ${MAGENTA}= ${GREEN}${MEM_FREE}(free)/${MEM_TOTAL}(total) kB
${MAGENTA}+ ${WHITE}Swap ${MAGENTA}= ${GREEN}${SWAP_FREE}(free)/${SWAP_TOTAL}(total) kB"
${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" "\n${RESET}${MAGENTA}++++++++++++++++++++: ${WHITE}User Data${MAGENTA} :++++++++++++++++++++++${RESET}
${MAGENTA}+ ${WHITE}Username ${MAGENTA}= ${GREEN}${USERNAME}
${MAGENTA}+ ${WHITE}Sessions ${MAGENTA}= ${GREEN}${USER_SESSION}
${MAGENTA}+ ${WHITE}Processes ${MAGENTA}= ${GREEN}$PROC_COUNT of ${PROC_LIMIT} MAX"
${MAGENTA}+ ${WHITE}Username\t${MAGENTA}= ${GREEN}${USERNAME}
${MAGENTA}+ ${WHITE}Sessions\t${MAGENTA}= ${GREEN}${USER_SESSION}
${MAGENTA}+ ${WHITE}Processes\t${MAGENTA}= ${GREEN}$PROC_COUNT of ${PROC_LIMIT} MAX"
printf '%b' "\n${MAGENTA}++++++++++++: ${WHITE}Authentication Information${MAGENTA} :+++++++++++++${RESET}"
@ -134,19 +135,18 @@ printf '%b' "\n${MAGENTA}++++++++++++: ${WHITE}Authentication Information${MAGEN
#echo -e "${MAGENTA}+ ${WHITE}Sudo fail ${MAGENTA}= ${GREEN}${SUDO_FAIL} fail(s) this week
#${MAGENTA}+ ${WHITE}Sudo 3 fails ${MAGENTA}= ${GREEN}${SUDO_3_FAIL} fail(s) this week"
printf '%b' "\n${MAGENTA}++++++++++++++++++++: ${WHITE}Disk Usage${MAGENTA} :+++++++++++++++++++++${RESET}"
# Root partition
# Replace by rootfs in few kernel version
DISK_USAGE=$(df | grep -m1 "/$" | awk '{print $5}')
printf '%b' "\n${MAGENTA}+ ${WHITEB}/${RESET} [ ${DISK_USAGE} ] "
printf '%b' "\n${MAGENTA}+ ${WHITEB}/${RESET}\t[ ${DISK_USAGE} ] "
# Other partition
for PART in /boot /home /opt /tmp /usr /var /var/lib/vz; do
# "/...$" : $ to grep only the mount point and not sub-directories (/var: OK; /mnt/temp: nOK)
if (df | grep "${PART}$" > /dev/null); then
DISK_USAGE=$(df | grep "${PART}$" | awk '{print $5}')
printf '%b' "\n${MAGENTA}+ ${WHITEB}${PART}${RESET} [ ${DISK_USAGE} ] "
printf '%b' "\n${MAGENTA}+ ${WHITEB}${PART}${RESET}\t[ ${DISK_USAGE} ] "
fi
done