How to perform an ad-hoc data collection in the Karaf shell

Using the Karaf shell, you can perform an ad-hoc (i.e. unscheduled, on-the-fly) data collection using the opennms:collect command.

Command help:

admin@opennms()> opennms:collect --help
DESCRIPTION
        opennms:collect

        Invokes a collector against a host at a specified location.

SYNTAX
        opennms:collect [options] collectorClass host [attributes]

ARGUMENTS
        collectorClass
                Collector class
                (required)
        host
                Hostname or IP Address of the system to poll
                (required)
        attributes
                Collector specific attributes in key=value form

OPTIONS
        -l, --location
                Location
        -s, --system-id
                System ID
        -p, --persist
                Persist collection
        -n, --node
                Node ID or FS:FID
        -t, --ttl
                Time to live in milliseconds
        -x, --rra
                Round Robin Archives, defaults to the pristine content on datacollection-config.xml
                (multi-valued)
        --help
                Display this help message

In it’s simplest form, this command can be:

opennms:collect -n 1 org.opennms.netmgt.collectd.SnmpCollector 127.0.0.1

(if you have a node with id 1 with an interface 127.0.0.1 with an SNMP service defined)

Some collectors require a collection name:

opennms:collect -n 3 org.opennms.netmgt.collectd.prometheus.PrometheusCollector 127.0.1.5 collection=knode_status

Some situations may require additional collector attributes on the command line:

opennms:collect -n 3 org.opennms.netmgt.collectd.prometheus.PrometheusCollector 127.0.1.5  url='https://${requisition:url}/?match[]=%7Bname%3D~%22knode_status.%2B%22%7D' collection=knode_status header-authorization='Basic somebase64encodedgibberish'

The parameters provided on the command line are the same as accepted by the collector in collectd-configuration.xml


:woman_facepalming: You can fix me, I’m a wiki post.