Postfix for nagios email notification alerts problem

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.
Siddharth Hegde
Posts: 70
Joined: Mon Aug 07, 2017 4:19 am

Re: Postfix for nagios email notification alerts problem

Post 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
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Postfix for nagios email notification alerts problem

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Siddharth Hegde
Posts: 70
Joined: Mon Aug 07, 2017 4:19 am

Re: Postfix for nagios email notification alerts problem

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Postfix for nagios email notification alerts problem

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Siddharth Hegde
Posts: 70
Joined: Mon Aug 07, 2017 4:19 am

Re: Postfix for nagios email notification alerts problem

Post 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.
Attachments
Screen Shot 2018-02-01 at 3.10.42 pm.png
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Postfix for nagios email notification alerts problem

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Siddharth Hegde
Posts: 70
Joined: Mon Aug 07, 2017 4:19 am

Re: Postfix for nagios email notification alerts problem

Post by Siddharth Hegde »

Hi @tgriep,

Please find the attached configuration files
Attachments
nrpe.cfg
/usr/local/nagios/etc/
(12.36 KiB) Downloaded 482 times
nagioshost.cfg
/usr/local/nagios/etc/servers/
(2.08 KiB) Downloaded 519 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Postfix for nagios email notification alerts problem

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Siddharth Hegde
Posts: 70
Joined: Mon Aug 07, 2017 4:19 am

Re: Postfix for nagios email notification alerts problem

Post 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.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Postfix for nagios email notification alerts problem

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked