-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmuninpatch
executable file
·88 lines (65 loc) · 2.05 KB
/
muninpatch
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
#!/bin/bash
function add_munin_patch {
if [ -f /etc/munin/plugin-conf.d/cpanel.conf ]; then
echo ""
echo "=== Updating Munin configuration ==="
if grep -q "\[apache_status\]" /etc/munin/plugin-conf.d/cpanel.conf
then
echo "Munin patched already, nothing to do here"
else
cat >> "/etc/munin/plugin-conf.d/cpanel.conf" <<EOF
[apache_status]
env.ports 8081
env.label 8081
EOF
fi
ln -s /usr/local/cpanel/3rdparty/share/munin/plugins/nginx_request /etc/munin/plugins/nginx_request
ln -s /usr/local/cpanel/3rdparty/share/munin/plugins/nginx_status /etc/munin/plugins/nginx_status
sleep 10
service munin-node restart
fi
}
function remove_munin_patch {
if [ -f /etc/munin/plugin-conf.d/cpanel.conf ]; then
echo ""
echo "=== Updating Munin configuration ==="
if grep -q "\[apache_status\]" /etc/munin/plugin-conf.d/cpanel.conf
then
sed -i 's:\[apache_status\]::' /etc/munin/plugin-conf.d/cpanel.conf
sed -i 's:env\.ports 8081::' /etc/munin/plugin-conf.d/cpanel.conf
sed -i 's:env\.label 8081::' /etc/munin/plugin-conf.d/cpanel.conf
else
echo -e "\033[35;1m Munin not installed or not Pached, nothing to do here \033[0m"
fi
rm -f /etc/munin/plugins/nginx_request
rm -f /etc/munin/plugins/nginx_status
service munin-node restart
fi
}
### Define actions ###
case $1 in
install)
echo ""
echo " ****************************************************"
echo " * Paching Munin *"
echo " ****************************************************"
add_munin_patch
echo " ****************************************************"
echo " * Munin Pached *"
echo " ****************************************************"
echo ""
;;
remove)
remove_munin_patch
echo ""
echo " ****************************************************"
echo " * Munin Patch Removal Complete *"
echo " ****************************************************"
echo ""
;;
*)
echo ""
echo -e "\033[35;1m Please define an action: install | remove \033[0m"
echo ""
;;
esac