[hobbit] XML from Hobbit via url

s_aiello at comcast.net s_aiello at comcast.net
Wed May 28 12:57:44 CEST 2008


On Sunday 25 May 2008, Galen Johnson wrote:
> Ok...further testing shows that it's the host only that causes this.  If
> you give it a valid host but invalid test, you get an empty
> <StatusBoard></StatusBoard>.  It'd be nice if it were consistent when an
> invalid host was sent as well.
>
> =G=
>
> ________________________________________
> From: Galen Johnson [Galen.Johnson at sas.com]
> Sent: Sunday, May 25, 2008 11:57 AM
> To: hobbit at hswn.dk
> Subject: RE: [hobbit] XML from Hobbit via url
>
> Henrik,
>
> In testing this script, I noticed that if you enter a non-existant hostname
> (or test), hobbitdxboard actually returns XML as though you didn't enter
> any host (or test).  I think it would be more helpful if it sent back an
> "Invalid host/test" message (note this is 4.2 with the AiO patch applied).
>
> =G=
>
> ________________________________________
> From: Galen Johnson [Galen.Johnson at sas.com]
> Sent: Sunday, May 25, 2008 11:33 AM
> To: hobbit at hswn.dk
> Subject: RE: [hobbit] XML from Hobbit via url
>
> Hey Andrew,
>
> I hacked something together real quick for you...it requires the Hobbit
> Admin Tools available at The Shire's Addons page
> (http://www.trantor.org/theshire/doku.php/addons).  I need to look into the
> hobbitdxboard command to fully flesh it out.  I may then add it to the tool
> kit since the original maintainer seems to have disappeared (or at least
> left/graduated from his university).
>
> Just add the following script to the hobbit cgi-bin folder after adding the
> toolkit and make it executable:
>
> admintools_xmlreport.sh:
>
> #!/bin/sh
>
> echo "content-type: text/xml"
> echo ""
>
> # Change to point to your hobbit server config file
> HOBBIT_SERVER_CFG="/usr/local/hobbit/server/etc/hobbitserver.cfg"
> ADMINSCRIPTS_FUNCTIONS="/usr/local/hobbit/server/etc/adminscripts_functions
>.sh"
>
> this_usePerl="false" #if you have perl (Use it when you have Problems with
> date (e.g. on Solaris))
>
> #############################################
> #Init Script
> #############################################
> #Load Hobbit configuration
> . $HOBBIT_SERVER_CFG
> . $ADMINSCRIPTS_FUNCTIONS
>
> #Use Requestparameters from GET or Post
> if [ "$REQUEST_METHOD" = POST ]; then
>         read -n $CONTENT_LENGTH query
> else
>         query="$QUERY_STRING"
> fi
>
> this_cgiascii "$query"
> this_getQuery "$query" "host";HOST_S="$RETURN"
>
> $BBHOME/bin/bb 127.0.0.1 "hobbitdxboard $HOST_S"
>
> exit 0;
>
> =G=
>
> ________________________________________
> From: Andrew Martin [agmweb at ilovemaths.co.uk]
> Sent: Sunday, May 25, 2008 6:27 AM
> To: hobbit at hswn.dk
> Subject: [hobbit] XML from Hobbit via url
>
> Hi,
>
> This is my first post.  I have searched the archives and the web as much as
> possible but cant find anything so please point me in the right direction
> if this has been covered before.
>
> I'm trying to obtain xml from Hobbit so I can integrate the results into
> other web based projects.
>
> I can use the command
>
> bb 127.0.0.1 "hobbitdxboard host=AServer"
>
> within terminal to obtain the xml output below.  This is suitable for the
> purposes I require.
>
> <?xml version='1.0' encoding='ISO-8859-1'?>
> <StatusBoard>
>   <ServerStatus>
>     <ServerName>AServer</ServerName>
>     <Type>perf</Type>
>     <Status>green</Status>
>     <TestFlags></TestFlags>
>     <LastChange>Wed May 21 08:41:07 2008</LastChange>
>     <LogTime>Sat May 24 11:06:11 2008</LogTime>
>     <ValidTime>Sat May 24 11:36:11 2008</ValidTime>
>     <AckTime>N/A</AckTime>
>     <DisableTime>N/A</DisableTime>
>     <Sender>xxx.xxx.xxx.xxx</Sender>
>     <Cookie>N/A</Cookie>
>     <MessageSummary><![CDATA[status AServer.perf green Sat 24/05/2008
> 10:50:07]]></MessageSummary>
>   </ServerStatus>
> </StatusBoard>
>
> However, I'd like to obtain this output via a url.
>
> For example,
>
> http://<<hobbitserver>>/hobbit-cgi/bb-xmlreport.sh?HOST=AServer
>
> would return the above xml.  The host variable would of course need to be
> passed appropriately to hobbitdxboard.
>
> I'm not sure of how to correctly write my bb-xmlreport.sh file, or if im
> going about this
> the correct way or not.
>
> Any help much appreciated.
>
> Andrew
>
> To unsubscribe from the hobbit list, send an e-mail to
> hobbit-unsubscribe at hswn.dk

I have attached the script I used to provide a XML via a HTTP request. It is 
basically a frontend to the BB hobbitdxboard command, it will work with any 
of it's possible fields. It will also cache the response for a given query 
for 30 seconds (configureable). I did not want my Hobbit server spammed with 
the same XML queries. Though this does mean, whatever directory used to store 
the tmp cache files has alot of files, since there is really no automated 
cleanup of the files.

Hope this is somewhat helpful.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hobbitdxboard.cgi
Type: application/x-perl
Size: 1034 bytes
Desc: not available
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20080528/ab84db4a/attachment.bin>


More information about the Xymon mailing list