What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Using PRTG placeholders in HTTP XML web server query

Votes:

0

I want to check the status of an XML REST service which has the format: https://someservice.com/Messages?MessageDate=DD-MM-YYYY

Is it possible to substitute in a place-holder parameter with the current date? Otherwise, do you have any steps for setting up a custom sensor to achieve this?

http parameter prtg sensor xml

Created on May 8, 2013 10:05:48 AM



1 Reply

Votes:

0

To answer my own question, after some googling, here is what I did:

1. Create a custom sensor and use batch file processing to create an environment variable with the correct format:

{{{call :prepare_date set datevalue=%yy%-%mm%-%dd%

REM Other stuff below...

:prepare_date for /f "tokens=1-4 delims=/-. " %%i in ('date /t') do (call :set_date %%i %%j %%k %%l) goto :eof

:set_date if "%1:0,1%" gtr "9" shift for /f "skip=1 tokens=2-4 delims=(-)" %%m in ('echo,^|date') do (set %%m=%1&set %%n=%2&set %%o=%3) goto :eof }}} 2. Using the WGET command line utility, I query the required web service. (http://www.gnu.org/software/wget/)

This is piped into the XmlStarlet command line utility which can return an element of an XML document based on a required Xpath query. (http://xmlstar.sourceforge.net/)

Thes utilities need to be available on he PATH to the custom sensor command file wget -q -O - "$@" "https://someservice.com/Messages?MessageDate>=%datevalue%" --no-check-certificate 2>nul | xml sel -t -v "//SomeData/@datavalue"

3. This command line is wrapped in the PRTG xml wrapper:

echo ^<?xml version="1.0" encoding="Windows-1252" ?^>
echo ^<prtg^>
echo    ^<result^>
echo        ^<channel^>SomeData^</channel^>
echo        ^<value^>
wget call here....
echo    ^</result^>
echo    ^<text^>OK^</text^>
echo ^</prtg^>

Created on May 13, 2013 9:44:11 AM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.