~mthaddon/charms/precise/haproxy/get-upstream

« back to all changes in this revision

Viewing changes to hooks/nrpe-external-master-relation-changed

  • Committer: Tom Haddon
  • Date: 2012-10-10 14:38:47 UTC
  • Revision ID: tom.haddon@canonical.com-20121010143847-uc9ufigqv1v965ub
Add nrpe-external-master checks to haproxy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
set -eux
 
3
 
 
4
# XXX: We should also be listing the listen stanzas in the configs and then
 
5
# doing a queue depth check on all of them
 
6
 
 
7
NAGIOS_SERVICEGROUP=$(config-get nagios_context)
 
8
NAGIOS_HOSTNAME="${NAGIOS_SERVICEGROUP}-${JUJU_UNIT_NAME//\//-}"
 
9
 
 
10
cp files/nrpe-external-master/check_haproxy.sh /usr/local/lib/nagios/plugins/check_haproxy.sh
 
11
chmod 555 /usr/local/lib/nagios/plugins/check_haproxy.sh
 
12
[ ! -d /var/log/nagios ] && mkdir /var/log/nagios && chown -R nagios:nagios /var/log/nagios
 
13
 
 
14
NRPE_CHECK="# check haproxy backends
 
15
command[check_haproxy]=/usr/local/lib/nagios/plugins/check_haproxy.sh"
 
16
 
 
17
echo "$NRPE_CHECK" > /etc/nagios/nrpe.d/check_haproxy.cfg
 
18
 
 
19
NRPE_EXPORT="
 
20
define service {
 
21
    use                             active-service
 
22
    host_name                       ${NAGIOS_HOSTNAME}
 
23
    service_description             ${NAGIOS_HOSTNAME} Check HAProxy
 
24
    check_command                   check_nrpe!check_haproxy
 
25
    servicegroups                   ${NAGIOS_SERVICEGROUP}
 
26
 
 
27
}"
 
28
 
 
29
echo "$NRPE_EXPORT" > /var/lib/nagios/export/service__${NAGIOS_HOSTNAME}_check_haproxy.cfg
 
30
 
 
31
/etc/init.d/nagios-nrpe-server reload