Custom plugin running fine in command line not in Nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Custom plugin running fine in command line not in Nagios

Post by xtremax »

Hi,

I have uploaded my own plugin for doing file checking on Amazon S3. Here are the codes:

Code: Select all

#!/bin/sh

DESTINATION=`date +"$1"`
count=`s3cmd ls $DESTINATION | wc -l`

if [ $count -gt 0 ]
then
        echo "OK - File exist."
        exit 0
else
        echo "CRITICAL - File not found."
        exit 2
fi
When I tried it out on linux command line, I am able to get the correct result with state OK. However after registering the command and service. It's giving me critical state.

Is there anything that I miss out when doing my plugin?

Please advise.

Thanks,

Rudy
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Custom plugin running fine in command line not in Nagios

Post by lmiltchev »

What do you see when you try to schedule an immediate check under "Service Status Detail"? Can you show a screenshot of this page? Are you testing your check under the CCM (by clicking on the "Test Check Command" button)? Can you show us the service and command definitions?
Be sure to check out our Knowledgebase for helpful articles and solutions!
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: Custom plugin running fine in command line not in Nagios

Post by xtremax »

Hi lmiltchev,

When I try to schedule immediate check, I am getting command processed successfully message (refer to nagios-service1.png).

Yes I am testing under CCM using the "Test Check Command" button. Please see the attached screenshot for the requested definition.

Thanks,

Rudy
You do not have the required permissions to view the files attached to this post.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom plugin running fine in command line not in Nagios

Post by abrist »

What is the output from the "test check command"? We want to see if further escaping is necessary for the check in XI.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: Custom plugin running fine in command line not in Nagios

Post by xtremax »

Hi,

I have attached the outcome here.

Thanks,

Rudy
You do not have the required permissions to view the files attached to this post.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom plugin running fine in command line not in Nagios

Post by abrist »

It looks like year (%Y) and month (%m) are not getting populated with the actual date.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: Custom plugin running fine in command line not in Nagios

Post by xtremax »

Hi abrist,

I think year and month value is populated just fine. Refer to my attached screenshot. I print the value out to debug.

Thanks,

Rudy
You do not have the required permissions to view the files attached to this post.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Custom plugin running fine in command line not in Nagios

Post by slansing »

Have you tried doubling the "/'s" and where there are two making four? So for instance:

Code: Select all

s3:////extramax.data.datacenter//
This may also not work from the test check command since we are escaping inside of the command. You may have to use the service itself once you apply configuration, and schedule immediate checks to get updates.
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: Custom plugin running fine in command line not in Nagios

Post by xtremax »

Hi,

I have tried your suggestion and test using service immediate check, however it's still not working.

Refer to my attached screenshot.

Thanks,

Rudy
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Custom plugin running fine in command line not in Nagios

Post by lmiltchev »

I am not sure if this is going to help, but can try removing the extra "/"s, and wrapping everything is single or double quotes.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked