-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10-serverinfo
40 lines (31 loc) · 2.13 KB
/
10-serverinfo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
UPTIME_DAYS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 / 86400)
UPTIME_HOURS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 / 3600)
UPTIME_MINUTES=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 % 3600 / 60)
HOSTNAME_VAR=$(hostname)
LOCALIP=$(ip -4 -o addr show $(ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $5}') |\
egrep -o "([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}" |\
head -n 1)
REMOTEIP=$(dig +short -4 myip.opendns.com @resolver1.opendns.com)
REMOTEIPV6=$(dig +short -6 myip.opendns.com AAAA @resolver1.opendns.com)
cat << EOF
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ Server │
│ Information │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Name: $HOSTNAME_VAR
Uptime: $UPTIME_DAYS days, $UPTIME_HOURS hours, $UPTIME_MINUTES minutes
CPU: `cat /proc/cpuinfo | grep 'model name' | head -1 | cut -d':' -f2`
Memory: `free -m | head -n 2 | tail -n 1 | awk {'print $2'}`M
Swap: `free -m | tail -n 1 | awk {'print $2'}`M
Disk: `df -h / | awk '{ a = $2 } END { print a }'`
Distro: `lsb_release -s -d` with `uname -r`
CPU Load: `cat /proc/loadavg | awk '{print $1 ", " $2 ", " $3}'`
Free Memory: `free -m | head -n 2 | tail -n 1 | awk {'print $4'}`M
Free Swap: `free -m | tail -n 1 | awk {'print $4'}`M
Free Disk: `df -h / | awk '{ a = $2 } END { print a }'`
Local Address: $LOCALIP
Public IPv4 Address: $REMOTEIP
EOF