Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error checking serverStatus:undefined method `[]' for nil:NilClass #34

Open
nnsaln opened this issue Aug 22, 2016 · 12 comments
Open

Error checking serverStatus:undefined method `[]' for nil:NilClass #34

nnsaln opened this issue Aug 22, 2016 · 12 comments

Comments

@nnsaln
Copy link

nnsaln commented Aug 22, 2016

Error checking serverStatus:undefined method []' for nil:NilClass ["/etc/sensu/plugins/apps/metrics-mongodb.rb:173:ingather_replication_metrics'", "/etc/sensu/plugins/apps/metrics-mongodb.rb:140:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.3.0/lib/sensu-plugin/cli.rb:57:inblock in class:CLI'"]

@andrewawagner
Copy link

I ran into the same thing with the latest metrics change.

@eheydrick
Copy link
Contributor

Can you try the latest version (1.1.0) and see if it fixes this issue.

@nnsaln
Copy link
Author

nnsaln commented Oct 26, 2016

I still got this error
Check failed to run: undefined method[]' for nil:NilClass, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mongodb-1.1.0/lib/sensu-plugins-mongodb/metics.rb:120:in server_metrics'", "/etc/sensu/plugins/apps/check-mongodb-metric.rb:126:inrun'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.3.0/lib/sensu-plugin/cli.rb:57:in block in <class:CLI>'"]

@naemono
Copy link
Contributor

naemono commented Feb 6, 2017

For me this error occurred because I did not supply the proper credentials to authenticate to the mongodb database. (--user, --password options)

@eheydrick
Copy link
Contributor

@nnsaln is this still an issue for you?

@ankitjain2
Copy link

@eheydrick I am still seeing the issue with check-mongodb-metrics.rb

I am trying to run the simple
/etc/sensu/plugins/check-mongodb-metric.rb --host <myhostname.com> --ssl

Check failed to run: undefined method []' for nil:NilClass, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mongodb-1.2.0/lib/sensu-plugins-mongodb/metics.rb:120:in server_metrics'", "/etc/sensu/plugins/check-mongodb-metric.rb:126:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.2/lib/sensu-plugin/cli.rb:58:in block in <class:CLI>'"]

@majormoses
Copy link
Member

@ankitjain2 I notice you are not using embedded ruby from the path, does this bug affect you if you use sensu embedded ruby?

@majormoses majormoses added the Bug label May 4, 2017
@majormoses
Copy link
Member

Can someone confirm that specifying credentials as per: #34 (comment) solves the issue?

We should ensure that credentials are not required as last I checked mongodb does not authentication despite this being a good security posture.

@majormoses
Copy link
Member

majormoses commented May 7, 2017

Also I am noticing that the same issue effects multiple checks based on the comments here, we should keep track of which ones are affected and their resolution:

  • check-mongodb-metric.rb
  • metrics-mongodb.rb

@majormoses
Copy link
Member

@ankitjain2 @nnsaln @andrewawagner can you please confirm that #34 (comment) fixes this for you? I would like to know if its a matter of improving error handling or a bug.

@DoctorOgg
Copy link

I had the same issue, however, i added the role "clusterMonitor" to a user I created on the admin database and it workes ....

@majormoses
Copy link
Member

interesting, let's minimally document that it needs that permission for the user and can look at better error handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants