server_info.sh
4.33 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
# irul@20200907
if [[ `id -u` -ne 0 ]] ; then printf "\nPlease run as root.\n\n" ; exit 1 ; fi
clear
# https://www.2daygeek.com/bash-shell-script-view-linux-system-information/
echo -e "== System Information =="
echo -e "Manufacturer: "`cat /sys/class/dmi/id/chassis_vendor`
echo -e "Product Name: "`cat /sys/class/dmi/id/product_name`
echo -e "Version: "`cat /sys/class/dmi/id/product_version`
echo -e "Serial Number: "`cat /sys/class/dmi/id/product_serial`
echo -e "Machine Type: "`vserver=$(lscpu | grep Hypervisor | wc -l); if [ $vserver -gt 0 ]; then echo "VM"; else echo "Physical"; fi`
echo -e "Kernel: "`uname -r`
echo -e "Architecture: "`arch`
echo -e "Processor Name: "`awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//'`
echo ""
echo -e "HDD: "`lsblk -dio SIZE,KNAME,MODEL,TYPE | grep disk`
echo -e "Memory(RAM): "`free -mht| awk '/Mem/{print $2 " |Used: " $3 " |Free: " $4}'`
echo -e "Swap Memory: "`free -mht| awk '/Swap/{print $2 " |Used: " $3 " |Free: " $4}'`
echo ""
# echo -e "Operating System: "`hostnamectl | grep "Operating System" | cut -d ' ' -f5-`;
echo -e "Operating System: "`cat /etc/*release | grep PRETTY_NAME | cut -d "=" -f 2 | tr -d '"'`
echo -e "Using Systemd: "`pidof systemd && echo "True" || echo "False"`
echo -e "Hostname: "`hostname`
echo ""
# echo -e "Server IP: "`hostname -I`
echo -e "Server IP: "`/sbin/ip -4 a | grep "inet " | tail -n +2 | awk '{print $7 "=" $2}'`
echo -e "Default Gateway: "`ip route show | sed 's/\(\S\+\s\+\)\?default via \(\S\+\).*/\2/p; d'`
echo -e "Uptime: "`uptime | awk '{print $3,$4}' | sed 's/,//'`
echo ""
echo -e "== Base Application =="
# virtualmin
if dpkg --get-selections | grep -E '(^|\s)virtualmin-core($|\s)' &> /dev/null
then
echo "[x] virtualmin-core-"$(dpkg -l virtualmin-core | grep ^ii | awk '{print $3}' | cut -f1 -d-)
elif dpkg --get-selections | grep -E '(^|\s)virtualmin-custom($|\s)' &> /dev/null
then
echo "[x] virtualmin-custom-"$(dpkg -l virtualmin-custom | grep ^ii | awk '{print $3}' | cut -f1 -d-)
else
echo "[_] virtualmin"
fi
# webmin
if dpkg --get-selections | grep webmin &> /dev/null
then
echo "[x] webmin-"$(dpkg -l webmin | grep ^ii | awk '{print $3}' | cut -f1 -d-)
else
echo "[_] webmin"
fi
# openvpn
if command -v openvpn &> /dev/null
then
echo "[x] openvpn-"$(openvpn --version | head -n 1 | cut -d " " -f 2)
else
echo "[_] openvpn"
fi
# git
if command -v git &> /dev/null
then
echo "[x] git-"$(git --version | head -n 1 | cut -d " " -f 3)
else
echo "[_] git"
fi
# apache2
if dpkg --get-selections | grep -E '(^|\s)apache2($|\s)' &> /dev/null
then
echo "[x] apache2-"$(dpkg -l apache2 | grep ^ii | awk '{print $3}' | cut -f1 -d-)
else
echo "[_] apache2"
fi
# nginx
if dpkg --get-selections | grep nginx &> /dev/null
then
echo "[x] nginx-"$(dpkg -l nginx | grep ^ii | awk '{print $3}' | cut -f1 -d-)
else
echo "[_] nginx"
fi
# postgresql
if command -v psql &> /dev/null
then
echo "[x] postgresql-"$(psql -V | head -n 1 | cut -d " " -f 3)
else
echo "[_] postgresql"
fi
# mysql
if command -v mysql &> /dev/null
then
echo "[x] mysql-"$(dpkg -l mysql-server | grep ^ii | awk '{print $3}' | cut -f1 -d-)
else
echo "[_] mysql"
fi
# python3
if command -v python3 &> /dev/null
then
echo "[x] python3-"$(python3 --version | head -n 1 | cut -d " " -f 2)
else
echo "[_] python3"
fi
# php
if command -v php &> /dev/null
then
echo "[x] php-"$(php -v | head -n 1 | cut -d " " -f 2)
else
echo "[_] php"
fi
echo ""
if dpkg --get-selections | grep -E '(^|\s)apache2($|\s)' &> /dev/null ; then
#echo "== Sites Available ==";
#echo -e `apache2ctl -S 2>&1 | grep "namevhost" | awk '{print "(" NR ") " $4}'`
SITES=$(echo `apache2ctl -S 2>&1 |grep "sites-en"|cut -d"/" -f5|cut -d ":" -f1|rev|cut -d"." -f2-|rev|grep -v "default"|uniq -u|sort`)
if [ ! -z "$SITES" ] ; then
echo "== Sites Available ==";
SITES_CNT=1
for SITE in $SITES
do
if curl -I "$SITE" 2>&1 | grep -w "200\|301" > /dev/null ; then
echo "$SITES_CNT $SITE is up"
else
echo "$SITES_CNT $SITE is down"
fi
SITES_CNT=$[$SITES_CNT +1]
done
echo ""
fi
fi
if ! command -v curl &> /dev/null ; then
echo "Curl command not found!"
echo ""
fi
echo "Last Check: "$(date '+%Y-%m-%d %H:%M')
echo ""