How I configured OpenNMS to monitor Twitter
Shortly after Tarus published this post, I received a Twitter DM from Esmir Alemic asking if I would mind sharing the configuration for the Twitter service monitor. I tried to post this as a comment to Tarus’ post, but my pre-formatted HTML got stripped out. So here it is. I used the Provisioning Groups feature to create the twitter.com node and Twitter service, which in OpenNMS 1.6 requires the addition of a dummy protocol plugin to the capsd-configuration.xml file (in 1.8 you’ll be able to do this using Provisiond instead):
<protocol-plugin protocol="Twitter" class-name="org.opennms.netmgt.capsd.plugins.LoopPlugin" scan="off" />
The real magic lives in the poller-configuration.xml file. Define the Twitter service in the appropriate package (beware the default-empty “strafer” package):
<service name="Twitter" interval="600000" user-defined="false" status="on">
<parameter key="retry" value="1" />
<parameter key="timeout" value="5000" />
<parameter key="page-sequence">
<page-sequence>
<page path="/twitter" port="80" successMatch="(?s).*<title>Twitter \(twitter\) on Twitter.*"
virtual-host="twitter.com"
user-agent="OpenNMS/1.6 (JVM; I; Most Any Platform; en-us)" />
</page-sequence>
</parameter>
</service>
Finally, don’t forget to tell the poller which monitor class to use for the Twitter service:
<monitor service="Twitter" class-name="org.opennms.netmgt.poller.monitors.PageSequenceMonitor" />
I used the PageSequenceMonitor rather than the more basic HttpMonitor because I plan on coming back later and making the page sequence include logging in to a Twitter account, verifying that some more sophisticated tests pass, and logging out again.