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

Replicaset/Server stats are not own data, but read-preference's data #54

Open
naemono opened this issue Oct 2, 2017 · 10 comments
Open

Comments

@naemono
Copy link
Contributor

naemono commented Oct 2, 2017

Using the mongo client without :connect :direct option is returning the replSetGetStatus, and serverStatus information for whatever the read preference is set to, such as the master, and not your own information.

Example

local rs.status

> rs.status()
{
	"set" : "1b686e5c-7630-46e6-9d9e-80108b2f92e1",
	"date" : ISODate("2017-10-02T16:35:16.305Z"),
	"myState" : 2,
	"term" : NumberLong(2),
	"syncingTo" : "redacted",

output

# /opt/sensu/embedded/bin/ruby /etc/sensu/plugins/metrics-mongodb.rb --user redacted --password redacted | grep replicaset.state
80d05bce-8a92-47e7-8e1a-8d21d7032627.mongodb.metrics.replicaset.state 1 1506961990

https://gist.github.com/naemono/d9a7ef94b030d5e06b4b9dc378ba89aa

@naemono naemono mentioned this issue Oct 2, 2017
3 tasks
@majormoses
Copy link
Member

Is there any reason this might not be desired and should be behind an option to control it?

@naemono
Copy link
Contributor Author

naemono commented Feb 19, 2018

@majormoses comment in PR. If an option is preferred, let me know and I'll get that in place. thanks

@majormoses
Copy link
Member

Yes an option makes sense to me, no real cost and allow people to do things as they see fit.

@jindraj
Copy link

jindraj commented Apr 20, 2021

I would love to see this merged. Is there anything I can help with?

@majormoses
Copy link
Member

majormoses commented Apr 21, 2021

@jindraj it looks like there are two things:

  • The code is out of date and needs to be rebased, I can take a look at that
  • We need a test be it automated or manual

@majormoses
Copy link
Member

I resolved the conflict, if someone can provide a working test I am happy to accept it. The test if manual should be something along these lines:

  1. command run (with all options, redact if needed)
  2. the output of a successful run

@jindraj
Copy link

jindraj commented Apr 21, 2021

I tried to provide the test, but I'm hitting the wall.

  1. backticks around --connect long option causes error below. This needs to be in single quotes.
    bin/metrics-mongodb.rb:104:in ``': No such file or directory - --connect (Errno::ENOENT)

  2. The default seems to work fine (I can confirm I'm connected to a secondary and I'm getting for different servers in replicaset different metrics). But when I define it on command line --connect direct I'm getting this error.
    Check failed to run: undefined method `to_sym' for true:TrueClass Did you mean? to_s, ["/var/lib/gems/2.3.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:290:in `block (3 levels) in opt_parser'", "/usr/lib/ruby/2.3.0/optparse.rb:1540:in `block in parse_in_order'", "/usr/lib/ruby/2.3.0/optparse.rb:1527:in `catch'", "/usr/lib/ruby/2.3.0/optparse.rb:1527:in `parse_in_order'", "/usr/lib/ruby/2.3.0/optparse.rb:1521:in `order!'", "/usr/lib/ruby/2.3.0/optparse.rb:1613:in `permute!'", "/usr/lib/ruby/2.3.0/optparse.rb:1635:in `parse!'", "/var/lib/gems/2.3.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in `parse_options'", "/var/lib/gems/2.3.0/gems/sensu-plugin-2.0.1/lib/sensu-plugin/cli.rb:13:in `initialize'", "/var/lib/gems/2.3.0/gems/sensu-plugin-2.0.1/lib/sensu-plugin/cli.rb:57:in `new'", "/var/lib/gems/2.3.0/gems/sensu-plugin-2.0.1/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]

sadly I don't know how to resolve this.

@majormoses
Copy link
Member

@jindraj thats why I ask for tests on changes I do not know how to test myself. I will try to find some time this weekend to take a closer look at the code to see if I can see why its failing. If I can figure it out I will push to that pull request and will ask for another test.

@majormoses
Copy link
Member

@jindraj I took a look at the code and believe I have resolved the issue, can you please pull the branch again for another test and report back?

@naemono
Copy link
Contributor Author

naemono commented Apr 26, 2021

I had completely forgotten about this, and just happened to notice conversations concerning this via email. I'm nearly complete working through an integration test that will only run when specified

--tag integration

that shows this functionality using a full mongodb replicaset brought up in docker. I assume you wouldn't want to run this full test with the other test suites normally? Or would you prefer this in another manner? Any preferences?

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

3 participants