Page 1 of 2

check_jenkins_job_extended plugin - JSON.pm query

Posted: Thu Nov 12, 2015 5:18 am
by neworderfac33
Good morning,

I have recently downloaded and installed the check_jenkins_job_extended plugin.

When I attempt to run the following command:

Code: Select all

./check_jenkins_job_extended.pl -j MyJobName -l https://MyJenkinsServer
I get the following:

Code: Select all

Can't locate JSON.pm in @INC (@INC contains: /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 ./check_jenkins_job_extended.pl line 4.
BEGIN failed--compilation aborted at ./check_jenkins_job_extended.pl line 4.
Can anyone shed any light as to where I can find JSON.pm and how i would go about installing it, please?

Thanks in advance

Pete

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Thu Nov 12, 2015 10:22 am
by hsmith

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Thu Nov 12, 2015 10:52 am
by neworderfac33
"It is indeed", he typed, with an already sinking feeling...

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Thu Nov 12, 2015 11:56 am
by rkennedy
Do you have perl-JSON installed? (case sensitive)

Code: Select all

yum install perl-JSON

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Tue Nov 17, 2015 7:46 am
by neworderfac33
Thank you for your reply and apologies for the delay in replying myself!

I have now installed JSON and set up my service definition as follows:

Code: Select all

define service{
        use                     generic-service
        host_name               MyJenkinsServer
        service_description     MyJenkinsJobName
        check_interval          1
        check_command           cjj!MyJenkinsServerName!MyJenkinsJobName!0!0!0!0
        }
and my command like this:

Code: Select all

define command{
        command_name    cjj
        command_line    $USER1$/check_jenkins_job_extended.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$
}
but the web interface is currently returning "(No output returned from plugin) "

Even though the username and password fields are optional, I'm just wondering if I should add two parameter separators to indicate that I'm not including username or password, like this:

Code: Select all

check_command           cjj!MyJenkinsServerName!MyJenkinsJobName!!!0!0!0!0
if I include my username and password like this:

Code: Select all

check_command           cjj!MyJenkinsServerName!MyUserName!MyPassword!MyJenkinsJobName!0!0!0!0
the result is the same.

Note - I'm using the jenkins server hostname, rather than its URL, because when I use (for example) "https://jenkinsbuildserver", I get:
Error: Could not find any host matching 'https://jenkinsbuildserver'

Any suggestions, good Nagios folk?

Thanks in advance.

Pete

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Tue Nov 17, 2015 10:27 am
by rkennedy
Can you post the output of the check from the CLI? Sometimes this has a bit more information that we can use for helping to troubleshoot.

Code: Select all

./check_jenkins_job_extended.pl -j MyJobName -l https://MyJenkinsServer

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Tue Nov 17, 2015 11:07 am
by neworderfac33
When I do that, it just spits out an incorrect syntax message!

Code: Select all

Usage: check_jenkins_job url [user_name password] job_name concurrent_fails_threshold build_duration_threshold_seconds last_stable_build_threshold_seconds_warn last_stable_build_threshold_seconds_crit
I tried putting the jobname in double quotes, but with the same result.
Cheers

Pete

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Tue Nov 17, 2015 11:16 am
by neworderfac33
I also tried this:

Code: Select all

/usr/local/nagios/libexec > ./check_jenkins_job_extended.pl -l https://myjenkinsserver -j MyJobName 0 0 100 100
which returned:

Code: Select all

Basic authorization user name can't contain ':' at /usr/share/perl5/HTTP/Message.pm line 658
If I remove the double quotes around the jobname, I get the usage check message again.
Pete

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Tue Nov 17, 2015 11:52 am
by neworderfac33
Another variation:

Code: Select all

/usr/local/nagios/libexec > ./check_jenkins_job_extended.pl https://myjenkinsserver "my job name with spaces" 0 0 0 0
returns:

Code: Select all

UNKNOWN - Failed retrieving status for last build via API (API status line: )
Pete

Re: check_jenkins_job_extended plugin - JSON.pm query

Posted: Tue Nov 17, 2015 5:07 pm
by rkennedy
peterooney wrote:I also tried this:

Code: Select all

/usr/local/nagios/libexec > ./check_jenkins_job_extended.pl -l https://myjenkinsserver -j MyJobName 0 0 100 100
which returned:

Code: Select all

Basic authorization user name can't contain ':' at /usr/share/perl5/HTTP/Message.pm line 658
If I remove the double quotes around the jobname, I get the usage check message again.
Pete
The reason this won't work is because it's looking for things in a specific order, rather than a flag.
The plugin supports several options, which you can pass "0" to disable that particular threshold.

Usage: check_jenkins_job_extended url jobname concurrentFailsThreshold buildDurationThresholdMilliseconds lastStableBuildThresholdInMinutesWarn lastStableBuildThresholdInMinutesCrit
I don't have a Jenkins server to test with, but perhaps something along the lines of what you did second without the https may work? It seems to be parsing your job name, and the finishing variables without error. However, I don't see anything referencing if SSL is supported or not on GitHub.

Code: Select all

./check_jenkins_job_extended.pl http://myjenkinsserver "my job name with spaces" 0 0 0 0