From 2af2e5ee787e47099a486d7279a30883d3bc1d95 Mon Sep 17 00:00:00 2001 From: William Hirigoyen Date: Mon, 11 Sep 2023 09:25:21 +0200 Subject: [PATCH] nagios-nrpe: set default check_load --per-cpu for BSD --- CHANGELOG.md | 1 + nagios-nrpe/files/check-local | 24 +++++++++++++++++------- nagios-nrpe/templates/evolix_bsd.cfg.j2 | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03309dc0..5de3729a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ The **patch** part changes is incremented if multiple releases happen the same m * lxc-php: Change lxc container in bookworm for php82 * evolinux-base: include files under `sshd_config.d` * postfix: disable sending mails via IPv6 +* nagios-nrpe: set default check_load --per-cpu for BSD ### Fixed diff --git a/nagios-nrpe/files/check-local b/nagios-nrpe/files/check-local index 8fcc3da8..dc46aacd 100755 --- a/nagios-nrpe/files/check-local +++ b/nagios-nrpe/files/check-local @@ -1,17 +1,27 @@ #!/usr/bin/env bash -if ! test -f /usr/lib/nagios/plugins/check_nrpe; then - echo '/usr/lib/nagios/plugins/check_nrpe is missing, please install nagios-nrpe-plugin package.' +CHECK_BIN=/usr/lib/nagios/plugins/check_nrpe + +if ! test -f "${CHECK_BIN}"; then + echo "${CHECK_BIN} is missing, please install nagios-nrpe-plugin package." exit 1 fi -if [ -r /etc/nagios/nrpe.d/evolix.cfg ]; then - command=$(grep "\[check_$1\]" /etc/nagios/nrpe.d/evolix.cfg | grep -v '^[[:blank:]]*#' | tail -n1 | cut -d'=' -f2-) - echo "Command:" - echo " $command" +for file in /etc/nagios/{nrpe.cfg,nrpe_local.cfg,nrpe.d/evolix.cfg}; do + if [ -r ${file} ]; then + found_command=$(grep "\[check_$1\]" "${file}" | grep -v '^[[:blank:]]*#' | tail -n1 | cut -d'=' -f2-) + fi + if [ -n "${found_command}" ]; then + command="${found_command}" + fi +done + +if [ -n "${command}" ]; then + echo "Found command in /etc/nagios (take care, in some cases, Nagios can play another command):" + echo " ${command}" fi echo "NRPE daemon output:" -/usr/lib/nagios/plugins/check_nrpe -H 127.0.0.1 -c "check_$1" +"${CHECK_BIN}" -H 127.0.0.1 -c "check_$1" diff --git a/nagios-nrpe/templates/evolix_bsd.cfg.j2 b/nagios-nrpe/templates/evolix_bsd.cfg.j2 index 436bf125..cdeb53a1 100644 --- a/nagios-nrpe/templates/evolix_bsd.cfg.j2 +++ b/nagios-nrpe/templates/evolix_bsd.cfg.j2 @@ -7,7 +7,7 @@ allowed_hosts={{ nagios_nrpe_allowed_hosts | join(',') }} command[check_users]=/usr/local/libexec/nagios/check_users -w 5 -c 10 -command[check_load]=/usr/local/libexec/nagios/check_load -w 15,10,5 -c 30,25,20 +command[check_load]=/usr/local/libexec/nagios/check_load --percpu -w 0.7,0.6,0.5 -c 0.9,0.8,0.7 command[check_disk1]=/usr/local/libexec/nagios/check_disk -x /lib/init/rw -x /dev -x /dev/shm -w 10% -c 3% -W 10% -K 3% -C -w 5% -c 2% -W 5% -K 2% -p /home command[check_zombie_procs]=/usr/local/libexec/nagios/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/local/libexec/nagios/check_procs -w 150 -c 200