Page 1 of 2

Plugin for Postfix Mail Queue

Posted: Wed Nov 23, 2016 9:04 am
by mindspring
Hi there,

I am trying to get a plugin meant for Nagios Core working with Nagios XI.

This is the plugin:

https://exchange.nagios.org/directory/P ... ue/details

I have installed it on both the NagiosXI server as well as the server I am monitoring. When I run the command on the server I am monitoring it gives me the correct information regarding the queue.

I configured a command as per my attachment called postfix1.png and then linked that command to a service. Please see attached service.png to see how it is configured. I have sanitized the host.

NagiosXI reports back to me saying that there is 0 messages in the queue which is incorrect because when I run the command locally it comes up with a different amount.

Can you tell if there is anything I am doing wrong that would cause the plugin to give me incorrect information?

I checked permissions and gave the script Postfix:nagios permissions so that it can execute remotely.

Thanks.

Re: Plugin for Postfix Mail Queue

Posted: Wed Nov 23, 2016 11:45 am
by rkennedy
The command that your check is calling to in the Service management is check_nrpe, not the check_command posted in your second screenshot check_nrpe_postqueue.

You may just need to update this to match, and then set your $ARG#$ variables accordingly.

Re: Plugin for Postfix Mail Queue

Posted: Thu Nov 24, 2016 1:01 am
by mindspring
Thanks, sorry I was playing around with the config a bit.

I did have it as attached pic (service2.png) in the past.

I think I know what is happening, it is running the command locally on the NagiosXI server and not running it on the actual host I am monitoring.

The documentation shows below. It says I should configure NRPE with the -w and -c and then I should use the check command

"check_command to check_nrpe!check_queue"

It looks like it integrates with check_nrpe in some way. So I think the script actually doesn't need to be on the NagiosXI server and only on the client I am monitoring and then check_nrpe gets the results somehow to run the command on the server I am monitoring?
Thanks.


*********************************************************************
This will display the current queue of Postfix.
Client configuration
====================
1) Put the script in the appropiate directory on the client. If you compile from source, it should be /usr/local/nagios/libexec.

2) Add the following to nrpe.cfg.
command[check_queue]=/usr/local/nagios/libexec/check_postfix_queue -w 20 -c 40

3) Restart nrpe.

Server configuration
====================
1) Edit an existing nrpe service and change the check_command to check_nrpe!check_queue

2) Check if the configuration is correct. /usr/bin/nagios -v /etc/nagios/nagios.cfg

3) Restart Nagios. /etc/init.d/nagios restart
*****************************************************************************************************

Re: Plugin for Postfix Mail Queue

Posted: Thu Nov 24, 2016 1:06 am
by mindspring
When I change the command as the attached picture command.png

I get the following error message:

(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_nrpe!check_queue, ...) failed. errno is 2: No such file or directory

Re: Plugin for Postfix Mail Queue

Posted: Mon Nov 28, 2016 3:09 pm
by avandemore
Let's start at the beginning and verify each step. What does check_postfix_queue -w 20 -c 40 show when run on the remote system? From that system, please attach the file /usr/local/nagios/etc/nrpe.cfg. Also from there, what is the output of

Code: Select all

# netstat -plnt |grep 5666

Re: Plugin for Postfix Mail Queue

Posted: Tue Nov 29, 2016 1:12 am
by mindspring
Hi There,

Out of the command:

Code: Select all


[root]@mail] /usr/local/nagios/libexec] $ ./check_postfix_queue -w 20 -c 40
OK: incoming queue messages: 0 active queue messages: 1 maildrop queue messages: 0 deferred queue messages: 3 bounce queue messages: 0

out of netstat:

Code: Select all


[root]@mail. ~] $ netstat -plnt |grep 5666
tcp6       0      0 :::5666                 :::*                    LISTEN      20561/xinetd 

Also /etc/xinet.d/nrpe

Code: Select all

service nrpe
{
        flags           = REUSE
        socket_type     = stream    
        port            = 5666    
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = 196.x.x.xx


I have also attached the file.

Thanks!

Re: Plugin for Postfix Mail Queue

Posted: Tue Nov 29, 2016 12:29 pm
by avandemore
You appear to have modified your prompt. When logged in as the user shown in the previous

Code: Select all

[root]@mail] /usr/local/nagios/libexec] $ ./check_postfix_queue -w 20 -c 40
What is the output of

Code: Select all

[root]@mail] /usr/local/nagios/libexec] $ id

Re: Plugin for Postfix Mail Queue

Posted: Wed Nov 30, 2016 3:37 am
by mindspring
Sorry, that was me just playing around. I had it without the sudo and it still didn't work. Here is the output with the sudo.

Code: Select all


[nagios]@mail.] $ sudo /usr/local/nagios/libexec/check_postfix_queue -w 20  -c 40
OK: incoming queue messages: 0 active queue messages: 0 maildrop queue messages: 0 deferred queue messages: 8 bounce queue messages: 0
[nagios]@mail.] $ id
uid=5686(nagios) gid=5686(nagios) groups=5686(nagios),89(postfix),5687(nagcmd)
[nagios]@mail.] $ 


Re: Plugin for Postfix Mail Queue

Posted: Wed Nov 30, 2016 3:12 pm
by avandemore
Actually that command appears to be working correctly regardless the use of sudo. Now from the Nagios server try this:

Code: Select all

# /usr/local/nagios/libexec/check_nrpe -H <Your remote IP> -c check_queue

Re: Plugin for Postfix Mail Queue

Posted: Fri Dec 02, 2016 1:24 am
by mindspring
Ok great thanks, I think it's working now.

I didn't really understand the mechanism with check_nrpe!check_queue and how it was supposed to run.

Many thanks for you help on this, much appreciated.

Code: Select all

[root]@[root]@nagiosxi] $ /usr/local/nagios/libexec/check_nrpe -H mail.xxx -c check_queue
OK: incoming queue messages: 0 active queue messages: 0 maildrop queue messages: 0 deferred queue messages: 16 bounce queue messages: 0