forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_list_sys_rrd
More file actions
executable file
·121 lines (94 loc) · 2.97 KB
/
v_list_sys_rrd
File metadata and controls
executable file
·121 lines (94 loc) · 2.97 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
#!/bin/bash
# info: list system rrd charts
# options: [format]
#
# List available rrd graphics, its titles and paths.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
# Define json function
json_list_rrd() {
i=1
echo "{"
for type in $rrd_types; do
for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
if [ "$i" -ne 1 ]; then
echo -e "\t},"
fi
# Define title
if [ "$type" = 'la' ]; then
title="Load Average"
fi
if [ "$type" = 'mem' ]; then
title="Memory Usage"
fi
if [ "$type" = 'net' ]; then
title="Bandwidth Usage $rrd"
fi
if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\
[ "$type" = 'ssh' ]; then
title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage"
fi
if [ "$type" = 'db' ]; then
db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \
-e 's/pgsql/PostgreSQL/g' )
db_host=$(echo $rrd|cut -f 2 -d _ )
title="$db_type Usage on $db_host"
fi
echo -e "\t\"$i\": {"
echo -e "\t\t\"TYPE\": \"$type\"",
echo -e "\t\t\"RRD\": \"$rrd\"",
echo -e "\t\t\"TITLE\": \"$title\""
(( ++i))
done
done
if [ "$i" -gt 1 ]; then
echo -e "\t}"
fi
echo "}"
}
# Define jshell function
shell_list_rrd() {
if [ -z "$nohead" ]; then
# Print brief info
echo "PATH"
echo "---------"
fi
for type in $rrd_types; do
for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
echo "$V_RRD/$type/$rrd.rrd"
done
done
}
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking enabled systems
rrd_types="la mem net"
if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
rrd_types="$rrd_types web"
fi
if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
rrd_types="$rrd_types db"
fi
if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
rrd_types="$rrd_types mail"
fi
if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
rrd_types="$rrd_types ftp"
fi
rrd_types="$rrd_types ssh"
# Listing domains
case $format in
json) json_list_rrd ;;
plain) nohead=1; shell_list_rrd ;;
shell) shell_list_rrd | column -t ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit