Skip to content

Commit 841c979

Browse files
committed
Server monitoring tools
1 parent 9db728e commit 841c979

File tree

10 files changed

+586
-9
lines changed

10 files changed

+586
-9
lines changed

bin/v-list-sys-cpu-status

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# info: list system cpu info
3+
# options: [FORMAT]
4+
#
5+
# The function lists cpu information
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Displaying top 30
24+
top -b -n1 | head -n 37
25+
echo -en "\n-------------------------------------"
26+
echo -en "-------------------------------------\n\n"
27+
28+
# Displaying process tree
29+
pstree -s
30+
echo -en "\n-------------------------------------"
31+
echo -en "-------------------------------------\n\n"
32+
33+
# Displaying CPU information
34+
grep 'model name' /proc/cpuinfo|cut -f 2 -d : | sed "s/ //"
35+
echo
36+
lscpu 2>/dev/null
37+
38+
#----------------------------------------------------------#
39+
# Vesta #
40+
#----------------------------------------------------------#
41+
42+
exit

bin/v-list-sys-db-status

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
# info: list db status
3+
# options: [FORMAT]
4+
#
5+
# The function lists db server status
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
source $VESTA/conf/vesta.conf
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Checking db system
24+
if [ -z "$DB_SYSTEM" ]; then
25+
exit
26+
fi
27+
28+
# Checking supported database systems
29+
for db in $(echo $DB_SYSTEM| tr ',' '\n'); do
30+
OLD_IFS="$IFS"
31+
IFS=$'\n'
32+
33+
# Checking database config
34+
if [ -e "$VESTA/conf/$db.conf" ]; then
35+
36+
# Checking server status
37+
for host_str in $(cat $VESTA/conf/$db.conf); do
38+
eval $host_str
39+
40+
# Checking MySQL
41+
if [ "$db" = 'mysql' ]; then
42+
mycnf="$VESTA/conf/.mysql.$HOST"
43+
if [ ! -e "$mycnf" ]; then
44+
echo "[client]">$mycnf
45+
echo "host='$HOST'" >> $mycnf
46+
echo "user='$USER'" >> $mycnf
47+
echo "password='$PASSWORD'" >> $mycnf
48+
chmod 600 $mycnf
49+
else
50+
mypw=$(grep password $mycnf|cut -f 2 -d \')
51+
if [ "$mypw" != "$PASSWORD" ]; then
52+
echo "[client]">$mycnf
53+
echo "host='$HOST'" >> $mycnf
54+
echo "user='$USER'" >> $mycnf
55+
echo "password='$PASSWORD'" >> $mycnf
56+
chmod 660 $mycnf
57+
fi
58+
fi
59+
echo "MySQL $HOST status"
60+
mysqladmin --defaults-file=$mycnf status |sed -e "s/ /\n/g"
61+
echo
62+
mysqladmin --defaults-file=$mycnf processlist
63+
echo -en "\n-------------------------------------"
64+
echo -en "-------------------------------------\n\n"
65+
fi
66+
67+
# Checking PostgreSQL
68+
if [ "$db" = 'pgsql' ]; then
69+
echo "PostgreSQL $HOST status"
70+
export PGPASSWORD="$PASSWORD"
71+
psql -h $HOST -U $USER -c "SELECT * FROM pg_stat_activity"
72+
fi
73+
done
74+
fi
75+
IFS="$OLD_IFS"
76+
done
77+
78+
79+
#----------------------------------------------------------#
80+
# Vesta #
81+
#----------------------------------------------------------#
82+
83+
exit

bin/v-list-sys-disk-status

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# info: list disk information
3+
# options: [FORMAT]
4+
#
5+
# The function lists disk information
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Displaying disk usage
24+
df -h
25+
echo -en "\n-------------------------------------"
26+
echo -en "-------------------------------------\n\n"
27+
28+
# Displaying I/O usage
29+
iostat -m
30+
echo -en "\n-------------------------------------"
31+
echo -en "-------------------------------------\n\n"
32+
33+
# Displaying disk information
34+
fdisk -l
35+
36+
#----------------------------------------------------------#
37+
# Vesta #
38+
#----------------------------------------------------------#
39+
40+
exit

bin/v-list-sys-dns-status

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
# info: list dns status
3+
# options: [FORMAT]
4+
#
5+
# The function lists dns server status
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
source $VESTA/conf/vesta.conf
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Checking dns system
24+
if [ -z "$DNS_SYSTEM" ]; then
25+
exit
26+
fi
27+
28+
# Checking statistics-file on RHEL/CentOS
29+
if [ -e "/etc/named/named.conf" ]; then
30+
conf="/etc/named/named.conf"
31+
dump_file='/var/named/data/named_stats.txt'
32+
dump_option=" dump-file \"$dump_file\";"
33+
opt_check=$(grep $dump_file $conf |grep -v //)
34+
if [ -z "$opt_check" ]; then
35+
sed -i "s|options {|options {\n$dump_option|" $conf
36+
service named restart >/dev/null 2>&1
37+
fi
38+
fi
39+
if [ -e "/etc/named.conf" ]; then
40+
conf="/etc/named.conf"
41+
dump_file='/var/named/data/named_stats.txt'
42+
dump_option=" dump-file \"$dump_file\";"
43+
opt_check=$(grep $dump_file $conf |grep -v //)
44+
if [ -z "$opt_check" ]; then
45+
sed -i "s|options {|options {\n$dump_option|" $conf
46+
service named restart >/dev/null 2>&1
47+
fi
48+
fi
49+
50+
# Checking statistics-file on Debian/Ubuntu
51+
if [ -e "/etc/bind/named.conf" ]; then
52+
conf="/etc/bind/named.conf.options"
53+
dump_file='/var/cache/bind/named.stats'
54+
#dump_option=" dump-file \"$dump_file\";"
55+
#opt_check=$(grep $dump_file $conf |grep -v //)
56+
#if [ -z "$opt_check" ]; then
57+
# sed -i "s|options {|options {\n$dump_option|" $conf
58+
# service named restart >/dev/null 2>&1
59+
#fi
60+
fi
61+
62+
# Generating dns stats
63+
rm -f $dump_file 2>/dev/null
64+
/usr/sbin/rndc stats 2>/dev/null
65+
66+
# Displaying dns status
67+
if [ -e "$dump_file" ]; then
68+
cat $dump_file
69+
fi
70+
71+
#----------------------------------------------------------#
72+
# Vesta #
73+
#----------------------------------------------------------#
74+
75+
exit

bin/v-list-sys-mail-status

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# info: list mail status
3+
# options: [FORMAT]
4+
#
5+
# The function lists mail server status
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
source $VESTA/conf/vesta.conf
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Checking mail system
24+
if [ -z "$MAIL_SYSTEM" ]; then
25+
exit
26+
fi
27+
28+
# Displaying exim queue status
29+
echo "Exim queue status"
30+
exim -bp
31+
echo -en "\n-------------------------------------"
32+
echo -en "-------------------------------------\n\n"
33+
34+
# Displaying exim stats
35+
if [ -e "/var/log/exim4/mainlog" ]; then
36+
eximstats /var/log/exim4/mainlog 2>/dev/null
37+
else
38+
eximstats /var/log/exim/main.log 2>/dev/null
39+
fi
40+
41+
42+
#----------------------------------------------------------#
43+
# Vesta #
44+
#----------------------------------------------------------#
45+
46+
exit

bin/v-list-sys-memory-status

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# info: list virtual memory info
3+
# options: [FORMAT]
4+
#
5+
# The function lists virtual memory information
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Displaying memory and swap usage
24+
free -t -m
25+
echo -en "\n-------------------------------------"
26+
echo -en "-------------------------------------\n\n"
27+
28+
# Displaying memory stats
29+
vmstat -S m -s
30+
echo -en "\n-------------------------------------"
31+
echo -en "-------------------------------------\n\n"
32+
33+
# Displaying ram information
34+
dmidecode -t 17 2>/dev/null
35+
36+
#----------------------------------------------------------#
37+
# Vesta #
38+
#----------------------------------------------------------#
39+
40+
exit

bin/v-list-sys-network-status

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# info: list system network status
3+
# options: [FORMAT]
4+
#
5+
# The function lists network status
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
#format=${1-shell}
14+
15+
# Includes
16+
#source $VESTA/func/main.sh
17+
18+
19+
#----------------------------------------------------------#
20+
# Action #
21+
#----------------------------------------------------------#
22+
23+
# Displaying network stats
24+
ss -s
25+
echo -en "\n-------------------------------------"
26+
echo -en "-------------------------------------\n\n"
27+
28+
# Displaying network usage
29+
lsof -itcp -n -P
30+
echo -en "\n-------------------------------------"
31+
echo -en "-------------------------------------\n\n"
32+
33+
# Displaying network interfaces
34+
ifconfig
35+
36+
#----------------------------------------------------------#
37+
# Vesta #
38+
#----------------------------------------------------------#
39+
40+
exit

0 commit comments

Comments
 (0)