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

Bug when thre is a colon in Key value #43

Closed
fitou13 opened this issue May 11, 2018 · 12 comments
Closed

Bug when thre is a colon in Key value #43

fitou13 opened this issue May 11, 2018 · 12 comments
Assignees
Labels
Milestone

Comments

@fitou13
Copy link

fitou13 commented May 11, 2018

Script return : UNKNOWN: Status UNKNOWN.HTTPError[500] when I have brackets in key value.

Sample:

{
  "com.healthCheck" : {
    "healthy" : false,
    "message" : "Exe[mystate/303]: stopped"
  },
  "com.version" : {
    "healthy" : true,
    "message" : "10.23"
  },
  "com.Connection" : {
    "healthy" : true,
    "message" : "PostgreSQL 8.3.20 "
  }
}

Any idea ?

@martialblog
Copy link
Collaborator

Hi, can you show the command you're running. I could not recreate that yet.

@martialblog
Copy link
Collaborator

Ok so it's not the Bracket, but the colon.

Due to this:

     def equals(self, key, value):
         return self.exists(key) and \
            str(self.get(key)) in value.split(':')

@martialblog martialblog added this to the v2.0 milestone Mar 3, 2020
@martialblog
Copy link
Collaborator

Unittest to recreate

   def test_equality_colon(self):
       # This should not fail
       self.check_data(RulesHelper().dash_q(['metric,foo:bar']),
                       '{"metric": "foo:bar"}', OK_CODE)

@martialblog martialblog changed the title Bug when thre is a bracket in Key value Bug when thre is a colon in Key value Mar 3, 2020
@martialblog
Copy link
Collaborator

@drewkerrigan One solution would be to add a new CLI paramter to set a custom separator for the -q option. What do you think? 🤔

@K0nne
Copy link
Contributor

K0nne commented Mar 5, 2020

Other checks like nwc health use a similar approach.

@martialblog
Copy link
Collaborator

@K0nne I'm not sure I know what you mean?

@K0nne
Copy link
Contributor

K0nne commented Mar 5, 2020

I mean special options for options.

@martialblog
Copy link
Collaborator

yeah I thinks that's the only solution here

@drewkerrigan
Copy link
Owner

Yeah I think for the short term a custom separator via cli option will be fine. For the medium-long term I think we may want to actually switch to something like json path for the majority of this functionality

@martialblog
Copy link
Collaborator

@drewkerrigan Been thinking about a jsonpath solution, I see an issue with having a library for that, since the script loses its independence. You know what I mean?

I'll write some code for a custom separator and we'll see if that works

@drewkerrigan
Copy link
Owner

@martialblog agree re: script independence. If we go the json path route we would likely want to rip out some open source functionality and put it directly in the script. That would need to be a major version change though, since the interface would definitely be broken for existing users.

@martialblog
Copy link
Collaborator

Fixed in v2.0 Branch https://github.com/drewkerrigan/nagios-http-json/tree/python3

Release will follow soon

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

No branches or pull requests

4 participants