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^>
Add comment