I'm trying to include a call to NRDP as part of a script we use on Windows. I don't really want to use any of the existing clients but, from what I've seen, calling it directly shouldn't be a problem.
Is there a published API Document for NRDP? No matter what POST data I send to NRDP, I always get the full html page come back (the same one you get in a web browser when browsing to http://nagios/nrdp/).
If there isn't one, can anyone tell me what I need to send to NRDP, what needs to go into the headers etc? I don't need much detail, just enough to get me going.
Thanks,
Gavin
NRDP API
Re: NRDP API
You can review our documentation on NRDP, in particular the "Testing The NRDP API" section:
http://assets.nagios.com/downloads/nagi ... erview.pdf
Also, you may want to take a look at this one:
http://old.nagios.org/developerinfo/ext ... ndlist.php
Hope this helps.
http://assets.nagios.com/downloads/nagi ... erview.pdf
Also, you may want to take a look at this one:
http://old.nagios.org/developerinfo/ext ... ndlist.php
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: NRDP API
Thanks for that. I've tried reverse engineer to the script that document references, but I must be doing something wrong as I keep getting the html page come back:
Thanks,
Gavin
What do I need to send in the HTTP request? I've tried sending the token, the cmd and the XMLDATA in the headers, which I thought was what the script did...HTTP/1.1 200 OK
Connection: close
Content-Length: 1243
Content-Type: text/html; charset=UTF-8
Date: Sat, 26 Jan 2013 21:41:05 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
<strong>Submit Nagios Command:</strong><br>
<form action="" method="get">
<input type="hidden" name="cmd" value="submitcmd">
Token: <input type="text" name="token" value="" size="15"><br>
Command: <input type="text" name="command" size="50" value="DISABLE_HOST_NOTIFICATIONS;somehost"><br>
<input type="submit" name="btnSubmit" value="Submit Command">
</form>
<hr>
<strong>Submit Check Data</strong><br>
<form action="" method="post">
<input type="hidden" name="cmd" value="submitcheck">
Token: <input type="text" name="token" value="" size="15"><br>
Check Data:<br>
<textarea cols="80" rows="15" name="XMLDATA">
<?xml version='1.0'?>
<checkresults>
<checkresult type='host'>
<hostname>somehost</hostname>
<state>0</state>
<output>Everything looks okay!|perfdata</output>
</checkresult>
<checkresult type='service'>
<hostname>somehost</hostname>
<servicename>someservice</servicename>
<state>1</state>
<output>WARNING: Danger Will Robinson!|perfdata</output>
</checkresult>
</checkresults>
</textarea><br>
<input type="submit" name="btnSubmit" value="Submit Check Data">
</form>
Thanks,
Gavin
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: NRDP API
Hmm, be sure you are posting to the full path, ie.
not
Otherwise, what you stated sounds correct
Code: Select all
http://nagiosxi/nrdp/Code: Select all
http://nagiosxi/nrdpRe: NRDP API
Thanks, I've got it sorted now. Took me a while to realise why the data wasn't appearing in Nagios... turns out the NRDP config file hadn't been updated with the new location of our /spool/ directory (which is now on a ramdisk).
If anybody is interested, PowerShell 3.0 comes with a handy little command called 'Invoke-RestMethod', which can easily call NRDP. For example:
Thanks,
Gavin
If anybody is interested, PowerShell 3.0 comes with a handy little command called 'Invoke-RestMethod', which can easily call NRDP. For example:
Code: Select all
$NagiosURL="http://nagios/nrdp/"
$token="tokenhere"
$cmd="submitcheck"
$XMLDATA= "<?xml version='1.0'?>
<checkresults>
<checkresult type='service'>
<hostname>somehost</hostname>
<servicename>someservice</servicename>
<state>1</state>
<output>WARNING: Danger Will Robinson!|perfdata</output>
</checkresult>
</checkresults>"
$PostRequest = "token=$Token&cmd=$cmd&XMLDATA=$XMLDATA"
Invoke-RestMethod -Method POST -URI $NagiosURL -Body $PostRequestGavin