Skip to content

Commit fed4d60

Browse files
committed
created rrd listing function
1 parent 2151ec2 commit fed4d60

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

bin/v_list_sys_rrd

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# info: listing available system rrd charts
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
format=${1-shell}
9+
10+
# Importing variables
11+
source $VESTA/conf/vars.conf
12+
source $V_CONF/vesta.conf
13+
14+
# Define json function
15+
json_list_rrd() {
16+
i=1
17+
echo "{"
18+
for type in $rrd_types; do
19+
for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
20+
if [ "$i" -ne 1 ]; then
21+
echo -e "\t},"
22+
fi
23+
echo -e "\\t\"$i\""
24+
echo -e "\t\t\"TYPE\": \"$type\"",
25+
echo -e "\t\t\"RRD\": \"$rrd\""
26+
(( ++i))
27+
done
28+
done
29+
30+
if [ "$i" -gt 1 ]; then
31+
echo -e "\t}"
32+
fi
33+
echo "}"
34+
}
35+
36+
# Define jshell function
37+
shell_list_rrd() {
38+
if [ -z "$nohead" ]; then
39+
# Print brief info
40+
echo "PATH"
41+
echo "---------"
42+
fi
43+
44+
for type in $rrd_types; do
45+
for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
46+
echo "$V_RRD/$type/$rrd.rrd"
47+
done
48+
done
49+
}
50+
51+
52+
53+
#----------------------------------------------------------#
54+
# Action #
55+
#----------------------------------------------------------#
56+
57+
# Checking enabled systems
58+
rrd_types="la mem net"
59+
60+
if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
61+
rrd_types="$rrd_types web"
62+
fi
63+
64+
if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
65+
rrd_types="$rrd_types db"
66+
fi
67+
68+
if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
69+
rrd_types="$rrd_types mail"
70+
fi
71+
72+
if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
73+
rrd_types="$rrd_types ftp"
74+
fi
75+
rrd_types="$rrd_types ssh"
76+
77+
78+
# Listing domains
79+
case $format in
80+
json) json_list_rrd ;;
81+
plain) nohead=1; shell_list_rrd ;;
82+
shell) shell_list_rrd | column -t ;;
83+
esac
84+
85+
86+
#----------------------------------------------------------#
87+
# Vesta #
88+
#----------------------------------------------------------#
89+
90+
exit

0 commit comments

Comments
 (0)