XmlBlaster Logo

REQUIREMENT

admin.http

XmlBlaster Logo


Type NEW
Priority MEDIUM
Status CLOSED
Topic XmlBlaster provides a HTML/HTTP plugin interface for your own HTML monitoring pages
Des
cription

The HTML/HTTP native plugin

XmlBlaster provides a very tiny http server implementation which is used for example to provide the CORBA IOR string. You can now add a native plugin and register it with this http server to deliver your own html pages directly from the core of a running xmlBlaster.

We provide one such native plugin which delivers a simple status page and additionally allows to deliver any configured HTML page. The HTML pages may contain any administrative command or any JMX invocation which is replaced on delivery to the browser with the real values. Needless to say, you can use Javascript and CSS in this page to add formatting, calculations and additional value.

The plugin is readily configured in xmlBlasterPlugins.xml, you can easily add your own plugins in a similar way, just take care to choose another unique id:

<plugin id='HtmlMonitorPlugin.default' className='org.xmlBlaster.contrib.htmlmonitor.HtmlMonitorPlugin'>
   <attribute id='documentRoot'>${user.home}${file.separator}html</attribute>
   <attribute id='urlPath'>/monitor</attribute>
   <attribute id='urlPath.CLASSPATH'>/status.html</attribute>
   <action do='LOAD' onStartupRunlevel='9' sequence='6' onFail='resource.configuration.pluginFailed'/>
   <action do='STOP' onShutdownRunlevel='6' sequence='5'/>
</plugin>
     

This plugins reacts on two browser requests:

urlPath or urlPath.CLASSPATH Browser URL example Comment
/monitor http://myHost:3412/monitor/XX.html As the URL example starts with the path /monitor the HTML file XX.html will be searched on the hard disk in the given documentRoot=/home/joe/html directory (assuming this users home directory).
All administrative commands in the XX.html template will be replaced by the server current values and the HTML page is finally delivered to the browser.
/status.html http://myHost:3412/status.html As the URL example contains the path /status.html the HTML file status.html will be searched in the CLASSAPTH, that is in xmlBlaster.jar in the xmlBlaster.jar:org/xmlBlaster/contrib/htmlmonitor directory. All administrative commands in the status.html template will be replaced by the server current values and the HTML page is finally delivered to the browser.
Note that xmlBlaster/config/status.html is used, it is copied into the xmlBlaster.jar file during compilation with build all.
Example
any

Observing xmlBlaster with a simple status page

XmlBlaster comes ready configured with a simple status HTML page which contains the most important informations. You can easily extend this example to your needs by editing xmlBlaster/config/status.html and and put the new file to xmlBlaster.jar:org/xmlBlaster/contrib/htmlmonitor.

Example on how to access the status page:

java org.xmlBlaster.Main -xmlBlaster/monitor/freeMemThreshold 2.0 -xmlBlaster/monitor/statusRefresh 60

Open URL
   http://localhost:3412/status.html
in your browser.
   

Note that the command line arguments -xmlBlaster/monitor/freeMemThreshold 2.0 -xmlBlaster/monitor/statusRefresh 60 are optional, they are used inside the status.html page to set the color of the free memory to red if less than 2 MBytes of memory are available and refreshes the HTML page every 60 seconds (defaults to 5 MBytes and 12 seconds).

You can change the http port on command line:

java org.xmlBlaster.Main -bootstrapPort 9090

Open URL
   http://localhost:9090/status.html
in your browser.
   

status.html screen shot

HTML - xmlBlaster status.html browser screenshot

Please see xmlBlaster/config/status.html for details about this page.

Example
any

A HTML template example using administrative commands

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv='Refresh' content='10'>
  </head>

  <body>
     <h2>Free Memory: ${?freeMem} bytes</h2>
  </body>
</html>
   

The above example refreshes every 10 seconds and delivers the servers free memory retrieved with the administrative command ${?freeMem}.

The following example reads the command line argument java org.xmlBlaster.Main -xmlBlaster/monitor/statusRefresh 20 and refreshes with this setting every 20 seconds:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script language="JavaScript" type="text/javascript">
      var key = "${sysprop/?xmlBlaster/monitor/statusRefresh}";
      var refreshInverval = (key.indexOf("$")==-1) ? key : 12;
      document.write("<meta http-equiv='Refresh' content='"+refreshInverval+"'>");
    </script>
    <title>XmlBlaster Status</title>
  </head>

  <body>
     <h2>Free Memory: ${?freeMem} bytes</h2>
  </body>
</html>
   

Please see xmlBlaster/config/status.html for a more complete example.

Example
any

A HTML template example using JMX

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script language="JavaScript" type="text/javascript">
      var key = "${sysprop/?xmlBlaster/monitor/statusRefresh}";
      var refreshInverval = (key.indexOf("$")==-1) ? key : 12;
      document.write("<meta http-equiv='Refresh' content='"+refreshInverval+"'>");
    </script>
    <title>XmlBlaster Status</title>
  </head>

  <body>
     <h2>Free Memory: ${org.xmlBlaster:nodeClass=node,node="heron"/action=getFreeMemStr} bytes</h2>
  </body>
</html>
   

Please start xmlBlaster with the cluster node id 'heron' and with activated JMX to be successful:

java -Dcom.sun.management.jmxremote org.xmlBlaster.Main -cluster.node.id heron

Note that all JMX commands need to start with org.xmlBlaster:, for more details please read the admin.jmx requirement.

Example
Java

Example how to query a topic (a watchdog using JMX markup)

This example shows a html page which looks up a topic watchdog and accesses the first message from the history queue:

<!-- watchdog.html -->
${org.xmlBlaster:nodeClass=node,node="heron",topicClass=topic,topic="watchdog"/action=peekHistoryMessages?p1+int=1}

Start xmlBlaster and a client sending heartbeats:

java -Dcom.sun.management.jmxremote org.xmlBlaster.Main -cluster.node.id heron

java javaclients.HelloWorldPublish -session.name watchdog/1 -numPublish -1 -persistent false \
     -oid watchdog -content ALIVE -lifeTime 15000 -interactive false -sleep 10000 -queue/history/maxEntries 1

You can now query xmlBlaster over http and report the result to nagios, here we use the wget command on linux:

rm watchdog.html.*; `wget http://127.0.0.2:3412/monitor/watchdog.html >/dev/null 2>&1` cat watchdog.html.1 | grep ALIVE

If you kill the publisher, after 15 seconds no "ALIVE" will be reported.

Configure

HTTP access and the HTML plugin delivered is configured in the xmlBlaster.properties configuration file or on command line.

Note: Currently there is no password protection available. As the status.html pages is read only this shouldn't cause problems if used behind a firewall.

Id (name) Type Manda tory Default value Comment
bootstrapPort int no 3412 The port where the xmlBlaster native http server listens. The port 0 switches this feature off.
bootstrapHostname String no localhost The host/IP where the xmlBlaster native http server listens. Useful for multi-homed hosts.
xmlBlaster/monitor/statusRefresh int no 12 The refresh cycle of the HTML page in seconds. This is only evaluated by the status.html page. See template xmlBlaster/config/status.html, this file is copied during build all to xmlBlaster.jar to be available over the CLASSPATH.
documentRoot String yes ${user.home}${file.separator}html This attribute is only used by the HtmlMonitorPlugin native plugin. It specifies the location on the hard disk where the HTML template files are searched. For a user joe on Windows it is typically C:\Documents And Settings\joe\html
urlPath String no /monitor Configure for which URL pathes the native plugin is called. Here, with http://localhost:3412/monitor/XX.html, a browser request comes in and the URL path start with /monitor. Therefore it is handled by the HtmlMonitorPlugin native plugin. The HTML file is searched at the hard disk location C:\Documents And Settings\joe\html\XX.html.
You can provide a list of pathes separated by a comma ','.
urlPath.CLASSPATH String no /status.html Configure for which URL pathes the native plugin is called. Here, with http://localhost:3412/status.html, a browser request comes in and the /status.html page is retrieved over the CLASSPATH from xmlBlaster.jar.
You can provide a list of pathes separated by a comma ','.

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

Todo
  1. Add password protection
See REQ admin.commands
See REQ admin.telnet
See REQ admin.jmx

This page is generated from the requirement XML file xmlBlaster/doc/requirements/admin.http.xml

Back to overview