JSON Parsing and saving
-
vinothsethuram
- Posts: 147
- Joined: Thu Nov 07, 2013 11:44 am
JSON Parsing and saving
Hi,
My http url is giving JSON response. I would like to parse and save the value.Is Nagios Core providing the feature?
Thanks
Vinoth
My http url is giving JSON response. I would like to parse and save the value.Is Nagios Core providing the feature?
Thanks
Vinoth
Re: JSON Parsing and saving
You would need to find (or create) a plugin to do this. This might be a good starting point:
http://exchange.nagios.org/directory/Pl ... ON/details
http://exchange.nagios.org/directory/Pl ... ON/details
Former Nagios employee
-
vinothsethuram
- Posts: 147
- Joined: Thu Nov 07, 2013 11:44 am
Re: JSON Parsing and saving
I have script to parse and save the JSON. Now I'm getting JSON response from check_http plugin. How to parse the JSON response which is retrieved from check_http plugin output.
Re: JSON Parsing and saving
You could use the string match ( -s, --string=STRING ) or regex ( -r, --regex, --ereg=STRING ) to parse the output to a state.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
-
vinothsethuram
- Posts: 147
- Joined: Thu Nov 07, 2013 11:44 am
Re: JSON Parsing and saving
Can't understand .
-s, --string=STRING
String to expect in the content
-R, --eregi=STRING
Search page for case-insensitive regex STRING
How this parameter will help to retrieve and save the value from JSON response
-s, --string=STRING
String to expect in the content
-R, --eregi=STRING
Search page for case-insensitive regex STRING
How this parameter will help to retrieve and save the value from JSON response
Re: JSON Parsing and saving
If you want to retrieve and save the json, just use wget or curl. What is the usage case for this?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
-
vinothsethuram
- Posts: 147
- Joined: Thu Nov 07, 2013 11:44 am
Re: JSON Parsing and saving
Here is my scenario.
I'm testing my APIs using check_http plugin. First API will have token in JSON response. I need to parse the token and save it. Then I need to use this token as a parameter for all other APIs. Check_http plugin's verbose command his giving JSON response.
Thanks
Vinoth
I'm testing my APIs using check_http plugin. First API will have token in JSON response. I need to parse the token and save it. Then I need to use this token as a parameter for all other APIs. Check_http plugin's verbose command his giving JSON response.
Thanks
Vinoth
Re: JSON Parsing and saving
This request will require a custom script. You will need to fetch the json, parse it, and then save it to a file. Another script would then wrap check_http to use the new parameter from the previous script. This is out of scope for our support, so my suggestion would be to create the scripts, do some troubleshooting, and then post here when you need help.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
-
vinothsethuram
- Posts: 147
- Joined: Thu Nov 07, 2013 11:44 am
Re: JSON Parsing and saving
Hi,
I'm using check_http plugin to check my APIs. Verbose command is giving the response. I want to save the response. Is there any possibility yo save the response?
I'm using check_http plugin to check my APIs. Verbose command is giving the response. I want to save the response. Is there any possibility yo save the response?
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: JSON Parsing and saving
Sure, write a wrapper script that uses the check_http command, and redirects the output to a flat file. This is not something that core will do on its own, or the check_http plugin, it will need to be custom created.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.