Page 3 of 4

Re: Postfix for nagios email notification alerts problem

Posted: Mon Jan 29, 2018 7:12 am
by Siddharth Hegde
Hi tgriep and tacolover101,

I tried installing and defining https://github.com/usolved/check_usolved_disks using http://www.bauer-power.net/2012/10/how- ... m7zTK2B3eQ. Getting this error

Code: Select all

Unknown - Could't read SNMP information. Properly the host isn't configured correctly for SNMP or wrong SNMP version was given. 
My host.cfg

Code: Select all

define service{
        host_name                       prodapiservernode01
        service_description             Disks
        use                             generic-service
        check_command                   check_usolved_disks!90!95!
}
my commands.cfg

Code: Select all

define command {
    command_name    check_usolved_disks
    command_line    $USER1$/check_usolved_disks.php -H $HOSTADDRESS$ -C $_HOSTSNMPCOMMUNITY$ -V $_HOSTSNMPVERSION$ -w $ARG1$ -c $ARG2$
}
In my nrpe-remote.cfg

Code: Select all

command[check_usolved_disks]=/usr/local/nagios/libexec/check_usolved_disks -w 90 -c 95
I have this plugin in both /usr/local/nagios/libexec/ and /usr/lib/nagios/plugins/

Also

Code: Select all

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
is working for me regarding disk space.

So, I tried to use it to monitor mounted drive also

Code: Select all

#sudo vi /usr/local/nagios/etc/nrpe.cfg
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 5% -c 3% -A -I '/mnt/*'
command[check_mnt]=/usr/local/nagios/libexec/check_disk -w 5% -c 3% -p /mnt
command[check_usolved_disks]=/usr/local/nagios/libexec/check_usolved_disks -w 90 -c 95
In nagios server, my host.cfg

Code: Select all

define service{
        use                             generic-service
        host_name                      prodapiservernode01
        service_description             Disk Spaces
        check_command                   check_nrpe!check_disk
         contact_groups                  admins
        }

define service{
        use                             generic-service
        host_name                       prodapiservernode01
        service_description            Mounted Drive  Disk Space
        check_command                   check_nrpe!check_mnt
         contact_groups                  admins
        }

define service{
        use                             generic-service
        host_name                       prodapiservernode01
        service_description             Disk Space
        check_command                   check_nrpe!check_hda1!20%!10%!/
         contact_groups                  prod-api-server-monitoring
        }

define service{
        host_name                       prodapiservernode01
        service_description             Disks
        use                             generic-service
        check_command                   check_usolved_disks!90!95!
}
when I did this, I'm getting

Code: Select all

Notifications for this service are being suppressed because it was detected as having been flapping between different states (20.9% change >= 20.0% threshold). When the service state stabilizes and the flapping stops, notifications will be re-enabled.
Please help me resolve these 2 issues

Re: Postfix for nagios email notification alerts problem

Posted: Mon Jan 29, 2018 3:47 pm
by npolovenko
@Siddharth Hegde, This command as you defined it is not using NRPE:
define command {
command_name check_usolved_disks
command_line $USER1$/check_usolved_disks.php -H $HOSTADDRESS$ -C $_HOSTSNMPCOMMUNITY$ -V $_HOSTSNMPVERSION$ -w $ARG1$ -c $ARG2$
}
It connects to your Linux server via PHP SNMP and gets the disk information via SNMP. So anything you defined in the nrpe.cfg on the remote server is not being used. This command basically calls the plugin from the local directory $USER1$ = /usr/local/nagios/etc/libexec/check_usolved_disks.php, connects to the host that has snmpt and gets the disk info via SNMP, not NRPE.
Just copy the file check_usolved_disks.php into your Nagios plugin directory. For example into the path /usr/local/nagios/libexec/
On the local server, not on the remote server.
Make sure to have the PHP SNMP module installed and enabled in your php.ini.

> apt-get install php5-snmp (Ubuntu, Debian, ...) or > yum install php-snmp (RedHat, CentOS, ...)
On the local server.


Now, if you wanted to use NRPE you could.
1. You'd put a plugin to the /usr/local/nagios/libexec/ folder on the remote server and give the permissions chmod +x 777
2. On the remote server, you'd define a command in nrpe.cfg file:

Code: Select all

command[check_usolved_disks]=/usr/local/nagios/libexec/check_usolved_disks.php -w 90 -c 95
3. restart the nrpe service on the remote server to apply the newly defined command
3. On the local nagios server check to see if the everything works so far. Run this command:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H remote_server_ip -c check_usolved_disks
4. If step number 3 worked fine create a new service definition:

Code: Select all

define service{
        host_name                       prodapiservernode01
        service_description             Disks
        use                             generic-service
        check_command                   check_nrpe!check_usolved_disks
}
5. restart nagios with

Code: Select all

service nagios restart
So the whole idea of nrpe is that it runs plugins locally and then sends the results to the main nagios server. Take a look at this documentation for more clarification on the process:
https://assets.nagios.com/downloads/nag ... e/NRPE.pdf

Let me know if this makes sense, otherwise, I'll try to explain in more detail.

Re: Postfix for nagios email notification alerts problem

Posted: Tue Jan 30, 2018 3:16 am
by Siddharth Hegde
Hi @npolovenko,
. On the local nagios server check to see if the everything works so far. Run this command:

Code: Select all

CODE: SELECT ALL
/usr/local/nagios/libexec/check_nrpe -H remote_server_ip -c check_usolved_disks
I'm getting

Code: Select all

root@nagios:/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_nrpe -H host.private.ip.address -c check_usolved_disks
NRPE: Unable to read output

Re: Postfix for nagios email notification alerts problem

Posted: Tue Jan 30, 2018 4:05 pm
by scottwilkerson
verify this will run correctly on the remote machine

Code: Select all

/usr/local/nagios/libexec/check_usolved_disks.php -w 90 -c 95
You may need to adjust the config to include php and path

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -w 90 -c 95
Also, you will need to restart NRPE on the remote machine for the new command to be seen

Re: Postfix for nagios email notification alerts problem

Posted: Thu Feb 01, 2018 2:36 am
by Siddharth Hegde
Hi @scottwilkerson,

I installed php5-snmp and checked locally, I'm getting the result

Code: Select all

siddarth@clientserver:~$ ./check_usolved_disks.php -H localhost -C public -w 90 -c 95 
Disks OK // "/" (57.8%), "/sys/fs/cgroup" (57.8%), "/run" (0%), "/run/lock" (0%), "/run/shm" (0%), "/run/user" (0%), "/datadrive" (36.9%), "/mnt" (0%)
"/" - Size: 39.23 GB / Used: 22.68 GB (57.8% used)
"/sys/fs/cgroup" - Size: 0 GB / Used: 0 GB (57.8% used)
"/run" - Size: 1.37 GB / Used: 0 GB (0% used)
"/run/lock" - Size: 0 GB / Used: 0 GB (0% used)
"/run/shm" - Size: 6.85 GB / Used: 0 GB (0% used)
"/run/user" - Size: 0.1 GB / Used: 0 GB (0% used)
"/datadrive" - Size: 29.4 GB / Used: 10.86 GB (36.9% used)
"/mnt" - Size: 196.74 GB / Used: 0.06 GB (0% used)
But I'm not getting any output. I have attached screenshot of the result.

Re: Postfix for nagios email notification alerts problem

Posted: Thu Feb 01, 2018 5:47 pm
by tgriep
It looks like there is a missing option in the command an incorrect settings.
Can you post the full configuration setting for that service so we can view it?

Re: Postfix for nagios email notification alerts problem

Posted: Fri Feb 02, 2018 12:46 am
by Siddharth Hegde
Hi @tgriep,

Please find the attached configuration files

Re: Postfix for nagios email notification alerts problem

Posted: Fri Feb 02, 2018 10:06 am
by tgriep
Your command in the nrpe.cfg file

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -w 90 -c 95
Is missing some of the required options.

You heed to specify the hostaddress, the community string and the snmp version

Code: Select all

-H HOSTADDRESS -C COMMUNITY -V SNMPVERSION
So, change your command in the nrpe.cfg file to the following example, replacing the options with valid entries.

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -H HOSTADDRESS -C COMMUNITY -V SNMPVERSION -w 90 -c 95
And that should work for you.

Another option is if the Nagios server can connect to that host over the network, you can just run the command on the nagios server without using the check_nrpe command to run it on the remote server.

Re: Postfix for nagios email notification alerts problem

Posted: Sat Feb 03, 2018 6:38 am
by Siddharth Hegde
Hi @tgriep,

Code: Select all

-H HOSTADDRESS -C COMMUNITY -V SNMPVERSION
-H host.private.ip.address -C Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-135-generic x86_64) -V 5.7.2
I changed nrpe.cfg to

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -H host.private.ip.address -C Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-135-generic x86_64) -V 5.7.2 -w 90 -c 95
The output

Code: Select all

Unknown - Could't read SNMP information. Properly the host isn't configured correctly for SNMP or wrong SNMP version was given. 
I changed nrpe.cfg to

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -H host.private.ip.address -C Ubuntu 14.04.2 LTS -V 5.7.2 -w 90 -c 95
The output is still

Code: Select all

Unknown - Could't read SNMP information. Properly the host isn't configured correctly for SNMP or wrong SNMP version was given.
I changed nrpe.cfg to

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -H localhost -C public -V 5.7.2 -w 90 -c 95
The output is still same

I changed nrpe.cfg to

Code: Select all

command[check_usolved_disks]=/usr/bin/php /usr/local/nagios/libexec/check_usolved_disks.php -H localhost -C ubuntu -V 5.7.2 -w 90 -c 95
The output is still same

Code: Select all

Unknown - Could't read SNMP information. Properly the host isn't configured correctly for SNMP or wrong SNMP version was given.

Re: Postfix for nagios email notification alerts problem

Posted: Mon Feb 05, 2018 9:22 am
by tgriep
Here are what the -C and the -V options are for.
-C <snmp community>
Give the SNMP Community String
[-V <snmp version>]
Optional: SNMP version 1 or 2c are supported, if argument not given version 1 is used by default
The -C is the community string setup in SNMP.
Typically is is set to public.

The -V is the version of SNMP that is setup on the remote host.
It is either set to 1 or 2c.

Take a look at this link for what SNMP is and how to poll devices, systems using SNMP.
https://en.wikipedia.org/wiki/Simple_Ne ... t_Protocol