fix memory status

This commit is contained in:
root 2014-12-19 13:14:08 +01:00
parent 84d4d7c4fe
commit 166e9a217f
1 changed files with 10 additions and 12 deletions

View File

@ -1,9 +1,8 @@
#!/bin/bash #!/bin/bash
#Script to update motd with relevant information. #Script to update motd with relevant information.
#Define output file #Define output file
motd="/etc/motd" motd="/etc/motd"
# Collect information # Collect information
# $USER is automatically defined # $USER is automatically defined
HOSTNAME=`uname -n` HOSTNAME=`uname -n`
@ -15,24 +14,23 @@ CPU_TEMP=$(($(</sys/class/thermal/thermal_zone0/temp) / 1000))
ARCH=`uname -m` ARCH=`uname -m`
PACMAN=`pacman -Qu | wc -l` PACMAN=`pacman -Qu | wc -l`
DISC=`df -hT | awk '/md0/ {print $4 "/" $3 " (" $6 ")" }'` DISC=`df -hT | awk '/md0/ {print $4 "/" $3 " (" $6 ")" }'`
MEMORY1=`free -t -m | grep "buffers/cache" | awk '{print $3" MB";}'` MEMORY=`free -m -t | awk 'NR==2 { printf "%sMB / %sMB\n", $3, $2 }'`
MEMORY2=`free -t -m | grep "Mem" | awk '{print $2" MB";}'`
PSA=`ps -Afl | wc -l` PSA=`ps -Afl | wc -l`
PSU=`ps U $USER h | wc -l` PSU=`ps U $USER h | wc -l`
#System uptime #System uptime
uptime=`cat /proc/uptime | cut -f1 -d.` uptime=`cat /proc/uptime | cut -f1 -d.`
upDays=$((uptime/60/60/24)) upDays=$((uptime/60/60/24))
upHours=$((uptime/60/60%24)) upHours=$((uptime/60/60%24))
upMins=$((uptime/60%60)) upMins=$((uptime/60%60))
upSecs=$((uptime%60)) upSecs=$((uptime%60))
#System load #System load
LOAD1=`awk {'print $1'} /proc/loadavg` LOAD1=`awk {'print $1'} /proc/loadavg`
LOAD5=`awk {'print $2'} /proc/loadavg` LOAD5=`awk {'print $2'} /proc/loadavg`
LOAD15=`awk {'print $3'} /proc/loadavg` LOAD15=`awk {'print $3'} /proc/loadavg`
#Color variables #Color variables
W="\033[00;37m" W="\033[00;37m"
B="\033[01;36m" B="\033[01;36m"
@ -42,18 +40,18 @@ A="\033[01;32m"
#Clear screen before motd #Clear screen before motd
clear > $motd clear > $motd
echo -e " echo -e "
$A. $X $A. $X
$A/#\ $X _ $A _ _ $A/#\ $X _ $A _ _
$A/###\ $X __ _ _ __ ___| |__ $A| (_)_ __ _ ___ __ $A/###\ $X __ _ _ __ ___| |__ $A| (_)_ __ _ ___ __
$A/#####\ $X / _' | '__/ __| '_ \ $A| | | '_ \| | | \ \/ / $A/#####\ $X / _' | '__/ __| '_ \ $A| | | '_ \| | | \ \/ /
$A/##.-.##\ $X | (_| | | | (__| | | |$A| | | | | | |_| |> < $A/##.-.##\ $X | (_| | | | (__| | | |$A| | | | | | |_| |> <
$A/##( )##\ $X \__,_|_| \___|_| |_|$A|_|_|_| |_|\__,_/_/\_\\ $A/##( )##\ $X \__,_|_| \___|_| |_|$A|_|_|_| |_|\__,_/_/\_\\
$A/#.-- --.#\ $X $A/#.-- --.#\ $X
$A/' '\ $B $A/' '\ $B
" >> $motd " >> $motd
echo -e "$R===============================================================" >> $motd echo -e "$R===============================================================" >> $motd
echo -e " $R KERNEL $W= $KERNEL (installed: $INSTALLED_KERNEL) " >> $motd echo -e " $R KERNEL $W= $KERNEL (installed: $INSTALLED_KERNEL) " >> $motd
echo -e " $R CPU $W= $CPU " >> $motd echo -e " $R CPU $W= $CPU " >> $motd
@ -63,7 +61,7 @@ echo -e " $R USERS $W= Currently `users | wc -w` users logged on " >> $mot
echo -e "$R===============================================================" >> $motd echo -e "$R===============================================================" >> $motd
echo -e " $R CPU Usage $W= $LOAD1 1 min $LOAD5 5 min $LOAD15 15 min " >> $motd echo -e " $R CPU Usage $W= $LOAD1 1 min $LOAD5 5 min $LOAD15 15 min " >> $motd
echo -e " $R CPU Temperature $W= $CPU_TEMP" >> $motd echo -e " $R CPU Temperature $W= $CPU_TEMP" >> $motd
echo -e " $R Memory Used $W= $MEMORY1 / $MEMORY2 " >> $motd echo -e " $R Memory Used $W= $MEMORY " >> $motd
echo -e " $R Swap in use $W= `free -m | tail -n 1 | awk '{print $3}'` MB " >> $motd echo -e " $R Swap in use $W= `free -m | tail -n 1 | awk '{print $3}'` MB " >> $motd
echo -e " $R Processes $W= You are running $PSU of $PSA processes " >> $motd echo -e " $R Processes $W= You are running $PSU of $PSA processes " >> $motd
echo -e " $R System Uptime $W= $upDays days $upHours hours $upMins minutes $upSecs seconds " >> $motd echo -e " $R System Uptime $W= $upDays days $upHours hours $upMins minutes $upSecs seconds " >> $motd