Files
MOTD/20-sysinfo
2020-07-18 07:26:38 +00:00

24 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# get free memory
IFS=" " read USED FREE TOTAL <<<$(free -htm | grep "Mem" | awk {'print $3,$4,$2'})
ISF2=" " read USEDSW FREESW TOTALSW <<<$(free -htm | grep "Swap" | awk {'print $3,$4,$2'})
# get processes
PROCESS=`ps -eo user=|sort|uniq -c | awk '{ print $2 " " $1 }'`
PROCESS_ALL=`echo "$PROCESS"| awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'`
PROCESS_ROOT=`echo "$PROCESS"| grep root | awk {'print $2'}`
PROCESS_USER=`echo "$PROCESS"| grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }'`
W="\e[0;39m"
G="\e[1;33m"
echo -e "
${W}system info:
$W Uptime.: $W`uptime -p | awk '{if ($1 != "test") printf("%s %s %s %s\n", $2, $3, $4, $5); }' | sed 's/,//g'`
$W Distro.: $W`cat /etc/*release | grep "PRETTY_NAME" | cut -d "=" -f 2- | sed 's/"//g'`
$W Kernel.: $W`uname -sr`
$W Proc...: $W$G$PROCESS_ROOT$W (r), $G$PROCESS_USER$W (u) | $G$PROCESS_ALL$W (t)
$W CPU....:$W`cat /proc/cpuinfo | grep "name" | cut -d : -f2 | uniq | cut -f1 -d"@" | sed 's/(TM)//;s/(R)//;s/CPU//'`
$W Memory.: $G$USED$W used | $G$TOTAL$W in total$W
$W Swap...: $G$USEDSW$W used | $G$TOTALSW$W in total$W"