Submit nrdp with curl

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Submit nrdp with curl

Post by BanditBBS »

I'm trying to replicate this post: https://support.nagios.com/forum/viewto ... 16&t=43618

I replaced the values(token, hostname, servicename, etc) and it just loads the page, it doesn't perform the POST.

Code: Select all

curl -X POST --data-urlencode 'token=xxxx&cmd=submitcheck&XMLDATA=<?xml version='\''1.0'\''?><checkresults><checkresult type='\''service'\''><hostname>localhost</hostname><servicename>Host Automation</servicename><state>1</state><output>Warning - this is a test</output></checkresult></checkresults>' http://xxxxx.itciss.com/nrdp/
And this is the output I get instead of the expected result of a successful processing:

Code: Select all

        <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>
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Submit nrdp with curl

Post by SteveBeauchemin »

Jim,

I just compared the 2 curl statements. The only difference I see is the final tic after the nrdp/' The working example has it, your example does not.

I have not tried anything, I'm just noticing one character missing.

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Submit nrdp with curl

Post by BanditBBS »

Steve, I must be blind as I don't see anything after nrdp/
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Submit nrdp with curl

Post by SteveBeauchemin »

Damn, where did it go... :P
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Submit nrdp with curl

Post by tmcdonald »

You got some funky escaping of your single quotes. I would suggest mixing single and double instead of trying to escape. Here:

Code: Select all

curl -X POST --data-urlencode 'token=xxxx&cmd=submitcheck&XMLDATA=<?xml version='\''1.0'\''?>
when you escape the second single quote after version you are essentially breaking the --data-urlencode string. You need to escape the first one. Effectively you have this string:

Code: Select all

curl -X POST --data-urlencode 'token=xxxx&cmd=submitcheck&XMLDATA=<?xml version='
Do this:

Code: Select all

curl -X POST --data-urlencode 'token=xxxx&cmd=submitcheck&XMLDATA=<?xml version="1.0"?><checkresults><checkresult type="service"><hostname>localhost</hostname><servicename>Host Automation</servicename><state>1</state><output>Warning - this is a test</output></checkresult></checkresults>' http://xxxxx.itciss.com/nrdp/
Former Nagios employee
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Submit nrdp with curl

Post by SteveBeauchemin »

yeah, what Trevor said...

I also noticed this
<checkresult Type='\''service'\''> - working example
<checkresult type='\''service'\''> - your example

Is case sensitivity an issue?

Also, in the output I see the working example has a pipe character. Do you need to terminate with that?
<output>Warning - this is a test</output>
<output>Warning - this is a test|</output>

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Submit nrdp with curl

Post by tmcdonald »

I also generally just pass it all in as a GET request:

Code: Select all

curl -L 'http://192.168.1.100/nrdp?cmd=submitcmd&token=banditbbsismyhero&command=PROCESS_SERVICE_CHECK_RESULT;localhost;automation;1;testing'
Does it work if you format it that way?
Former Nagios employee
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Submit nrdp with curl

Post by BanditBBS »

tmcdonald wrote:I also generally just pass it all in as a GET request:

Code: Select all

curl -L 'http://192.168.1.100/nrdp?cmd=submitcmd&token=banditbbsismyhero&command=PROCESS_SERVICE_CHECK_RESULT;localhost;automation;1;testing'
Does it work if you format it that way?
That works and is much simpler! Thanks!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Submit nrdp with curl

Post by SteveBeauchemin »

Cool... he's my hero too.
Thanks for the easy answer.
Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Submit nrdp with curl

Post by tmcdonald »

Closin' it up.
Former Nagios employee
Locked