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

Added functionality to receive JSON check results #23

Merged
merged 12 commits into from
Dec 21, 2017

Conversation

box293
Copy link
Contributor

@box293 box293 commented Sep 27, 2017

This addresses issue #7.

Here is the JSON structure.

Host

{ "checkresults": [ { "checkresult": { "type": "host", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "state": "0", "output": "OK" } ] }

Service

{ "checkresults": [ { "checkresult": { "type": "service", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "servicename" : "YOUR_SERVICE", "state": "0", "output": "OK" } ] }

Submit results with &JSONDATA=

Also allows &pretty=true.

Here are some examples with output.

1 Host

curl -f -d 'token=XXXXX&cmd=submitcheck&JSONDATA={ "checkresults": [ { "checkresult": { "type": "host", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "state": "0", "output": "OK" } ] }' http://127.0.0.1/nrdp/
{ "result" : {  "status" : "0", "message" : "OK", "output" : "1 checks processed." } }

1 Host 2 Services with pretty

curl -f -d 'token=XXXXX&cmd=submitcheck&JSONDATA={ "checkresults": [ { "checkresult": { "type": "host", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "state": "0", "output": "OK" }, { "checkresult": { "type": "service", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "servicename" : "YOUR_SERVICE", "state": "0", "output": "OK" }, { "checkresult": { "type": "service", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "servicename" : "YOUR_SERVICE_TWO", "state": "2", "output": "CRITICAL" } ] }&pretty=true' http://127.0.0.1/nrdp/
{
  "result" : {
    "status" : "0",
    "message" : "OK",
    "output" : "3 checks processed."
  }
}

Incorrectly formatted JSON:

curl -f -d 'token=XXXXX&cmd=submitcheck&JSONDATA={ "checkresults": [ { "checkresult": { "type": "host", "checktype": "1" }, "hostname": "YOUR_HOSTNAME", "state": "0", "output": "OK" ] }' http://127.0.0.1/nrdp/2
{ "result" : { "status" : "-1", "message" : "BAD JSON" } }

If this is pull request is accepted I'll then proceed to update the send_nrdp clients to support JSON.

@jomann09 jomann09 added this to the 1.5.0 milestone Sep 27, 2017
@jomann09
Copy link
Contributor

From looking at this, it seems like it'll work. I will have to test it (and I am sure Bryan will too) and then we can pull this in for 1.5.0 - once this gets added, and whatever changes we make get applied, we really should be ready for a 1.5.0 release.

@box293
Copy link
Contributor Author

box293 commented Sep 27, 2017

I think perhaps we should strip out the change comments / acknowledgements and add them to a central CHANGES.txt file.

Also might be worth setting the clients and server on the same version. For example I think send_nrpd.sh is 0.6, might make more sense if it is 1.5.

@hedenface hedenface merged commit ca9638b into NagiosEnterprises:master Dec 21, 2017
@hedenface
Copy link
Contributor

Thanks @box293 !

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

Successfully merging this pull request may close these issues.

3 participants