From OpenNMS
Contents |
Author & Credits
- Author: Adam Balogh <hapan _at_ mindwipe.org>
- Credits for helping me with this: Jeff 'JeffG' Gehlbach, Johan 'Joed' Edström
Finding the necessary information
First you need to know which port the service you want to map up has. I will demonstrate this on 3306/MySQL.
We will do this by snmpwalking the host.
hapan@kuroi:~$ snmpwalk -v2c -c community host tcpConnTable | grep 3306 TCP-MIB::tcpConnState.127.0.0.1.3306.0.0.0.0.0 = INTEGER: listen(2) TCP-MIB::tcpConnLocalAddress.127.0.0.1.3306.0.0.0.0.0 = IpAddress: 127.0.0.1 TCP-MIB::tcpConnLocalPort.127.0.0.1.3306.0.0.0.0.0 = INTEGER: 3306 TCP-MIB::tcpConnRemAddress.127.0.0.1.3306.0.0.0.0.0 = IpAddress: 0.0.0.0 TCP-MIB::tcpConnRemPort.127.0.0.1.3306.0.0.0.0.0 = INTEGER: 0
Ok, tcpConnState seems logical. We can also see that it listenes to 127.0.0.1.
hapan@kuroi:~$ snmpwalk -On -v2c -c community host tcpConnTable | grep 3306 | head -1 .1.3.6.1.2.1.6.13.1.1.127.0.0.1.3306.0.0.0.0.0 = INTEGER: listen(2)
Now we have the OID and the integer value for listen.
OID = .1.3.6.1.2.1.6.13.1.1.127.0.0.1.3306.0.0.0.0.0 value = 2
Note!
- MySQL doesnt always listen to a internal socket. Make sure you dont have skip-networking in your my.cnf AND make sure bind-address is 127.0.0.1.
- The OID's may variate depending on system / configuration. So please dont copy & paste the OID.
Adding the service to capabilities.
Now we need to add our custom protocol to capabilities so it will be scanned/noticed.
File to edit: capsd-configuration.xml
... <ns37:protocol-plugin protocol="MySQLlocal" class-name="org.opennms.netmgt.capsd.plugins.SnmpPlugin" scan="on" user-defined="false"> <ns37:property key="vbname" value=".1.3.6.1.2.1.6.13.1.1.127.0.0.1.3306.0.0.0.0.0"/> <ns37:property key="vbvalue" value="2"/> <ns37:property key="timeout" value="2000"/> <ns37:property key="retry" value="2"/> </ns37:protocol-plugin> ...
- protocol-plugin
- protocol = our custom service protocol. MySQLlocal in this case.
- class-name = define which plugin OpenNMS should use, we want to use Snmp so we use org.opennms.netmgt.capsd.plugins.SnmpPlugin
- property
- vbname = varbind name, OID goes here.
- vbvalue = varbind value, integer which marks the port as listening here.
Adding the service to poller configuration
Now we need to map our service in our poller configuration.
File to edit: poller-configuration.xml
...
<ns36:service name="MySQLlocal" interval="300000" user-defined="false" status="on">
<ns36:parameter key="retry" value="2"/>
<ns36:parameter key="timeout" value="3000"/>
<ns36:parameter key="operator" value="="/>
<ns36:parameter key="operand" value="2"/>
<ns36:parameter key="oid" value=".1.3.6.1.2.1.6.13.1.1.127.0.0.1.3306.0.0.0.0.0"/>
</ns36:service>
...
- service-tag
- name = the name of our service, MySQLlocal is what i choose.
- parameter-tags
- operator = which operator we would like to use, we want our OID to be EQUAL so we use =.
- operand = the value we want to match, in our case 2.
Note! The operand and operator parameters got added in OpenNMS 1.2.8.
We also need to add our service to monitor.
... <ns36:monitor service="MySQLlocal" class-name="org.opennms.netmgt.poller.monitors.SnmpMonitor"/> ...
- monitor
- service = same as name in example above. MySQLlocal
- class-name = we need to specifify that we want to use snmp to monitor this service. org.opennms.netmgt.poller.monitors.SnmpMonitor
Updating categories
Now we are almost done. We want to add our new service to a matching category.
File to edit: categories.xml
...
<category>
<label><![CDATA[Database Servers]]></label>
<comment>This category includes all managed interfaces which are currently running PostgreSQL or MySQL
database servers.</comment>
<normal>99</normal>
<warning>97</warning>
<service>Postgres</service>
<service>MySQL</service>
<service>MySQLlocal</service>
<rule><![CDATA[isPostgres | isMySQL | isMySQLlocal]]></rule>
</category>
...
We need to add our new service to two places. First a new service which can be seen in
the example above as <service>MySQLlocal</service>.
We also need to extend our rule for the category to:
<rule><![CDATA[isPostgres | isMySQL | isMySQLlocal]]></rule>
The rule above will make sure it finds our custom service.
Restart & Rescan
After all the above steps has been completed we need to restart Tomcat and OpenNMS.
Then view your host and rescan it. Rescan will scan for the new capabilities that we just
added.






