diff --git a/CHANGELOG b/CHANGELOG index c04a1b0..4868c9c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - base: zzz_evobackup upstream release 22.03 - etc-git: manage commits with an optimized shell script instead of many slow Ansible tasks - etc-git: add versioning for /usr/share/scripts +- nagios-nrpe: add a wraper to check_dhcpd to define the number of dhcpd processes that must be running depending on the CARP state ### Fixed diff --git a/roles/nagios-nrpe/files/plugins_bsd/check_dhcpd.sh b/roles/nagios-nrpe/files/plugins_bsd/check_dhcpd.sh new file mode 100755 index 0000000..8d27627 --- /dev/null +++ b/roles/nagios-nrpe/files/plugins_bsd/check_dhcpd.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Simple wraper to define the number of dhcpd processes that must be running +# depending on the CARP active or backup state +# Can be customized if dhcpd must be running even in backup state + +dhcpd_processes_number=1 + +CARP_STATUS=$(/sbin/ifconfig carp0 | /usr/bin/grep "status" | /usr/bin/awk '{print $2}') +if [ "$CARP_STATUS" = "backup" ]; then + dhcpd_processes_number=0 +fi + +/usr/local/libexec/nagios/check_procs -c ${dhcpd_processes_number}:${dhcpd_processes_number} -C dhcpd diff --git a/roles/nagios-nrpe/tasks/main.yml b/roles/nagios-nrpe/tasks/main.yml index accaf63..3d5ec1d 100644 --- a/roles/nagios-nrpe/tasks/main.yml +++ b/roles/nagios-nrpe/tasks/main.yml @@ -60,6 +60,7 @@ - {name: 'check_pf_states', force: false} - {name: 'check_mailq.pl', force: true} - {name: 'check_dhcp_pool', force: false} + - {name: 'check_dhcpd.sh', force: false} notify: restart nrpe - name: Nagios plugins are installed - template diff --git a/roles/nagios-nrpe/templates/evolix_bsd.cfg.j2 b/roles/nagios-nrpe/templates/evolix_bsd.cfg.j2 index 1d02cab..a4c5c33 100644 --- a/roles/nagios-nrpe/templates/evolix_bsd.cfg.j2 +++ b/roles/nagios-nrpe/templates/evolix_bsd.cfg.j2 @@ -32,7 +32,6 @@ command[check_unbound]=/usr/local/libexec/nagios/check_dig -l evolix.net -H loca #command[check_smb]=/usr/local/libexec/nagios/check_tcp -H IPLOCALE -p 445 command[check_mysql]=/usr/local/libexec/nagios/check_mysql -H 127.0.0.1 -f /etc/nrpe.d/.my.cnf #command[check_vpn]=/usr/local/libexec/nagios/check_ping -H IPDISTANTE -p 1 -w 5000,100% -c 5000,100% -command[check_dhcpd]=/usr/local/libexec/nagios/check_procs -c1:1 -C dhcpd command[check_bioctl]=/usr/local/libexec/nagios/check_bioctl -d sd2 # Local checks (not packaged) @@ -49,6 +48,7 @@ command[check_ospfd_simple]=doas /usr/local/libexec/nagios/plugins/check_ospfd_s #command[check_bgpd]=doas /usr/local/libexec/nagios/plugins/check_openbgpd -u command[check_connections_state]=doas /usr/local/libexec/nagios/plugins/check_connections_state.sh command[check_packetfilter]=doas /usr/local/libexec/nagios/plugins/check_packetfilter.sh +command[check_dhcpd]=/usr/local/libexec/nagios/plugins/check_dhcpd.sh command[check_dhcp_pool]=/usr/local/libexec/nagios/plugins/check_dhcp_pool # This is an Ansible managed file !