OpenNMS implement script to get status of any service - opennms

I am trying to implement script(sh, py..) that will get mi True(Up) of False(Down) status if my installed app on nodes is up-to-date.
Before that, i tried to implement simple script found on net (https://wiki.opennms.org/wiki/SystemExecuteMonitor) just to see if script works.
OpenNMS is installed on Windows 10.
This is what i did so far:
In poller-configuration.xml
`<service name="Test" interval="300000" user-defined="false" status="on">
<parameter key="script" value="/etc/scripts/test.sh"/>
<parameter key="banner" value="OK"/>
<parameter key="retry" value="3"/>
<parameter key="timeout" value="3000"/>
<parameter key="rrd-repository" value="/opt/opennms/share/rrd/response"/>
<parameter key="ds-name" value="test"/>
</service>`
AND
`<monitor service="Test" class-name="org.opennms.netmgt.poller.monitors.SystemExecuteMonitor"/>`
In default-foreign-source.xml
`<detector name="Test" class="org.opennms.netmgt.poller.monitors.SystemExecuteMonitor">
<parameter key="script" value="/etc/scripts/test.sh"/>
<parameter key="banner" value="OK"/>
<parameter key="retry" value="3"/>
<parameter key="timeout" value="3000"/>
<parameter key="rrd-repository" value="/opt/opennms/share/rrd/response"/>
<parameter key="ds-name" value="test"/>
</detector>`
And this is what i am missing: snmpd.conf
I don't have that file in OpenNMS, so my question is where should i call that script to be executed and do i miss anything else to get this working?
Thnx!

In the meantime, i've implemented groovy script like this:
In poller-configuration.xml
<service name="MinGroovy" interval="300000" user-defined="true" status="on">
<parameter key="file-name" value="C:/OpenNMS/etc/scripts/MinimalGroovy.groovy"/>
<parameter key="bsf-engine" value="org.codehaus.groovy.bsf.GroovyEngine"/>
<parameter key="rrd-repository" value="/opt/opennms/share/rrd/response" />
</service>
AND
<monitor service="MinGroovy" class-name="org.opennms.netmgt.poller.monitors.BSFMonitor"/>
this is my groovy script:
#!/usr/bin/env groovy\
bsf_monitor.log("ERROR", "Starting MinimalGroovy.groovy", null);
filePath = "//netpath/output/temp.txt"
file = new File(filePath)
if (file.exists()){
return "OK";
}else{
return "NOK";
}
In groovy-starter.conf i added:
enter #lib for opennms
load ${opennms.home}/lib/*.jar
If i run script in groovy console, it works OK!
And this is the error i get in poller.log in OpenNMS:
ERROR [pool-9-thread-27] o.o.n.p.m.BSFMonitor: Starting MinimalGroovy.groovy
Any help?

Your service definition in the poller-configuration.xml looks suspicious to me:
<service name="MinGroovy" interval="300000" user-defined="true" status="on">
<parameter key="file-name" value="C:/OpenNMS/etc/scripts/MinimalGroovy.groovy"/>
<parameter key="bsf-engine" value="org.codehaus.groovy.bsf.GroovyEngine"/>
<parameter key="rrd-repository" value="/opt/opennms/share/rrd/response" />
</service>
The file name is located on "C:/..." whereas your rrd-repository is in "/opt/opennms". Do you have installed OpenNMS on Windows or Linux? The path to your groovy script in the service definition is from the OpenNMS process perspective.

Related

Unable to send file in out directory WSO2 ESB

I have a simple vfs based proxy service. I want to poll file "DiscardedContracts.csv" and I want to add time with file name and move it to Out directory.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="ContractsDiscardedFileReader"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="vfs">
<target>
<inSequence>
<property expression="fn:concat('DiscardedContracts', get-property('SYSTEM_DATE', 'yyMMddHHmmss'), '.csv')"
name="transport.vfs.ReplyFileName"/>
<log separator="==-------Going to move discarded contract file in out directory---------=="/>
<log level="custom" separator="==-------File--------==">
<property expression="fn:concat('DiscardedContracts', get-property('SYSTEM_DATE', 'yyMMddHHmmss'), '.csv')"
name="transport.vfs.ReplyFileName"/>
</log>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file:///opt/file/contracts/Out/"/>
</endpoint>
</send>
</inSequence>
<faultSequence>
<sequence key="DeliveriesFileProcessingFaultSequence"/>
</faultSequence>
</target>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.CreateFolder">true</parameter>
<parameter name="transport.vfs.MoveAfterFailure">vfs:file:///opt/file/contracts/Fail</parameter>
<parameter name="sequential">true</parameter>
<parameter name="transport.vfs.LockReleaseSameNode">false</parameter>
<parameter name="transport.vfs.Build">false</parameter>
<parameter name="transport.vfs.MoveAfterProcess">vfs:file:///opt/file/contracts/Out/</parameter>
<parameter name="coordination">true</parameter>
<parameter name="transport.vfs.Streaming">true</parameter>
<parameter name="transport.PollInterval">30</parameter>
<parameter name="transport.vfs.FileURI">vfs:file:///opt/file/mysql</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.AutoLockRelease">false</parameter>
<parameter name="transport.vfs.FileSortAttribute">lastmodifiedtimestamp</parameter>
<parameter name="transport.vfs.FileSortAscending">true</parameter>
<parameter name="transport.vfs.DistributedLock">false</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.csv</parameter>
<parameter name="transport.vfs.Locking">disable</parameter>
<description/>
</proxy>
But Problem is I am able to concat datetime with file name but file is not moving to Out directory properly. It create a response.xml Which contains my data. I don't know how file name and extension is changing. Need help, Thanks.
I believe this is because you have not set transport.vfs.ReplyFileName. (You have only logged it.) Its default value is response.xml.
If you take transport.vfs.ReplyFileName property out of the log mediator, it should work.
Ref: https://docs.wso2.com/display/ESB500/VFS+Transport
Update: Set scope="transport" to the property like below.
<property expression="fn:concat('DiscardedContracts', get-property('SYSTEM_DATE', 'yyMMddHHmmss'), '.csv')"
scope="transport"
name="transport.vfs.ReplyFileName"/>

WSO2 EI Registry(/_system/config/repository) values to be accessesd in proxy-service parameters

Defined a proxy-service and need to access service parameters from registry. The below syntax is not working.
<parameter name="transport.vfs.FileURI">"conf:/repository/FileLocation"</parameter>
<parameter name="transport.vfs.MoveAfterFailure">"conf:/repository/FileMoveAfterFailure"</parameter>
<parameter name="transport.vfs.FileNamePattern">"conf:/repository/FilePattern"</parameter>
<parameter name="transport.vfs.MoveAfterProcess">"conf:/repository/FileMoveAfterProcess"</parameter>
How to access registry values under /_system/config/repository to use in proxy service parameters?
As far as I know you cannot, the only option is to create a "file" inbound endpoint
<inboundEndpoint name="test_Inbound" protocol="file" sequence="test_Process" suspend="false" xmlns="http://ws.apache.org/ns/synapse">
<parameters>
<parameter name="interval">5000</parameter>
<parameter name="sequential">true</parameter>
<parameter name="coordination">true</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.LockReleaseSameNode">false</parameter>
<parameter name="transport.vfs.AutoLockRelease">false</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter key="conf:/repository/FileLocation" name="transport.vfs.FileURI"/>
<parameter key="conf:/repository/FileMoveAfterFailure" name="transport.vfs.MoveAfterFailure"/>
<parameter name="transport.vfs.DistributedLock">false</parameter>
<parameter key="conf:/repository/FilePattern" name="transport.vfs.FileNamePattern"/>
<parameter key="conf:/repository/FileMoveAfterProcess" name="transport.vfs.MoveAfterProcess"/>
<parameter name="transport.vfs.Locking">disable</parameter>
<parameter name="transport.vfs.CreateFolder">true</parameter>
<parameter name="transport.vfs.Streaming">false</parameter>
<parameter name="transport.vfs.Build">false</parameter>
</parameters>
</inboundEndpoint>
Then you have to do your processing in a sequence (test_Process), and of course adapt to your parameters (ContentType, interval, sequential or not....)
I never tried for transport.vfs.FileNamePattern but for the other I'm sure it's working as I'm using it.

Using OpenNMS to monitor SNMP, can't see MIB data

I have a MIB with oids and events. The device the MIB relates to is online. OpenNMS sees and gathers information about the interfaces on the appliance, as well as the linux variant it is running.
but it doesn't see the other oids (or I can't find/chart them).
The gui reports Polling Status (Managed) and Package (uti_p). The uti_p package is
<package name="uti_p">
<filter>IPADDR != '0.0.0.0'</filter>
<include-range begin="10.19.0.200" end="10.19.0.210" />
<rrd step="300">
<rra>RRA:AVERAGE:0.5:1:2016</rra>
<rra>RRA:AVERAGE:0.5:12:1488</rra>
<rra>RRA:AVERAGE:0.5:288:366</rra>
<rra>RRA:MAX:0.5:288:366</rra>
<rra>RRA:MIN:0.5:288:366</rra>
</rrd>
<service name="ICMP" interval="300000" user-defined="false" status="on">
<parameter key="retry" value="2" />
<parameter key="timeout" value="3000" />
<parameter key="rrd-repository" value="/var/lib/opennms/rrd/response" />
<parameter key="rrd-base-name" value="icmp" />
<parameter key="ds-name" value="icmp" />
</service>
<service name="SNMP" interval="300000" user-defined="false" status="on">
<parameter key="retry" value="2"/>
<parameter key="timeout" value="3000"/>
<parameter key="port" value="161"/>
<parameter key="oid" value=".1.3.6.1.4.1.nnnn"/>
</service>
<downtime interval="30000" begin="0" end="300000" />
<downtime interval="300000" begin="300000" end="43200000" />
<downtime interval="600000" begin="43200000" end="432000000" />
<downtime begin="432000000" delete="true" />
</package>
I have a collectd-configuration
<package name="uti_p">
<filter>IPADDR != '0.0.0.0'</filter>
<include-range begin="10.19.0.200" end="10.19.0.210"/>
<service name="SNMP" interval="30000" user-defined="false" status="on">
<parameter key="collection" value="HsmLan"/>
<parameter key="port" value="161"/>
<parameter key="retry" value="3"/>
<parameter key="timeout" value="3000"/>
<parameter key="thresholding-enabled" value="true"/>
</service>
</package>
The .../rrd/snmp/{node} directory does not show any collection of data for the various oids that I am looking for.
In response to comments:
$ snmpwalk -v 2c -c FIPS14023 10.19.0.204 iso.3.6.1.4.1.nnnn
...
iso.3.6.1.4.1.nnnn.1.1.10.0 = INTEGER: 29
iso.3.6.1.4.1.nnnn.1.1.11.0 = STRING: "29.0"
...
i.e., it returns the expected data from the MIB.
The Community set in OpenNMS is FIPS14023, and the automatic discovery process finds the node.
Node Hsm.204
Interface 10.19.0.204
Polling Status Managed
Polling Package uti_p
Monitor Class org.opennms.netmgt.poller.monitors.SnmpMonitor
Service Parameters
oid .1.3.6.1.4.1.nnnn
The Requisition name for the class of appliance is correct.
I just can find where the above String "29.0" is supposed to appear. As I understand it, the data should be collected into RRD db files, but the node Database IDs never show up in the /etc/opennms/rrdsnmp directory.
riw#riw-ubuntu-vbox:/etc/opennms/rrdsnmp$ ls
riw#riw-ubuntu-vbox:/etc/opennms/rrdsnmp$
Thank you!
I would debug the SNMP access as the following with assuming you have SNMP v2 setup:
Test access to SNMP agent from your OpenNMS server with snmpwalk -v 2c -c
OpenNMS associates SNMP community strings with the IP address. You can verify this in the Web UI in "Admin -> Configure OpenNMS -> Configure OpenNMS Community Names by IP Address" and use the "Lookup" field. It will show you which SNMP community is configured for your device and fix this if necessary.
Go to the node page and rescan the server and see if the "SNMP Attributes" fields with IP and physical interfaces get filled.
If Step 1 does not give you the full SNMP tree you have to fix your surrounding configuration, IP tables or SNMP agent configuration for views and community.
Is there a reason you are defining a different collection set "HsmLan" over the default collection for SNMP in collectd?
Be sure to include the collection service at the bottom of collectd-configuration.xml for HsmLan, ala:
<collector service="HsmLan" class-name="org.opennms.netmgt.collectd.SnmpCollector"/>
If there is, you need to define this "snmp-collection" in datacollection-config.xml and include collections via the tag which references collections named in xml files (that have OIDs, etc) in etc/datacollection/
The poller-configuration.xml you listed at the top has no bearing on data collection. It is for service polling.

Error while creating JMS configuration in wso2esb

I'm using wso2esb4.7.0 and wso2mb-2.2.0. I wish to create jms proxy service using wso2mb. For this i have configured the wso2mb as well as wso2esb like :
Wso2esb configuration :
(changes in jndi.properties)
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5673'
connectionfactory.TopicConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5673'
# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = MyQueue
changes in axis2.xml :
uncomment following code :
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
</parameter>
<parameter name="myQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
<parameter name="default" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">ConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
</transportReceiver>
also copied andes-client-*.jar and geronimo-jms_1.1_spec-*.jar from $MB_HOME/client-lib to $ESB_HOME/repository/components/lib
re-started servers.Till it's working fine.
Now wish to create a service with jms port. it is creating a service but immediately it goes to faulty service and esb logs it showing error like :
ERROR - JMSListener Unexpected error when configuring service SampleJMS for the JMS transport. It will be disabled for this transport and marked as faulty.
java.lang.NullPointerException
at org.apache.axis2.transport.jms.JMSListener.getConnectionFactory(JMSListener.java:132)
at org.apache.axis2.transport.jms.JMSEndpoint.loadConfiguration(JMSEndpoint.java:193)
at org.apache.axis2.transport.base.AbstractTransportListenerEx.startListeningForService(AbstractTransportListenerEx.java:153)
at org.apache.axis2.transport.base.AbstractTransportListener.internalStartListeningForService(AbstractTransportListener.java:213)
at org.apache.axis2.transport.base.AbstractTransportListener$2.serviceAdded(AbstractTransportListener.java:126)
at org.apache.axis2.transport.base.tracker.AxisServiceTracker.serviceAdded(AxisServiceTracker.java:212)
at org.apache.axis2.transport.base.tracker.AxisServiceTracker.start(AxisServiceTracker.java:188)
at org.apache.axis2.transport.base.AbstractTransportListener.start(AbstractTransportListener.java:178)
at org.apache.axis2.transport.base.AbstractTransportListenerEx.start(AbstractTransportListenerEx.java:83)
also while restarting it showing error like :
ERROR - BaseUtils JNDI lookup of name ConnectionFactory returned a org.wso2.andes.client.AMQQueue while a interface javax.jms.ConnectionFactory was expected
[2015-01-20 10:22:27,709] ERROR - ListenerManager Couldn't initialize the jmstransport listener
org.apache.axis2.transport.base.BaseTransportException: JNDI lookup of name ConnectionFactory returned a org.wso2.andes.client.AMQQueue while a interface javax.jms.ConnectionFactory was expected
My proxy configuration is :
<target>
<inSequence>
<property name="Action"
value="urn:placeOrder"
scope="default"
type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<drop/>
</outSequence>
Why so? is their any problem with jms configuration? Please guide me.
in jndi.properties, you've defined :
QueueConnectionFactory
TopicConnectionFactory
and in axis.xml, you use :
QueueConnectionFactory
TopicConnectionFactory
AND, in the default part, a "ConnectionFactory"
I don't use WSO2MB by I wonder if this would not be your problem

Configure WSO2 ESB JMS Transport with IBM Messagesight

I was wondering how to configure a JMS transport to work with IBM MessageSight, similar to: http://docs.wso2.org/display/ESB460/Configure+with+ActiveMQ
Right now, I have the following in axis2.xml:
<transportReceiver name="ibmMsgSightJMS" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">com.ibm.ima.jms.ImaJmsFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">tcp://192.168.154.128:1883</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
</parameter>
<parameter name="myQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">com.ibm.ima.jms.ImaJmsFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">tcp://192.168.154.128:1883</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
<parameter name="default" locked="false">
<parameter name="java.naming.factory.initial" locked="false">com.ibm.ima.jms.ImaJmsFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">tcp://192.168.154.128:1883</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
</transportReceiver>
And I have something like this in an ESB proxy service:
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="esbProcessMqttJMSPS" statistics="disable" trace="disable" transports="ibmMsgSightJMS">
<parameter name="transport.jms.ConcurrentConsumers">1</parameter>
<parameter name="transport.jms.ConnectionFactory">myTopicConnectionFactory</parameter>
<parameter name="transport.jms.DestinationType">B</parameter>
<parameter name="transport.jms.Destination">B</parameter>
</proxy>
When I startup the ESB server, I get the following error: Cannot acquire JNDI context, JMS Connection factory : TopicConnectionFactory or default destination : null for JMS CF
Any help would be greatly appreciated. Thanks!
Okay so I figured this out.
The jms config in axis2.xml should be:
<transportReceiver name="ibmMsgSightJMS" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory">
<parameter name="java.naming.factory.initial" locked="false">com.sun.jndi.fscontext.RefFSContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">file:/C:/path/to/wso2/repository/conf/jndi</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">connFactory1</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
</parameter>
<parameter name="myQueueConnectionFactory">
<parameter name="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</parameter>
<parameter name="java.naming.provider.url">file:/C:/path/to/wso2/repository/conf/jndi</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">connFactory1</parameter>
<parameter name="transport.jms.ConnectionFactoryType">queue</parameter>
</parameter>
<parameter name="default">
<parameter name="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</parameter>
<parameter name="java.naming.provider.url">file:/C:/path/to/wso2/repository/conf/jndi</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">connFactory1</parameter>
<parameter name="transport.jms.ConnectionFactoryType">topic</parameter>
</parameter>
</transportReceiver>
And I have a jndi properties file named .bindings with the following:
connFactory1/ClassName=com.ibm.ima.jms.impl.ImaConnectionFactory
connFactory1/FactoryName=com.ibm.ima.jms.impl.ImaConnectionFactory
connFactory1/RefAddr/0/Encoding=String
connFactory1/RefAddr/0/Type=Port
connFactory1/RefAddr/0/Content=16102
connFactory1/RefAddr/1/Encoding=String
connFactory1/RefAddr/1/Type=Server
connFactory1/RefAddr/1/Content=192.168.154.128
connFactory1/RefAddr/2/Encoding=String
connFactory1/RefAddr/2/Content=common
connFactory1/RefAddr/2/Type=ObjectType
RequestTopic/ClassName=com.ibm.ima.jms.impl.ImaTopic
RequestTopic/FactoryName=com.ibm.ima.jms.impl.ImaTopic
RequestTopic/RefAddr/0/Encoding=String
RequestTopic/RefAddr/0/Type=Name
RequestTopic/RefAddr/0/Content=testRequestTopic
ResponseTopic/ClassName=com.ibm.ima.jms.impl.ImaTopic
ResponseTopic/FactoryName=com.ibm.ima.jms.impl.ImaTopic
ResponseTopic/RefAddr/0/Encoding=String
ResponseTopic/RefAddr/0/Type=Name
ResponseTopic/RefAddr/0/Content=testResponseTopic
Also, don't forget to put the ImaJmsClient.jar inside components/lib.
I am still having issues where every service is creating topics/queues, and because they are not defined in .bindings, the server is puking. I have worked around this by removing the jms transport protocol on every data service and jar service.

Resources