49 lines
1.7 KiB
Text
49 lines
1.7 KiB
Text
|
#! /usr/bin/env bash
|
||
|
|
||
|
# Basic info
|
||
|
HOSTNAME=`uname -n`
|
||
|
OSVERSION=`hostnamectl | grep "Operating System" | sed 's/^.*: //'`
|
||
|
CURRENTTIME=`date +"%Y-%m-%d %H:%M:%S"`
|
||
|
UPTIMEP=`uptime -p`
|
||
|
BOOTTIME=`uptime -s`
|
||
|
CONNECTEDUSERS=`who | wc -l`
|
||
|
|
||
|
# System load
|
||
|
MEMORY1=`free -t -m | grep Total | awk '{print $3" MB";}'`
|
||
|
MEMORY2=`free -t -m | grep "Mem" | awk '{print $2" MB";}'`
|
||
|
MEMORY3=`free -t -m | grep Mem | awk '{print $3/$2 * 100.0}'`
|
||
|
MEMORY4=`printf %.0f $MEMORY3`
|
||
|
LOAD1=`cat /proc/loadavg | awk {'print $1'}`
|
||
|
LOAD5=`cat /proc/loadavg | awk {'print $2'}`
|
||
|
LOAD15=`cat /proc/loadavg | awk {'print $3'}`
|
||
|
PROCESSES=`ps ax | wc -l | tr -d " "`
|
||
|
SWAPSTAT=`free -m | tail -n 1 | awk '{print $3}'`
|
||
|
USAGEROOT=`df -Ph | grep /$ | awk '{print $5 " of " $2}'`
|
||
|
IPADDRESSES=`ip a|grep -oP "inet \K[0-9.]*(?=.*[^ ][^l][^o]$)"`
|
||
|
|
||
|
{% if base_core_motd_banner != '' %}
|
||
|
BANNER='
|
||
|
{{ base_core_motd_banner }}
|
||
|
'
|
||
|
|
||
|
echo "$BANNER
|
||
|
*********************************************************************
|
||
|
{% else %}
|
||
|
echo "*********************************************************************
|
||
|
{% endif %}
|
||
|
- Hostname............: $HOSTNAME
|
||
|
- Operating System....: $OSVERSION
|
||
|
- Uptime..............: $UPTIMEP
|
||
|
- Current Time........: $CURRENTTIME
|
||
|
- Boot Time...........: $BOOTTIME
|
||
|
- Logged on users.....: $CONNECTEDUSERS
|
||
|
*********************************************************************
|
||
|
- Running Processes...: $PROCESSES
|
||
|
- CPU usage...........: $LOAD1, $LOAD5, $LOAD15 (1, 5, 15 min)
|
||
|
- Memory usage........: $MEMORY1 / $MEMORY2 ($MEMORY4%)
|
||
|
- Swap in use.........: $SWAPSTAT MB
|
||
|
- Usage of /..........: $USAGEROOT
|
||
|
- IP Addresses........: $IPADDRESSES
|
||
|
*********************************************************************
|
||
|
"
|