Tambah data network
parent
1d898c7a21
commit
c3b14ea4b1
|
@ -1,5 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
W="\e[0;39m"
|
||||
G="\e[1;32m"
|
||||
R="\e[1;31m"
|
||||
|
||||
# get load averages
|
||||
IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }')
|
||||
# get free memory
|
||||
|
@ -13,8 +17,27 @@ PROCESS_USER=`echo "$PROCESS"| grep -v root | awk {'print $2'} | awk '{ SUM += $
|
|||
PROCESSOR_NAME=`grep "model name" /proc/cpuinfo | cut -d ' ' -f3- | awk {'print $0'} | head -1`
|
||||
PROCESSOR_COUNT=`grep -ioP 'processor\t:' /proc/cpuinfo | wc -l`
|
||||
|
||||
W="\e[0;39m"
|
||||
G="\e[1;32m"
|
||||
## Adapted from https://github.com/mrlesmithjr/ansible-motd/blob/master/templates/etc/update-motd.d/30-sysinfo.j2
|
||||
# Capture DNS Servers
|
||||
DNS_SERVER="$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}' | tr '\r\n' ' ')"
|
||||
|
||||
# Capture Interfaces
|
||||
NET_INTERFACES="$(ip link show | awk -F: '$1>0 {print $2}' | grep -v lo)"
|
||||
|
||||
# Using captured interfaces loop through them and capture:
|
||||
# link state and ip address
|
||||
# Only if IP address is defined
|
||||
first=""
|
||||
NET_IPS="$(for int in ${NET_INTERFACES[@]};
|
||||
do
|
||||
state="$(ip link show $int | awk '{print $9}')"
|
||||
ip_addr="$(ip -4 add show $int | grep inet | awk '{print $2}'| awk -F/ '{print $1}')"
|
||||
if [ ! -z $ip_addr ]; then
|
||||
echo -e "$W$first$int [$R$state$W]: $G$ip_addr"
|
||||
first=" "
|
||||
fi
|
||||
done
|
||||
)"
|
||||
|
||||
echo -e "
|
||||
${W}system info:
|
||||
|
@ -26,4 +49,7 @@ $W Load........: $G$LOAD1$W (1m), $G$LOAD5$W (5m), $G$LOAD15$W (15m)
|
|||
$W Processes...: $W$G$PROCESS_ROOT$W (root), $G$PROCESS_USER$W (user), $G$PROCESS_ALL$W (total)
|
||||
|
||||
$W CPU.........: $W$PROCESSOR_NAME ($G$PROCESSOR_COUNT$W vCPU)
|
||||
$W Memory......: $G$USED$W used, $G$FREE$W free, $G$TOTAL$W total$W"
|
||||
$W Memory......: $G$USED$W used, $G$FREE$W free, $G$TOTAL$W total
|
||||
|
||||
$W IP Addresses: $NET_IPS
|
||||
$W DNS_SERVER..: $G$DNS_SERVER$W"
|
||||
|
|
Loading…
Reference in New Issue