#5453: adding nagios poll for mirrorlist individual servers
This commit is contained in:
parent
a09c776cca
commit
f698e3b250
6 changed files with 128 additions and 0 deletions
59
roles/nagios/client/files/scripts/check_haproxy_mirrorlist.py
Executable file
59
roles/nagios/client/files/scripts/check_haproxy_mirrorlist.py
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import socket
|
||||
import sys
|
||||
|
||||
|
||||
try:
|
||||
|
||||
unixsocket="/var/run/haproxy-stat"
|
||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
s.connect(unixsocket)
|
||||
s.send('show stat\n')
|
||||
|
||||
try:
|
||||
|
||||
output = s.recv(16384).strip().split('\n')
|
||||
fields = output.pop(0).split(',')
|
||||
fields[0]=fields[0].replace('# ','')
|
||||
proxies = list()
|
||||
for line in output:
|
||||
proxies.append(dict(zip(fields,line.split(','))))
|
||||
|
||||
except Exception, e:
|
||||
print str(e)
|
||||
finally:
|
||||
s.close()
|
||||
|
||||
except Exception as e:
|
||||
print "MIRRORLIST STATE UNKNOWN: " + str(e)
|
||||
sys.exit(3)
|
||||
|
||||
total=0
|
||||
downcount=0
|
||||
downlist=""
|
||||
for proxy in proxies:
|
||||
if proxy['svname'] == "FRONTEND" or proxy['svname'] == "BACKEND":
|
||||
continue
|
||||
if proxy['pxname'] == "mirror-lists":
|
||||
total+=1
|
||||
if proxy['status'] == "DOWN":
|
||||
downlist+=proxy["svname"]+" "
|
||||
downcount+=1
|
||||
|
||||
unavailability = 100 * float(downcount) / float(total)
|
||||
|
||||
if unavailability == 0:
|
||||
print "MIRRORLIST STATE OK: " + downlist
|
||||
sys.exit(0)
|
||||
|
||||
if unavailability < 50:
|
||||
print "MIRRORLIST STATE WARN: " + downlist
|
||||
sys.exit(1)
|
||||
|
||||
if unavailability >= 50:
|
||||
print "MIRRORLIST STATE CRIT: " + downlist
|
||||
sys.exit(2)
|
||||
|
||||
print "MIRRORLIST STATE UNKNOWN: " + downlist
|
||||
sys.exit(3)
|
|
@ -41,6 +41,7 @@
|
|||
copy: src="scripts/{{ item }}" dest="{{ libdir }}/nagios/plugins/{{ item }}" mode=0755 owner=nagios group=nagios
|
||||
with_items:
|
||||
- check_haproxy_conns.py
|
||||
- check_haproxy_mirrorlist.py
|
||||
- check_postfix_queue
|
||||
- check_raid.py
|
||||
- check_lock
|
||||
|
@ -184,6 +185,7 @@
|
|||
template: src={{ item }}.j2 dest=/etc/nrpe.d/{{ item }}
|
||||
with_items:
|
||||
- check_happroxy_conns.cfg
|
||||
- check_happroxy_mirrorlist.cfg
|
||||
- check_varnish_proc.cfg
|
||||
when: inventory_hostname.startswith('proxy')
|
||||
notify:
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
command[check_haproxy_mirrorlist]=/usr/lib64/nagios/plugins/check_haproxy_mirrorlist.py
|
|
@ -0,0 +1,6 @@
|
|||
define service {
|
||||
host_name proxy01
|
||||
service_description Check proxy01 for DOWN mirrorlist servers
|
||||
check_command check_by_nrpe!check_haproxy_mirrorlist
|
||||
use defaulttemplate
|
||||
}
|
|
@ -237,6 +237,7 @@ command[check_fedmsg_tweet_proc]=/usr/lib64/nagios/plugins/check_procs -c 1:1 -C
|
|||
command[check_fedmsg_masher_proc]=/usr/lib64/nagios/plugins/check_procs -c 1:1 -C 'fedmsg-hub' -u apache
|
||||
command[check_supybot_fedmsg_plugin]=/usr/lib64/nagios/plugins/check_supybot_plugin -t fedmsg
|
||||
command[check_haproxy_conns]=/usr/lib64/nagios/plugins/check_haproxy_conns.py
|
||||
command[check_haproxy_mirrorlist]=/usr/lib64/nagios/plugins/check_haproxy_mirrorlist.py
|
||||
command[check_redis_proc]=/usr/lib64/nagios/plugins/check_procs -c 1:1 -C 'redis-server' -u redis
|
||||
command[check_autocloud_proc]=/usr/lib64/nagios/plugins/check_procs -c 1:1 -C 'python' -a 'autocloud_job.py' -u root
|
||||
command[check_openvpn_link]=/usr/lib64/nagios/plugins/check_ping -H 192.168.1.41 -w 375.0,20% -c 500,60%
|
||||
|
|
59
roles/nagios/server/files/plugins/check_haproxy_mirrorlist.py
Executable file
59
roles/nagios/server/files/plugins/check_haproxy_mirrorlist.py
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import socket
|
||||
import sys
|
||||
|
||||
|
||||
try:
|
||||
|
||||
unixsocket="/var/run/haproxy-stat"
|
||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
s.connect(unixsocket)
|
||||
s.send('show stat\n')
|
||||
|
||||
try:
|
||||
|
||||
output = s.recv(16384).strip().split('\n')
|
||||
fields = output.pop(0).split(',')
|
||||
fields[0]=fields[0].replace('# ','')
|
||||
proxies = list()
|
||||
for line in output:
|
||||
proxies.append(dict(zip(fields,line.split(','))))
|
||||
|
||||
except Exception, e:
|
||||
print str(e)
|
||||
finally:
|
||||
s.close()
|
||||
|
||||
except Exception as e:
|
||||
print "MIRRORLIST STATE UNKNOWN: " + str(e)
|
||||
sys.exit(3)
|
||||
|
||||
total=0
|
||||
downcount=0
|
||||
downlist=""
|
||||
for proxy in proxies:
|
||||
if proxy['svname'] == "FRONTEND" or proxy['svname'] == "BACKEND":
|
||||
continue
|
||||
if proxy['pxname'] == "mirror-lists":
|
||||
total+=1
|
||||
if proxy['status'] == "DOWN":
|
||||
downlist+=proxy["svname"]+" "
|
||||
downcount+=1
|
||||
|
||||
unavailability = 100 * float(downcount) / float(total)
|
||||
|
||||
if unavailability == 0:
|
||||
print "MIRRORLIST STATE OK: " + downlist
|
||||
sys.exit(0)
|
||||
|
||||
if unavailability < 50:
|
||||
print "MIRRORLIST STATE WARN: " + downlist
|
||||
sys.exit(1)
|
||||
|
||||
if unavailability >= 50:
|
||||
print "MIRRORLIST STATE CRIT: " + downlist
|
||||
sys.exit(2)
|
||||
|
||||
print "MIRRORLIST STATE UNKNOWN: " + downlist
|
||||
sys.exit(3)
|
Loading…
Add table
Add a link
Reference in a new issue