REQUIREMENT admin.http |
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 pluginXmlBlaster 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:
|
|||||||||||||||||||||||||||||||||||
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 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
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.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.
NOTE: Configuration parameters are specified on command line (-someValue 17) or in the
xmlBlaster.properties file (someValue=17). See requirement "util.property" for details. |
|||||||||||||||||||||||||||||||||||
Todo |
|
|||||||||||||||||||||||||||||||||||
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