sensu-plugins / sensu-plugins-jenkins

This plugin provides native Jenkins instrumentation for monitoring and metrics collection, including: health, job status, metrics via `JQS`, and others.
http://sensu-plugins.io
MIT License
9 stars 18 forks source link

Issue with metrics-jenkins-jqs.rb #21

Open mildgrim opened 7 years ago

mildgrim commented 7 years ago

Hi,

I'm trying to extract metrics from a Jenkins installation. Now from the get go it's important to know that the Jenkins installation is on Windows.

I've tried running the check from a linux environment and from the Windows machine hosting the Jenkins server. In both instances I get the error below:

Check failed to run: undefined method `each' for 0:Fixnum, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:82:in `block (2 levels) in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:81:in `each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:81:in `block in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:80:in `each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:80:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.4/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]

Does anyone have an idea what is causing my issue?

majormoses commented 7 years ago

Can you please give us the full command you are using to run this check?

mildgrim commented 7 years ago

Below is run on the SensuServer:

My command: sudo /opt/sensu/embedded/bin/ruby /opt/sensu/embedded/bin/metrics-jenkins-jqs.rb -s bbtools_sandbox.jenkins -S bbtools

My error message:

Check failed to run: undefined method each' for 0:Fixnum, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:82:in block (2 levels) in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:81:in `each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:81:in `block in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:80:in `each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:80:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.4/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]

My response if i open bbtools:8080/jqs-monitoring/api/json in firefox (same machine as I run command)

{"buildQueue":{"numberOfJobs":0,"queueJobs":[]},"displayName":"JQS Monitoring","failHistory":{"allFailedJobsCount":5,"average24Hours":-1,"failedDisabledJobsCount":0,"failedEnabledJobsCount":5,"lastHourFailed":-1,"maximum24Hours":0,"minimum24Hours":-1,"numberOfFailedJobsLast24Hours":{"0":-1,"1":-1,"2":-1,"3":-1,"4":-1,"5":-1,"6":-1,"7":-1,"8":-1,"9":-1,"10":-1,"11":-1,"12":-1,"13":-1,"14":-1,"15":-1,"16":-1,"17":-1,"18":-1,"19":-1,"20":-1,"21":-1,"22":-1,"23":-1},"trendIconMessage":"6 more failed"},"failedBuildHistogram":"http://127.0.0.1:8080/userContent/jqs-monitoring-data/graphic1.jpg","iconFileName":"/plugin/jqs-monitoring/icons/user-desktop.png","iconsURL":"plugin/jqs-monitoring/icons/","jobsRunningTooLong":null,"numberOfAllJobs":34,"rootURL":"http://127.0.0.1:8080/","slavesHolder":{"numberOfOfflineSlaves":0,"numberOfOnlineSlaves":0,"numberOfSlaves":0,"slaves":[]},"urlName":"jqs-monitoring"}

Below is run on the bbtools sensu-client:

My command:

C:/opt/sensu/embedded/bin/ruby C:/opt/sensu/embedded/bin/metrics-jenkins-jqs.rb -s bbtools_sandbox.jenkins -S bbtools

My error message:

Check failed to run: undefined method `each' for 0:Fixnum, ["C:/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:83:in `block (2 levels) in run'", "C:/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:82:in `each'", "C:/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:82:in `block in run'", "C:/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:81:in `each'", "C:/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-jenkins-1.2.0/bin/metrics-jenkins-jqs.rb:81:in `run'", "C:/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-1.3.0/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]

My respone: (same as above)

majormoses commented 7 years ago

@mildgrim any chance I could get you to open up your server to my ipaddress so I have something to test against? I think I see the problem but it's probably gonna take some trial and error and I don't have a jenkins with jqs setup. If not I will set one up over this next weekend and see if I can work through this.