Nagios, nrdp, pihole

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
pmduque
Posts: 2
Joined: Sun Apr 12, 2020 6:58 am

Nagios, nrdp, pihole

Post by pmduque »

Hi,

I've been searching all around but I wasn't able to find a proper answer. I have a proper Nagios setup monitoring my network (internal and external) but now I want to monitor the available disk space in my pi-hole.

As the pi-hole is a raspberry pi 1b+, it and has very limited resources. I though about using nrdp with passive monitoring in Nagios but I'm struggling.

I've configured Nagios as nrdp_server and configured check_dummy. It works.

my command configuration in Nagios machine is as follows:

Code: Select all

define command {
    command_name            check_dummy
    command_line            $USER1$/check_dummy $ARG1$ $ARG2$
}
and the service is:

Code: Select all

define service {
    use                     generic-service           ; Name of service template to use
    host_name               pi-hole
    service_description     Disk Usage
    check_command           check_dummy
}
but if I try to evoke it from the pi-hole using:

Code: Select all

php send_nrdp.php --url=http://xxxxx/nrdp/ --token=xxxx --host=pi-hole --service=check_dummy --state=2 --output="everything is nok"
I get this error
check_dummy: Could not parse arguments
.

Can you help me? what configuration should I use to be able to report if the disk usage is over 80% as warning and over 90% as critical?

thanks in advance.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Nagios, nrdp, pihole

Post by cdienger »

You should be passing the service description("Disk Usage" instead of check_dummy").
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
pmduque
Posts: 2
Joined: Sun Apr 12, 2020 6:58 am

Re: Nagios, nrdp, pihole

Post by pmduque »

cdienger wrote:You should be passing the service description("Disk Usage" instead of check_dummy").
Thank you cdienger!

I solved it and I'm posting the final solution.

In Nagios Server:
commands.cfg:

Code: Select all

define command {
    command_name            check_dummy
    command_line            $USER1$/check_dummy $ARG1$ $ARG2$
}
pi-hole.cfg:

Code: Select all

define host {
    use                     linux-server            ; Host group to use
    host_name               pi-hole                 ; Name of this host
    alias                   pihole                  ; Alias
    address                 192.168.1.x             ; IP Address
    icon_image              raspi.png
}

define service {
    use                     generic-service           ; Name of service template to use
    host_name               pi-hole
    service_description     DNS
    check_command           check_dns
}
define service {
    use                     generic-service           ; Name of service template to use
    host_name               pi-hole
    service_description     HTTP
    check_command           check_http
}
define service {
    use                     generic-service           ; Name of service template to use
    host_name               pi-hole
    service_description     DHCP
    check_command           check_dhcp
}
define service {
    use                     generic-service           ; Name of service template to use
    host_name               pi-hole
    service_description     Disk Usage
    check_command           check_dummy!2!"No results received"
    active_checks_enabled       0
    passive_checks_enabled      1
    check_freshness             1
    freshness_threshold         7200
    notification_period     24x7
    flap_detection_enabled  0
    event_handler_enabled   0
    notification_interval   1440
    notification_period     24x7
}
In raspberry-pi server (monitored machine):
crontab:

Code: Select all

0 * * * * ~/check_disk.sh /dev/root 90 95
~/check_disk.sh

Code: Select all

#!/bin/sh
df -H | grep -E $1 | awk '{ print $5 " " $1 }' | while read output;
do
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge $3 ]; then
        php /usr/local/nrdp/clients/send_nrdp.php --url=http://balrog/nrdp/ --token=C4uu6YbpJIKyrK9qxH --host=pi-hole --service="Disk Usage" --state=2 --output="Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)"
  else
        if [ $usep -ge $2 ]; then
                php /usr/local/nrdp/clients/send_nrdp.php --url=http://balrog/nrdp/ --token=C4uu6YbpJIKyrK9qxH --host=pi-hole --service="Disk Usage" --state=1 --output="Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)"
        else
                php /usr/local/nrdp/clients/send_nrdp.php --url=http://balrog/nrdp/ --token=C4uu6YbpJIKyrK9qxH --host=pi-hole --service="Disk Usage" --state=0 --output="Disk ok \"$partition ($usep%)\" on $(hostname) as on $(date)"
        fi
  fi
done
And pls let me know if you find a better solution!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Nagios, nrdp, pihole

Post by cdienger »

That looks good :) Thanks for sharing your solution!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked