Errors while trying to monitor Asterisk through Nagios

Today, I was trying to configure nagios to monitor an asterisk setup. I installed the nagios-plugins-check_sip plugin available for CentOS. I also had check_asterisk downloaded from here just to try out both. Now, check_asterisk and check_sip are perl scipts which can be used to monitor an asterisk setup. When run through the command line, they seem to work fine, i.e: given that asterisk or any other sip server is listening and your command is correct, you should get output similar to this:

;SIP/2.0 200 OK, 0.000585 seconds response time, cnt=1

Although, that's exactly what I got, it didn't work the same way through nagios, I was getting the following as the output from the plugin.

(Service check did not exit properly)

After enabling debug info for nagios, I found this in the logs,

HOST: remotehost, SERVICE: Asterisk, CHECK TYPE: Active, OPTIONS: 1, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: No, RETURN CODE: 3, OUTPUT: **ePN failed to compile /usr/lib64/nagios/plugins/check_sip: "Can't locate utils.pm in @INC (@INC contains: /usr/lib6464/nagios/plugins /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 1) line 31,\nBEGIN failed--compilation aborted at (eval 1) line 38." at /usr/sbin/p1.pl line 249.\n

Looked like nagios was looking for utils.pm in the wrong directory, i.e: in /usr/lib6464/nagios/plugins. Soon enough, I came across line number 29 in /usr/lib64/nagios/plugins/check_sip which goes like this,

use lib "/usr/lib6464/nagios/plugins/";

It seems that this is a bug which has been already reported here. Changing lib6464 to lib64, seemed to uncover another issue. Now the logs looked something like this.

HOST: remotehost, SERVICE: Asterisk, CHECK TYPE: Active, OPTIONS: 1, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: No, RETURN CODE: 3, OUTPUT: **ePN failed to compile /usr/lib64/nagios/plugins/check_sip: "Number found where operator expected at (eval 1) line 129, near "case 1"" at /usr/sbin/p1.pl line 249.\n

It was just that the embedded perl interpreter in nagios was not able to understand the switch case syntax. Well, this one was pretty straightforward. I just had to change line 1145 in /etc/nagios/nagios.cfg to:

enable_embedded_perl=0

and that was pretty much what was required to make it work!

Comments

  1. Awesome! That worked for me. Thanks for sharing that tidbit on your blog!

    ReplyDelete

Post a Comment

Popular posts from this blog

Configuring remote access for couchdb

Proxy Error 502 “Reason: Error reading from remote server” with Apache 2.2.3