Open nnsaln opened 8 years ago
I ran into the same thing with the latest metrics change.
Can you try the latest version (1.1.0) and see if it fixes this issue.
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:in
run'", "/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>'"]
For me this error occurred because I did not supply the proper credentials to authenticate to the mongodb database. (--user, --password options)
@nnsaln is this still an issue for you?
@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>'"]
@ankitjain2 I notice you are not using embedded ruby from the path, does this bug affect you if you use sensu embedded ruby?
Can someone confirm that specifying credentials as per: https://github.com/sensu-plugins/sensu-plugins-mongodb/issues/34#issuecomment-277743689 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.
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:
@ankitjain2 @nnsaln @andrewawagner can you please confirm that https://github.com/sensu-plugins/sensu-plugins-mongodb/issues/34#issuecomment-277743689 fixes this for you? I would like to know if its a matter of improving error handling or a bug.
I had the same issue, however, i added the role "clusterMonitor" to a user I created on the admin database and it workes ....
interesting, let's minimally document that it needs that permission for the user and can look at better error handling.
Error checking serverStatus:undefined method
[]' for nil:NilClass ["/etc/sensu/plugins/apps/metrics-mongodb.rb:173:in
gather_replication_metrics'", "/etc/sensu/plugins/apps/metrics-mongodb.rb:140: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'"]