-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcheck_all_critical_stuff.sh
executable file
·43 lines (35 loc) · 1.36 KB
/
check_all_critical_stuff.sh
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
#!/bin/bash
if [ -d /usr/lib/nagios/plugins ]; then
NAGIOS_PLUGINS=/usr/lib/nagios/plugins
else
NAGIOS_PLUGINS=/usr/lib64/nagios/plugins
fi
set -e
set -o pipefail
check_tmp_rw(){
cp /etc/motd /tmp/$$.tmp
rm /tmp/$$.tmp
echo "OK - /tmp is writable"
}
(
check_tmp_rw
$NAGIOS_PLUGINS/check_nrpe -4 -H localhost -c check_disk_full | sed 's/|.*//g'
for dbms in mysql pg mongodb redis; do
if grep -q "command\[check_${dbms}_connection\]" /etc/nagios/nrpe.d/nrpe_local.cfg; then
$NAGIOS_PLUGINS/check_nrpe -4 -H localhost -c check_${dbms}_connection | sed 's/|.*//g'
fi
done
if [ -f /etc/apache2/apache2.conf ] || [ -f /etc/nginx/nginx.conf ] || [ -f /etc/haproxy/haproxy.cfg ]; then
# Sometime we can disable 80 so we need to check both 80 & 443
/usr/lib/nagios/plugins/check_tcp -H localhost -p 80 || /usr/lib/nagios/plugins/check_tcp -H localhost -p 443 | sed 's/|.*//g'
# check_http
#/usr/lib/nagios/plugins/check_http -H localhost | sed 's/|.*//g'
fi
# Do not work well
#for webserver in apache2 nginx; do
# if grep -q "command\[check_${webserver}_status\]" /etc/nagios/nrpe.d/nrpe_local.cfg; then
# $NAGIOS_PLUGINS/check_nrpe -4 -H localhost -c check_${webserver}_status | sed 's/|.*//g'
# fi
#done
echo "OK - Everything is Awesome"
) | tac # Shinken uses the first line as the main output, so we need to inverse the output