Page 1 of 1
check_mailq return code of 255 is out of bounds
Posted: Mon Jul 28, 2014 3:55 am
by Heiko
Hello,
after upgrading to Nagios XI 2014R1.3 I get the following error with check_mailq:
(return code of 255 is out of bounds)
If I call /usr/local/nagios/libexec/check_mailq from cli I get the following errors:
Code: Select all
[root@nagiosxi libexec]# ./check_mailq
Bareword found where operator expected at ./check_mailq line 613, near "/usr/sbin"
(Missing operator before bin?)
Semicolon seems to be missing at ./check_mailq line 618.
syntax error at ./check_mailq line 613, near "/usr/sbin"
syntax error at ./check_mailq line 618, near "exim4 elsif"
syntax error at ./check_mailq line 623, near "nullmailer elsif"
syntax error at ./check_mailq line 670, near "}"
Execution of ./check_mailq aborted due to compilation errors.
I use CentOS 6.5, 64 Bit, manual installation,
What can I do?
Thank you in advance for helping
Re: check_mailq return code of 255 is out of bounds
Posted: Mon Jul 28, 2014 10:09 am
by sreinhardt
Could you post your version of check_mailq.pl please?
Re: check_mailq return code of 255 is out of bounds
Posted: Tue Jul 29, 2014 1:54 am
by Heiko
my version of check_mailq is 2.0.2
Re: check_mailq return code of 255 is out of bounds
Posted: Tue Jul 29, 2014 7:07 am
by belvdr
Mine exhibits the same behavior. However, I'm using check_mailq via NRPE to my mail servers and they don't have this issue.
Some potentially interesting stats:
Code: Select all
Nagios Mail Server
Version 2.0.2 1443 (nagios-plugins 1.4.13)
Lines of code 670 609
Here are the offending lines of code. I'm no perl expert, but these don't seem correct:
Code: Select all
/usr/sbin/postfix elsif (-d '/var/lib/postfix' || -d '/var/local/lib/postfix'
/usr/sbin/postfix || -e '/usr/sbin/postfix' || -e '/usr/local/sbin/postfix')
{
$mailq = 'postfix';
}
exim4 elsif (-d '/usr/lib/exim4' || -d '/usr/local/lib/exim4'
exim || -e '/usr/sbin/exim' || -e '/usr/local/sbin/exim')
{
$mailq = 'exim';
}
nullmailer elsif (-d '/usr/lib/nullmailer' || -d '/usr/local/lib/nullmailer'
I cannot find these lines in the latest code either:
https://github.com/nagios-plugins/nagio ... k_mailq.pl
Re: check_mailq return code of 255 is out of bounds
Posted: Tue Jul 29, 2014 9:13 am
by Heiko
I have the same behavior on other machines as well.
The OS on those machines is SuSe and CentOS, where I use NRDS..
Re: check_mailq return code of 255 is out of bounds
Posted: Tue Jul 29, 2014 2:05 pm
by lmiltchev
Copy/paste is a great thing but it can get you in trouble...

I suppose some text got copied over to the mailq plugin that didn't belong there... Create a backup of the plugin (just in case). Open it in a text editor and remove the following text:
/usr/sbin/postfix from line 613
/usr/sbin/postfix from line 614
exim4 from line 618
exim from line 619
nullmailer from line 623
save, and exit. Let me know if this fixed your issue.
Re: check_mailq return code of 255 is out of bounds
Posted: Wed Jul 30, 2014 1:13 am
by Heiko
Thank you for your fast reply.
I removed the lines you pointed out.
Now I get new errors:
Code: Select all
[root@nagiosxi libexec]# ./check_mailq
syntax error at ./check_mailq line 619, near "||"
syntax error at ./check_mailq line 624, near "else"
syntax error at ./check_mailq line 627, near "}"
syntax error at ./check_mailq line 665, near "}"
Execution of ./check_mailq aborted due to compilation errors.
Is there a way to download a functional check_mailq plugin, maybe from nagios website?
addition:
Sorry maybe I misinterpreted you...
If I remove the lines from 613 to 628, then the plugin works correctly.
Thank you very much for your help!

Re: check_mailq return code of 255 is out of bounds
Posted: Wed Jul 30, 2014 9:19 am
by tmcdonald
You're supposed to remove *parts* of the lines, not the *whole* lines. Removing the whole lines can still leave the plugin functional, but the lines you removed may have been needed in certain error-handling cases. The plugin link you provided seems to be a working version, so it's safe to use. Just make sure you do not accidentally copy in extra characters.