Xymon Mailing List Archive search

XML from Hobbit via url

6 messages in this thread

list Andrew Martin · Sun, 25 May 2008 11:27:01 +0100 ·
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
list Galen Johnson · Sun, 25 May 2008 11:33:51 -0400 ·
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=
quoted from Andrew Martin

From: Andrew Martin [user-60870414283a@xymon.invalid]
Sent: Sunday, May 25, 2008 6:27 AM
To: user-ae9b8668bcde@xymon.invalid
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
list Galen Johnson · Sun, 25 May 2008 11:57:43 -0400 ·
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=
quoted from Galen Johnson

From: Galen Johnson [user-87f955643e3d@xymon.invalid]
Sent: Sunday, May 25, 2008 11:33 AM
To: user-ae9b8668bcde@xymon.invalid
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 [user-60870414283a@xymon.invalid]
Sent: Sunday, May 25, 2008 6:27 AM
To: user-ae9b8668bcde@xymon.invalid
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
list Galen Johnson · Sun, 25 May 2008 12:54:31 -0400 ·
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.
quoted from Galen Johnson

=G=

From: Galen Johnson [user-87f955643e3d@xymon.invalid]
Sent: Sunday, May 25, 2008 11:57 AM
To: user-ae9b8668bcde@xymon.invalid
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 [user-87f955643e3d@xymon.invalid]
Sent: Sunday, May 25, 2008 11:33 AM
To: user-ae9b8668bcde@xymon.invalid
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 [user-60870414283a@xymon.invalid]
Sent: Sunday, May 25, 2008 6:27 AM
To: user-ae9b8668bcde@xymon.invalid
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
list S Aiello · Wed, 28 May 2008 06:57:44 -0400 ·
quoted from Galen Johnson
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 [user-87f955643e3d@xymon.invalid]
Sent: Sunday, May 25, 2008 11:57 AM
To: user-ae9b8668bcde@xymon.invalid
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 [user-87f955643e3d@xymon.invalid]
Sent: Sunday, May 25, 2008 11:33 AM
To: user-ae9b8668bcde@xymon.invalid
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"
quoted from Galen Johnson

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 [user-60870414283a@xymon.invalid]
Sent: Sunday, May 25, 2008 6:27 AM
To: user-ae9b8668bcde@xymon.invalid
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

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.
list Andrew Martin · Sun, 1 Jun 2008 17:27:49 +0100 ·
Thank you for the responses to my plea for help.  I have used Galen's method
of obtaining the xml.  I changed the line running the hobbitdxboard command
to allow the host part to work on my system.  

$BBHOME/bin/bb 127.0.0.1 "hobbitdxboard host=$HOST_S"

I'll also be taking a look at s_aiello's script.  So thanks for that.  

Regards,
Andrew