Total Hit Counter

Wednesday, April 10, 2013

Nagios Perl Plugin (Service Check did not exit properly) issue


Hi Friends,

In this post I will talk about solving perl plugin related issue. Sometimes we are facing issue when we are creating plugin for nagios in perl language. Sometimes what happens we executing plugin on command prompt then it is working fine and giving properl result but when we are deploying that plugin in to production nagios environment then we are getting error in output.

If we are getting following error in nagios then 
 (Service Check did not exit properly) 
Add following lines in to beginning of the your perl script.

########################################################
use strict;
require 5.6.0;
use lib qw( /usr/lib/nagios/plugins );
use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage);
############################################################################

19 comments:

Rohin said...

It worked. Thanks very much

Shankar said...

Welcome :)
you can ask any linux or scripting related issues in comment as well as can mail me.
my id is given in my blog.

Paul said...

Hi Shankar,

Can you explain why this should work?
I'm developing a plugin now, but can't get it to work.

For debugging the plugin I use capture_plugin.pl (downloaded from http://www.waggy.at/nagios/capture_plugin.htm). As long as I use capture_plugin.pl everything works just fine. If I let nagios invoke my plugin directly (without using capture_plugin.pl) I get the message (Service check did not exit properly).

Paul said...

Forgot to say, the fix you posted doesn't work for me.

Shankar said...

let me know path of plugin directory
if possible send your plugin to me

Paul said...

Hi Shankar,

My plugin is located in /etc/nagios3/plugins (on a Debian 6 package installed environment).

Shankar said...

have you adapted the it as per solution as below?
use lib qw( /usr/lib/nagios/plugins );

Paul said...

Yes, I did.

Forgot to mention that I commented the line "use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage);" since it spawned this error:
Can't locate utils.pm in @INC (@INC contains: /etc/nagios3/plugins /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /etc/nagios3/plugins/check_urls.pl line 7.

Shankar said...

Kindly send me plugin I will check and let you know. where is the problem.

Paul said...

I can't seem to find any way to message you. How would you suggest I send the plugin?

Shankar said...

sankar.h.patel@gmail.com is my email id you can find it in my blog as well

Unknown said...

Hey Shankar i need help and sent you a email.

Anonymous said...

hello i have a problem i am setting nagios memcached plugin but it gives me service check did not check properly error i dont what i have to do plzz update me asap.

Shankar said...

In that case please use the given solution and if not works for you send me plugin and your config files

Anonymous said...

my plugins are stored in /usr/lib/nagios/plugins

Anonymous said...

i sent you a email.Please help me ASAP.

Shankar said...

Replied please check your mail

Anonymous said...

Again I sent you a mail.Please check

Only i want is check_memcached nagios plugin i want to monitor memcache by nagios.Please check the mail.

Unknown said...

It worked. Thanks very much