2. Minion development

2.1. Introduction

This guide is intended to help developers get started with writing Minion related features.
It is not intented to be an exhaustive overview of the Minion architecture or feature set.

2.2. Container

This section details the customizations we make to the standard Karaf distribution for the Minion container.

2.2.1. Clean Start

We clear the cache on every start by setting karaf.clean.cache = true in order to ensure that only the features listed in the featuresBoot (or installed by the karaf-extender) are installed.

2.2.2. Karaf Extender

The Karaf Extender was developed to make it easier to manage and extend the container using existing packaging tools.
It allows packages to register Maven Repositories, Karaf Feature Repositories and Karaf Features to Boot by overlaying additional files, avoiding modifying any of the existing files.

Here’s an overview, used for reference, of the relevant directories that are (currently) present on a default install of the opennms-minion package:

Find all of the folders listed under $karaf.home/repositories that do not start with a '.' and sort these by name.

Gather the list of Karaf Feature Repository URIs from the features.uris files in the repositories.

Gather the list of Karaf Feature Names from the features.boot files in the repositories.

Gather the list of Karaf Feature Names form the files under $karaf.etc/featuresBoot.d that do not start with a '.' and sort these by name.

Register the Maven Repositories by updating the org.ops4j.pax.url.mvn.repositories key for the PID org.ops4j.pax.url.mvn.

Wait up to 30 seconds until all of the Karaf Feature URIs are resolvable (the Maven Repositiries may take a few moments to update after updating the configuration.)

Install the Karaf Feature Repository URIs.

Install the Karaf Features.

Features listed in the features.boot files of the Maven Repositiries will take precedence over those listed in featuresBoot.d.

Any existing repository registered in org.ops4j.pax.url.mvn.repositories will be overwritten.

2.3. Packaging

This sections describes packages for Minion features and helps developers add new features to these packages.

We currently provide two different feature packages for Minion:

openns-minion-features-core

Core utilities and services required for connectivity with the OpenNMS controller

openns-minion-features-default

Minion-specific service extensions

Every package bundles all of the Karaf Feature Files and Maven Dependencies into a Maven Repository with additional meta-data used by the KarafExtender.

2.3.1. Adding a new feature to the default feature package

Add the feature definition to container/features/src/main/resources/features-minion.xml.

Add the feature name in the features list configuration for the features-maven-plugin in features/minion/repository/pom.xml.

Optionally add the feature name to features/minion/repository/src/main/resources/features.boot if the feature should be automatically installed when the container is started.

2.4. Guidelines

This sections describes a series of guidelines and best practices when developing Minion modules:

2.4.1. Security

Don’t store any credentials on disk, use the SecureCredentialVault instead.

2.5. Testing

This sections describes how developers can test features on the Minion container.

2.5.1. Local Testing

You can compile, assemble, and spawn an interactive shell on the Minion container using:

Assemble and run the container in place

cd features/minion && ./runInPlace.sh

2.5.2. System Tests

The runtime environment of the Minion container and features differs greatly from those provided by the unit and integration tests.
For this reason, it is important to perform automated end-to-end testing of the features.

The system tests provide a framework which allows developers to instantiate a complete Docker-based Minion system using a single JUnit rule.

3. Topology

3.1. Info Panel Items

This section is under development.
All provided examples or code snippet may not fully work.
However they are conceptionally correct and should point in the right direction.

Each element in the Info Panel is defined by an InfoPanelItem object.

All available InfoPanelItem objects are sorted by the order.
This allows to arrange the items in a custom order.
After the elements are ordered, they are put below the SearchBox and the Vertices in Focus list.

3.1.1. Programmatic

It is possible to add items to the Info Panel in the Topology UI by simply implementing the interface InfoPanelItemProvider and expose its implementation via OSGi.

The default implementation of InfoPanelItem.
You may use InfoPanelItem instead if the default implementation is not sufficient.

2

The title of the InfoPanelItem.
It is shown above the component.

3

The order.

4

A Vaadin component which actually describes the custom component.

In order to show information based on a selected vertex or edge, one must inherit the classes EdgeInfoPanelItemProvider or VertexInfoPanelItemProvider.
The following example shows a custom EdgeInfoPanelItemProvider.

Is invoked if one and only one edge is selected.
It determines if the current edge should provide the InfoPanelItem created by createInfoPanelItem.

2

Is invoked if one and only one edge is selected.
It creates the InfoPanelItem to show for the selected edge.

Implementing the provided interfaces/classes, is not enough to have it show up.
It must also be exposed via a blueprint.xml to the OSGi service registry.
The following blueprint.xml snippet describes how to expose any custom InfoPanelItemProvider implementation to the OSGi service registry and have the Topology UI pick it up.

3.1.2. Scriptable

By simply dropping JinJava templates (with file extension .html) to $OPENNMS_HOME/etc/infopanel a more scriptable approach is available.
For more information on JinJava refer to https://github.com/HubSpot/jinjava.

The following example describes a very simple JinJava template which is always visible.

3.2. GraphML

GraphML is a comprehensive and easy-to-use file format for graphs.
It consists of a language core to describe the structural properties of a graph and a flexible extension mechanism to add application-specific data.
[…​]
Unlike many other file formats for graphs, GraphML does not use a custom syntax.
Instead, it is based on XML and hence ideally suited as a common denominator for all kinds of services generating, archiving, or processing graphs.

— http://graphml.graphdrawing.org

OpenNMS Horizon does not support the full feature set of GraphML.
The following features are not supported: Nested graphs, Hyperedges, Ports and Extensions.
For more information about GraphML refer to the Official Documentation.

A basic graph definition using GraphML usually consists of the following GraphML elements:

Graph element to describe the graph

Key elements to define custom properties, each element in the GraphML document can define as data elements

Node and Edge elements

Data elements to define custom properties, which OpenNMS Horizon will then interpret.

The topology-name is a unique identifier for the Topology.
If a label property is defined for the Graphml element this is used to be displayed in the Topology UI, otherwise the topology-name defined here is used as a fallback.

To delete an already existing Topology a HTTP DELETE request must be send:

There is no PUT method available.
In order to update an existing GraphML Topology one must first delete and afterwards re-create it.

Even if the HTTP Request was successful, it does not mean, that the Topology is actually loaded properly.
The HTTP Request states that the Graph was successfully received, persisted and is in a valid GraphML format.
However, the underlying GraphMLTopologyProvider may perform additional checks or encounters problems while parsing the file.
If the Topology does not show up, the karaf.log should be checked for any clues what went wrong.
In addition it may take a while before the Topology is actually selectable from the Topology UI.

3.2.2. Supported Attributes

A various set of GraphML attributes are supported and interpreted by OpenNMS Horizon while reading the GraphML file.
The following table explains the supported attributes and for which GraphML elements they may be used.

The type of the GraphML-Attribute can be either boolean, int, long, float, double, or string.
These types are defined like the corresponding types in the Java™-Programming language.

Allows referencing the Vertex to an OpenNMS node identified by foreign source and foreign id.
Can only be used in combination with foreignID. Please note that this attribute will not be
used when the attribute nodeID is set.

foreignID

no

Node

string

-

Allows referencing the Vertex to an OpenNMS node identified by foreign source and foreign id.
Can only be used in combination with foreignSource. Please note that this attribute will not be
used when the attribute nodeID is set.

tooltipText

no

Node, Edge

string

Defines a custom tooltip. If not defined, the id attribute is used instead.

level

no

Node

int

0

Sets the level of the Vertex which is used by certain layout algorithms i.e. Hierarchical Layout and Grid Layout.

edge-path-offset

no

Graph, Node

int

20

Controls the spacing between the paths drawn for the edges when there are multiple edges connecting two vertices.

breadcrumb-strategy

no

GraphML

string

NONE

Defines the breadcrumb strategy to use. See Breadcrumbs for more information.

3.2.3. Focus Strategies

A Focus Strategy defines which Vertices should be added to focus when selecting the Topology.
The following strategies are available:

EMPTY No Vertex is add to focus.

ALL All Vertices are add to focus.

FIRST The first Vertex is add to focus.

SPECIFIC Only Vertices which id match the graph’s property focus-ids are added to focus.

3.2.4. Icons

With the GraphMLTopoloygProvider it is not possible to change the icon from the Topology UI.
Instead if a custom icon should be used, each node must contain a iconKey property referencing an SVG element.

3.2.5. Vertex Status Provider

The Vertex Status Provider calculates the status of the Vertex.
There are multiple implementations available which can be configured for each graph: default, script and propagate.
If none is specified, there is no status provided at all.

Default Vertex Status Provider

The default status provider calculates the status based on the worst unacknowledged alarm associated with the Vertex’s node.
In order to have a status calculated a (OpenNMS Horizon) node must be associated with the Vertex.
This can be achieved by setting the GraphML attribute nodeID on the GraphML node accordingly.

Script Vertex Status Provider

The script status provider uses scripts similar to the Edge Status Provider.
Just place Groovy scripts (with file extension .groovy) in the directory $OPENNMS_HOME/etc/graphml-vertex-status.
All of the scripts will be evaluated and the most severe status will be used for the vertex in the topology’s visualization.

If the script shouldn’t contribute any status to a vertex just return null.

Propagate Vertex Status Provider

The propagate status provider follows all links from a node to its connected nodes.
It uses the status of these nodes to calculate the status by determining the worst one.

3.2.6. Edge Status Provider

It is also possible to compute a status for each edge in a given graph.
Just place Groovy scripts (with file extension .groovy) in the directory $OPENNMS_HOME/etc/graphml-edge-status.
All of the scripts will be evaluated and the most severe status will be used for the edge in the topology’s visualization.

The following simple Groovy script example will apply a different style and severity if the edge’s associated source node is down.

If the script shouldn’t contribute any status to an edge just return null.

3.2.7. Layers

The GraphMLTopologyProvider can handle GraphML files with multiple graphs.
Each Graph is represented as a Layer in the Topology UI.
If a vertex from one graph has an edge pointing to another graph, one can navigate to that layer.

3.2.8. Breadcrumbs

When multiple Layers are used it is possible to navigate between them (navigate to option from vertex' context menu).
To give the user some orientation breadcrumbs can be enabled with the breadcrumb-strategy property.

The following strategies are supported:

NONE No breadcrumbs are shown.

SHORTEST_PATH_TO_ROOT generates breadcrumbs from all visible vertices to the root layer (TopologyProvider).
The algorithms assumes a hierarchical graph. Be aware, that all vertices MUST share the same root layer, otherwise the algorithm to determine the path to root does not work.

The following figure visualizes a graphml defining multiple layers (see below for the graphml definition).

From the given example, the user can select the Breadcrumb Example Topology Provider from the menu.
The user can switch between Layer 1, Layer 2 and Layer 3.
In addition for each vertex which has connections to another layer, the user can select the navigate to option from the context menu of that vertex to navigate to the according layer.
The user can also search for all vertices and add it to focus.

The following behaviour is implemented:

If a user navigates from one vertex to a vertex in another layer, the view is switched to that layer and adds all vertices to focus, the source vertex pointed to. The Breadcrumb is <parent layer name> > <source vertex>.
For example, if a user navigates from Layer1:A2 to Layer2:B1 the view switches to Layer 2 and adds B1 and B2 to focus. In addition Layer 1 > A2 is shown as Breadcrumbs.

If a user directly switches to another layer, the default focus strategy is applied, which may result in multiple vertices with no unique parent.
The calculated breadcrumb is: <parent layer name> > Multiple <target layer name>.
For example, if a user switches to Layer 3, all vertices of that layer are added to focus (focus-strategy=ALL). No unique path to root is found, the following breadcrumb is shown instead: Layer 1 > Multiple Layer 1 > Multiple Layer 2

If a user adds a vertex to focus, which is not in the current selected layer, the view switches to that layer and only the "new" vertex is added to focus.
The generated breadcrumb shows the path to root through all layers.
For example, the user adds C3 to focus, and the current layer is Layer 1, than the generated breadcrumb is as follows: Layer 1 > A1 > B3.

Only elements between layers are shown in the breadcrumb. Connections on the same layer are ignored.
For example, a user adds C5 to focus, the generated breadcrumb is as follows: Layer 1 > A2 > B2

The following graphml file defines the above shown graph.
Be aware, that the root vertex shown above is generated to help calculating the path to root.
It must not be defined in the graphml document.

5.1. ReST URL

5.2. Authentication

Use HTTP Basic authentication to provide a valid username and password.
By default you will not receive a challenge, so you must configure your ReST client library to send basic authentication proactively.

5.3. Data format

Jersey allows ReST calls to be made using either XML or JSON.
By default a request to the API is returned in XML. XML is delivered without namespaces. Please note: If a namespace is added manually in order to use a XML tool to validate against the XSD (like xmllint) it won’t be preserved when OpenNMS updates that file. The same applies to comments.
To get JSON encoded responses one has to send the following header with the request: Accept: application/json.

5.4. Standard Parameters

The following are standard params which are available on most resources (noted below)

Table 2. ReST standard parameter for resources

Parameter

Description

limit

integer, limiting the number of results. This is particularly handy on events and notifications, where an accidental call with no limit could result in many thousands of results being returned, killing either the client or the server. If set to 0, then no limit applied

offset

integer, being the numeric offset into the result set from which results should start being returned. E.g., if there are 100 result entries, offset is 15, and limit is 10, then entries 15-24 will be returned. Used for pagination

Filtering: All properties of the entity being accessed can be specified as parameters in either the URL (for GET) or the form value (for PUT and POST). If so, the value will be used to add a filter to the result. By default, the operation is equality, unless the comparator parameter is sent, in which case it applies to all comparisons in the filter. Multiple properties will result in an AND operation between the filter elements. Available comparators are:

eq

Checks for equality

ne

Checks for non-equality

ilike

Case-insensitive wildcarding (% is the wildcard)

like

Case-sensitive wildcarding (% is the wildcard)

gt

Greater than

lt

Less than

ge

Greater than or equal

le

Less than or equal

If the value null is passed for a given property, then the obvious operation will occur (comparator will be ignored for that property).
notnull is handled similarly.

Ordering: If the parameter orderBy is specified, results will be ordered by the named property.
Default is ascending, unless the order parameter is set to desc (any other value will default to ascending)

5.5. Standard filter examples

Take /events as an example.

Resource

Description

/events?eventUei=uei.opennms.org/internal/rtc/subscribe

would return the first 10 events with the rtc subscribe UEI, (10 being the default limit for events)

/events?eventUei=uei.opennms.org/internal/rtc/subscribe&limit=0

would return all the rtc subscribe events (potentially quite a few)

/events?id=100&comparator=gt

would return the first 10 events with an id greater than 100

/events?eventAckTime=notnull

would return the first 10 events that have a non-null Ack time (i.e. those that have been acknowledged)

/events?eventAckTime=notnull&id=100&comparator=gt&limit=20

would return the first 20 events that have a non-null Ack time and an id greater than 100. Note that the notnull value causes the comparator to be ignored for eventAckTime

would return the first 20 events that have were acknowledged after 28th July 2008 at 4:41am (+12:00), and an id greater than 100. Note that the same comparator applies to both property comparisons. Also note that you must URL encode the plus sign when using GET.

/events?orderBy=id&order=desc

would return the 10 latest events inserted (probably, unless you’ve been messing with the id’s)

/events?location.id=MINION

would return the first 10 events associated with some node in location 'MINION'

5.6. HTTP Return Codes

The following apply for OpenNMS Horizon 18 and newer.

DELETE requests are going to return a 202 (ACCEPTED) if they are performed asynchronously otherwise they return a 204 (NO_CONTENT) on success.

All the PUT requests are going to return a 204 (NO_CONTENT) on success.

All the POST requests that can either add or update an entity are going to return a 204 (NO_CONTENT) on success.

All the POST associated to resource addition are going to return a 201 (CREATED) on success.

All the POST requests where it is required to return an object will return a 200 (OK).

All the requests excepts GET for the Requisitions end-point and the Foreign Sources Definitions end-point will return 202 (ACCEPTED). This is because all the requests are actually executed asynchronously and there is no way to know the status of the execution, or wait until the processing is done.

If a resource is not modified during a PUT request, a NOT_MODIFIED will be returned. A NO_CONTENT will be returned only on a success operation.

All GET requests are going to return 200 (OK) on success.

All GET requests are going to return 404 (NOT_FOUND) when a single resource doesn’t exist; but will return 400 (BAD_REQUEST), if an intermediate resource doesn’t exist. For example, if a specific IP doesn’t exist on a valid node, return 404. But, if the IP is valid and the node is not valid, because the node is an intermediate resource, a 400 will be returned.

If something not expected is received from the Service/DAO Layer when processing any HTTP request, like an exception, a 500 (INTERNAL_SERVER_ERROR) will be returned.

Any problem related with the incoming parameters, like validations, will generate a 400 (BAD_REQUEST).

5.7. Identifying Resources

Some endpoints deal in resources, which are identified by Resource IDs.
Since every resource is ultimately parented under some node, identifying the node which contains a resource is the first step in constructing a resource ID.
Two styles are available for identifying the node in a resource ID:

Style

Description

Example

node[ID]

Identifies a node by its database ID, which is always an integer

node[42]

node[FS:FID]

Identifies a node by its foreign-source name and foreign-ID, joined by a single colon

node[Servers:115da833-0957-4471-b496-a731928c27dd]

The node identifier is followed by a period, then a resource-type name and instance name.
The instance name’s characteristics may vary from one resource-type to the next.
A few examples:

Value

Description

nodeSnmp[]

Node-level (scalar) performance data for the node in question.
This type is the only one where the instance identifier is empty.

interfaceSnmp[eth0-04013f75f101]

A layer-two interface as represented by a row in the SNMP ifTable.
The instance identifier is composed of the interface’s ifName and its ifPhysAddress (if it has one).

dskIndex[_root_fs]

The root filesystem of a node running the Net-SNMP management agent.

Putting it all together, here are a few well-formed resource IDs:

node[1].nodeSnmp[]

node[42].interfaceSnmp[eth0-04013f75f101]

node[Servers:115da833-0957-4471-b496-a731928c27dd].dskIndex[_root_fs]

5.8. Expose ReST services via OSGi

In order to expose a ReST service via OSGi the following steps must be followed:

Define an interface, containing java jax-rs annotations

Define a class, implementing that interface

Create an OSGi bundle which exports a service with the interface from above

5.8.1. Define a ReST interface

At first a public interface must be created which must contain jax-rs annotations.

5.9. Currently Implemented Interfaces

5.9.1. Acknowledgements

the default offset is 0, the default limit is 10 results.
To get all results, use limit=0 as a parameter on the URL (ie, GET /acks?limit=0).

GETs (Reading Data)

Resource

Description

/acks

Get a list of acknowledgements.

/acks/count

Get the number of acknowledgements. (Returns plaintext, rather than XML or JSON.)

/acks/{id}

Get the acknowledgement specified by the given ID.

POSTs (Setting Data)

Resource

Description

/acks

Creates or modifies an acknowledgement for the given alarm ID or notification ID. To affect an alarm, set an alarmId< parameter in the URL-encoded POST body; to affect a notification, set notifyId instead. An action parameter is also required, and may be one of ack, unack, clear, or esc (escalate).

5.9.2. Alarm Statistics

It is possible to get some basic statistics on alarms, including the number of acknowledged alarms, total alarms, and the newest and oldest of acknowledged and unacknowledged alarms.

GETs (Reading Data)

Resource

Description

/stats/alarms

Returns statistics related to alarms. Accepts the same Hibernate parameters that you can pass to the /alarms ReST service.

/stats/alarms/by-severity

Returns the statistics related to alarms, one per severity. You can optionally pass a list of severities to the severities query parameter to limit it to the specified severities. (eg, GET /opennms/rest/stats/alarms/by-severity?severities=MAJOR,CRITICAL).

5.9.3. Alarms

the default offset is 0, the default limit is 10 results. To get all results, use limit=0 as a parameter on the URL (ie, GET /events?limit=0).

GETs (Reading Data)

Resource

Description

/alarms

Get a list of alarms.

/alarms/count

Get the number of alarms. (Returns plaintext, rather than XML or JSON.)

/alarms/{id}

Get the alarms specified by the given ID.

Note that you can also query by severity, like so:

Resource

Description

/alarms?comparator=ge&severity=MINOR

Get the alarms with a severity greater than or equal to MINOR.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

New in OpenNMS 1.11.0

In OpenNMS 1.11.0, some additional features are supported in the alarm ack API:

Resource

Description

/alarms/{id}?clear=true

Clears an alarm.

/alarms/{id}?escalate=true

Escalates an alarm. eg, NORMAL → MINOR, MAJOR → CRITICAL, etc.

/alarms?x=y&…​&clear=true

Clears alarms matching the additional query parameters.

/alarms?x=y&…​&escalate=true

Escalates alarms matching the additional query parameters.

Additionally, when acknowledging alarms (ack=true) you can now specify an ackUser parameter.
You will only be allowed to ack as a different user IF you are PUTting as an authenticated user who is in the admin role.

5.9.4. Events

GETs (Reading Data)

Resource

Description

/events

Get a list of events. The default for offset is 0, and the default for limit is 10. To get all results, use limit=0 as a parameter on the URL (ie, GET /events?limit=0).

/events/count

Get the number of events. (Returns plaintext, rather than XML or JSON.)

/events/{id}

Get the event specified by the given ID.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

Resource

Description

/events/{id}?ack=''(true;false)

Acknowledges (or unacknowledges) an event.

/events?x=y&…​&ack=''(true;false)

Acknowledges (or unacknowledges) the matching events.

POSTs (Adding Data)

POST requires XML (application/xml) or JSON (application/json) as its Content-Type.

See ${OPENNMS_HOME}/share/xsds/event.xsd for the reference schema.

Resource

Description

/events

Publish an event on the event bus.

5.9.5. Categories

GETs (Reading Data)

Resource

Description

/categories

Get all configured categories.

/categories/{category}

Get the category specified by the given name.

/categories/{category}/nodes/{node}

Get the category specified by the given name for the given node (similar to /nodes/{node}/categories/{category})

/categories/nodes/{node}

Get the categories for a given node (similar to /nodes/{node}/categories)

/categories/groups/{group}

Get the categories for a given user group (similar to /groups/{group}/categories)

POSTs (Adding Data)

Resource

Description

/categories

Adds a new category.

PUTs (Modifying Data)

Resource

Description

/categories/{category}

Update the specified category

/categories/{category}/nodes/{node}

Modify the category with the given node ID and name (similar to /nodes/{node}/categories/{category})

/categories/{category}/groups/{group}

Add the given category to the given user group (similar to /groups/{group}/categories/{category})

DELETEs (Removing Data)

Resource

Description

/categories/{category}

Delete the specified category

/categories/{category}/nodes/{node}

Remove the given category from the given node (similar to /nodes/{node}/categories/{category})

/categories/{category}/groups/{group}

Remove the given category from the given user group (similar to /groups/{group}/categories/{category})

5.9.6. Flow API

The Flow API can be used to retrieve summary statistics and time series data derived from persisted flows.

Unless specific otherwise, all unit of time are expressed in milliseconds.

GETs (Reading Data)

Resource

Description

/flows/count

Retrieve the number of flows available

/flows/exporters

Retrieve basic information for the exporter nodes that have flows available

/flows/exporters/{nodeCriteria}

Retrieve detailed information about a specific exporter node

/flows/applications

Retrieve traffic summary statistics for the top N applications

/flows/applications/series

Retrieve time series metrics for the top N applications

/flows/conversations

Retrieve traffic summary statistics for the top N conversations

/flows/conversations/series

Retrieve time series metrics for the top N conversations

All of the endpoints support the following query string parameters to help filter the results:

The given filters are combined using a logical AND.
There is no support for using OR logic, or combinations thereof.

name

default

comment

start

-14400000

Timestamp in milliseconds.

If > 0, the timestamp is relative to the UNIX epoch (January 1st 1970 00:00:00 AM).

If < 0, the timestamp is relative to the end option (i.e.: default value is 4 hours ago).

end

0

Timestamp in milliseconds. If <= 0, the effective value will be the current timestamp.

PUTs (Updating Data)

Update a rule identified by {id}.
The id of the rule cannot be changed.

/groups/{id}

Retrieve the rule identified by {id}.

/classifications/groups

Update a group.
At the moment, only the enabled property can be changed

DELETEs (Deleting Data)

Resource

Description

/classifications?groupId={groupId}

Deletes all rules of a given group.

/groups/{id}

Delete the given group and all it’s containing rules.

5.9.8. Foreign Sources

ReSTful service to the OpenNMS Horizon Provisioning Foreign Source definitions. Foreign source definitions are used to control the scanning (service detection) of services for SLA monitoring as well as the data collection settings for physical interfaces (resources).

This API supports CRUD operations for managing the Provisioner’s foreign source definitions. Foreign source definitions are POSTed and will be deployed when the corresponding requisition gets imported/synchronized by Provisiond.

If a request says that it gets the "active" foreign source, that means it returns the pending foreign source (being edited for deployment) if there is one, otherwise it returns the deployed foreign source.

GETs (Reading Data)

Resource

Description

/foreignSources

Get all active foreign sources.

/foreignSources/default

Get the active default foreign source.

/foreignSources/deployed

Get the list of all deployed (active) foreign sources.

/foreignSources/deployed/count

Get the number of deployed foreign sources. (Returns plaintext, rather than XML or JSON.)

/foreignSources/{name}

Get the active foreign source named {name}.

/foreignSources/{name}/detectors

Get the configured detectors for the foreign source named {name}.

/foreignSources/{name}/detectors/{detector}

Get the specified detector for the foreign source named {name}.

/foreignSources/{name}/policies

Get the configured policies for the foreign source named {name}.

/foreignSources/{name}/policies/{policy}

Get the specified policy for the foreign source named {name}.

POSTs (Adding Data)

POST requires XML using application/xml as its Content-Type.

Resource

Description

/foreignSources

Add a foreign source.

/foreignSources/{name}/detectors

Add a detector to the named foreign source.

/foreignSources/{name}/policies

Add a policy to the named foreign source.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

Resource

Description

/foreignSources/{name}

Modify a foreign source with the given name.

DELETEs (Removing Data)

Resource

Description

/foreignSources/{name}

Delete the named foreign source.

/foreignSources/{name}/detectors/{detector}

Delete the specified detector from the named foreign source.

/foreignSources/{name}/policies/{policy}

Delete the specified policy from the named foreign source.

5.9.9. Groups

Like users, groups have a simplified interface as well.

GETs (Reading Data)

Resource

Description

/groups

Get a list of groups.

/groups/{groupname}

Get a specific group, given a group name.

/groups/{groupname}/users

Get the users for a group, given a group name. (new in OpenNMS 14)

/groups/{groupname}/categories

Get the categories associated with a group, given a group name. (new in OpenNMS 14)

POSTs (Adding Data)

Resource

Description

/groups

Add a new group.

PUTs (Modifying Data)

Resource

Description

/groups/{groupname}

Update the metadata of a group (eg, change the comments field).

/groups/{groupname}/users/{username}

Add a user to the group, given a group name and username. (new in OpenNMS 14)

/groups/{groupname}/categories/{categoryname}

Associate a category with the group, given a group name and category name. (new in OpenNMS 14)

DELETEs (Removing Data)

Resource

Description

/groups/{groupname}

Delete a group.

/groups/{groupname}/users/{username}

Remove a user from the group. (new in OpenNMS 14)

/groups/{groupname}/categories/{categoryname}

Disassociate a category from a group, given a group name and category name. (new in OpenNMS 14)

5.9.10. Heatmap

GETs (Reading Data)

Resource

Description

/heatmap/outages/categories

Sizes and color codes based on outages for nodes grouped by Surveillance Categories

/heatmap/outages/foreignSources

Sizes and color codes based on outages for nodes grouped by Foreign Source

/heatmap/outages/monitoredServices

Sizes and color codes based on outages for nodes grouped by monitored services

/heatmap/outages/nodesByCategory/{category}

Sizes and color codes based on outages for nodes associated with a specific Surveillance Category

/heatmap/outages/nodesByForeignSource/{foreignSource}

Sizes and color codes based on outages for nodes associated with a specific Foreign Source

/heatmap/outages/nodesByMonitoredService/{monitoredService}

Sizes and color codes based on outages for nodes providing a specific monitored service

Resource

Description

/heatmap/alarms/categories

Sizes and color codes based on alarms for nodes grouped by Surveillance Categories

/heatmap/alarms/foreignSources

Sizes and color codes based on alarms for nodes grouped by Foreign Source

/heatmap/alarms/monitoredServices

Sizes and color codes based on alarms for nodes grouped by monitored services

/heatmap/alarms/nodesByCategory/{category}

Sizes and color codes based on alarms for nodes associated with a specific Surveillance Category

/heatmap/alarms/nodesByForeignSource/{foreignSource}

Sizes and color codes based on alarms for nodes associated with a specific Foreign Source

/heatmap/alarms/nodesByMonitoredService/{monitoredService}

Sizes and color codes based on alarms for nodes providing a specific monitored service

5.9.11. Categories

Obtain or modify the status of a set of monitored services based on a given search criteria, based on nodes, IP interfaces, Categories, or monitored services itself.

Examples:

/ifservices?node.label=onms-prd-01

/ifservices?ipInterface.ipAddress=192.168.32.140

/ifservices?category.name=Production

/ifservices?status=A

GETs (Reading Data)

Resource

Description

/ifservices

Get all configured monitored services for the given search criteria.

Example:

Get the forced unmanaged services for the nodes that belong to the requisition named Servers:

Secondary attribute that will be queried in the case the primary attribute does not exist.

Step sizes

The behavior of the step parameter changes based on time series strategy that is being used.

When using persistence strategies based on RRD, the available step sizes are limited to those defined by the RRA when the file was created.
The effective step size used will be one that covers the requested period, and is closest to the requested step size.
For maximum accuracy, use a step size of 1.

When using Newts, the step size can be set arbitrarily since the aggregation is performed at the time of request.
In order to help prevent large requests, we limit to the step size of a minimum of 5 minutes, the default collection rate.
This value can be decreased by setting the org.opennms.newts.query.minimum_step system property.

POSTs (Reading Data)

Resource

Description

/measurements

Retrieve the measurements for one or more attributes, possibly spanning multiple resources, with support for JEXL expressions.

Here we use a POST instead of a GET to retrieve the measurements, which allows us to perform complex queries which are difficult to express in a query string.
These requests cannot be used to update or create new metrics.

An example of the POST body is available bellow.

Usage examples with curl

Retrieve bits in and bits out metrics for a particular interface. Perform calculations on bits out, and only return the derived values.

More Advanced Expressions

The JEXL 2.1.x library is used to parse the expression string and this also allows java objects and predefined functions to be included in the expression.

JEXL uses a context which is pre-populated by OpenNMS with the results of the query.
Several constants and arrays are also predefined as references in the context by OpenNMS.

Constant or prefix

Description

__inf

Double.POSITIVE_INFINITY

__neg_inf

Double.NEGATIVE_INFINITY

NaN

Double.NaN

__E

java.lang.Math.E

__PI

java.lang.Math.PI

__diff_time

Time span between start and end of samples

__i

Index into the samples array which the present calculation is referencing

__AttributeName (where AttributeName is the searched for attribute)

This returns the complete double[] array of samples for AttributeName

OpenNMS predefines a number of functions for use in expressions which are referenced by namespace:function.
All of these functions return a java double value.

Pre defined functions

Function

Description

Example

jexl:evaluate("_formula"):

Passes a string to the JEXL engine to be evaluated as if it was entered as a normal expression.
Like normal expressions, expressions evaluated through this function will return a Java double value.
This makes it possible to reference and evaluate a formula which has been stored in OpenNMS as a string variable.
The use case for this capability is that it gives us the ability to define and store a per-node and per-value correction formula which can normalise samples from different sample sources.

math:

References java.lang.Math class

math:cos(20)

strictmath:

References java.lang.StrictMath class

math:cos(20)

fn:

References the class org.opennms.netmgt.measurements.impl.SampleArrayFunctions.
This contains several functions which can reference previous samples in the time series.

fn:arrayNaN("sampleName", n)

References the nth previous sample in the "sampleName" sample series. Replacing the n samples before the start of the series with NaN.

fn:arrayNaN("x", 5)

fn:arrayZero("sampleName", n)

References the nth previous sample in the "sampleName" sample series. Replacing the n samples before the start of the series with 0 (zero).

fn:arrayZero("x", 5)

fn:arrayFirst("sampleName", n)

References the nth previous sample in the "sampleName" sample series. Replacing the n samples before the start of the series with the first sample.

fn:arrayFirst("x", 5)

fn:arrayStart("sampleName", n, constant)

References the nth previous sample in the "sampleName" sample series. Replacing the n samples before the start of the series with a supplied constant.

fn:arrayStart("x", 5, 10)

So for example with these additional variables and functions it is possible to create a Finite Impulse Response (FIR) filter function such as

y = a * f(n) + b * f(n-1) + c * f(n-2)

using the following expression where a,b and c are string constants and x is a time series value

a * x + b * fn:arrayNaN("x", 1) + c * fn:arrayNaN("x", 2)

5.9.15. Nodes

Note: the default offset is 0, the default limit is 10 results. To get all results, use limit=0 as a parameter on the URL (ie, GET /nodes?limit=0).

Additionally, anywhere you use "id" in the queries below, you can use the foreign source and foreign ID separated by a colon instead (ie, GET /nodes/fs:fid).

GETs (Reading Data)

Resource

Description

/nodes

Get a list of nodes. This includes the ID and node label.

/nodes/{id}

Get a specific node, by ID.

/nodes/{id}/ipinterfaces

Get the list of IP interfaces associated with the given node.

/nodes/{id}/ipinterfaces/{ipAddress}

Get the IP interface for the given node and IP address.

/nodes/{id}/ipinterfaces/{ipAddress}/services

Get the list of services associated with the given node and IP interface.

/nodes/{id}/ipinterfaces/{ipAddress}/services/{service}

Get the requested service associated with the given node, IP interface, and service name.

/nodes/{id}/snmpinterfaces

Get the list of SNMP interfaces associated with the given node.

/nodes/{id}/snmpinterfaces/{ifIndex}

Get the specific interface associated with the given node and ifIndex.

/nodes/{id}/categories

Get the list of categories associated with the given node.

/nodes/{id}/categories/{categoryName}

Get the category associated with the given node and category name.

/nodes/{id}/assetRecord

Get the asset record associated with the given node.

POSTs (Adding Data)

POST requires XML using application/xml as its Content-Type.

Resource

Description

/nodes

Add a node.

/nodes/{id}/ipinterfaces

Add an IP interface to the node.

/nodes/{id}/ipinterfaces/{ipAddress}/services

Add a service to the interface for the given node.

/nodes/{id}/snmpinterfaces

Add an SNMP interface to the node.

/nodes/{id}/categories

Add a category association to the node.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

Resource

Description

/nodes/{id}

Modify a node with the given ID.

/nodes/{id}/ipinterfaces/{ipAddress}

Modify the IP interface with the given node ID and IP address.

/nodes/{id}/ipinterfaces/{ipAddress}/services/{service}

Modify the service with the given node ID, IP address, and service name.

/nodes/{id}/snmpinterfaces/{ifIndex}

Modify the SNMP interface with the given node ID and ifIndex.

/nodes/{id}/categories/{categoryName}

Modify the category with the given node ID and name.

DELETEs (Removing Data)

Perform a DELETE to the singleton URLs specified in PUT above to delete that object.

Deletion of nodes, ipinterfaces and services are asynchronous so they will return 202 (ACCEPTED). Deletion of snmpinterfaces and categories are synchronous calls so they will return 204 (NO_CONTENT) on success.

5.9.16. Notifications

Note: the default offset is 0, the default limit is 10 results.
To get all results, use limit=0 as a parameter on the URL (ie, GET /events?limit=0).

GETs (Reading Data)

Resource

Description

/notifications

Get a list of notifications.

/notifications/count

Get the number of notifications. (Returns plaintext, rather than XML or JSON.)

/notifications/{id}

Get the notification specified by the given ID.

To acknowledge or unacknowledge a notification, use the acks endpoint — see Acknowledgements.

5.9.17. Outage Timelines

GETs (Reading Data)

Resource

Description

/header/{start}/{end}/{width}

Generate the timeline header

/image/{nodeId}/{ipAddress}/{serviceName}/{start}/{end}/{width}

Generate the timeline image

/empty/{start}/{end}/{width}

Generate an empty timeline for non-monitored services

/html/{nodeId}/{ipAddress}/{serviceName}/{start}/{end}/{width}

Generate the raw HTML for the image

5.9.18. Outages

GETs (Reading Data)

Resource

Description

/outages

Get a list of outages.

/outages/count

Get the number of outages. (Returns plaintext, rather than XML or JSON.)

/outages/{id}

Get the outage specified by the given ID.

/outages/forNode/{nodeId}

Get the outages that match the given node ID.

5.9.19. Requisitions

RESTful service to the OpenNMS Horizon Provisioning Requisitions.
In this API, these "groups" of nodes are aptly named and treated as requisitions.

This current implementation supports CRUD operations for managing provisioning requisitions.
Requisitions are first POSTed and no provisioning (import/synchronize) operations are taken.
This is done so that a) the XML can be verified and b) so that the operations can happen at a later time.
They are moved to the deployed state (put in the active requisition repository) when an import is run.

If a request says that it gets the active requisition, that means it returns the pending requisition (being edited for deployment) if there is one, otherwise it returns the deployed requisition.
Note that anything that says it adds/deletes/modifies a node, interface, etc. in these instructions is referring to modifying that element from the requisition not from the database itself.
That will happen upon import/synchronization.

You may write requisition data if the authenticated user is in the provision, rest, or admin roles.

GETs (Reading Data)

Resource

Description

/requisitions

Get all active requisitions.

/requisitions/count

Get the number of active requisitions. (Returns plaintext, rather than XML or JSON.)

/requisitions/deployed

Get the list of all deployed (active) requisitions.

/requisitions/deployed/count

Get the number of deployed requisitions. (Returns plaintext, rather than XML or JSON.)

/requisitions/{name}

Get the active requisition for the given foreign source name.

/requisitions/{name}/nodes

Get the list of nodes being requisitioned for the given foreign source name.

/requisitions/{name}/nodes/{foreignId}

Get the node with the given foreign ID for the given foreign source name.

/requisitions/{name}/nodes/{foreignId}/interfaces

Get the interfaces for the node with the given foreign ID and foreign source name.

/requisitions/{name}/nodes/{foreignId}/interfaces/{ipAddress}

Get the interface with the given IP for the node with the specified foreign ID and foreign source name.

Adds (or replaces) a service on the given interface in the specified requisition.

/requisitions/{name}/nodes/{foreignId}/categories

Adds (or replaces) a category for the given node in the specified requisition.

/requisitions/{name}/nodes/{foreignId}/assets

Adds (or replaces) an asset for the given node in the specified requisition.

PUTs (Modifying Data)

Expects form-urlencoded

Resource

Description

/requisitions/{name}/import

Performs an import/synchronize on the specified foreign source. This turns the "active" requisition into the "deployed" requisition.

/requisitions/{name}/import?rescanExisting=false

Performs an import/synchronize on the specified foreign source. This turns the "active" requisition into the "deployed" requisition. Existing nodes will not be scanned until the next rescan interval, only newly-added nodes will be. Useful if you’re planning on making a series of changes.

/requisitions/{name}

Update the specified foreign source.

/requisitions/{name}/nodes/{foreignId}

Update the specified node for the given foreign source.

/requisitions/{name}/nodes/{foreignId}/interfaces/{ipAddress}

Update the specified IP address for the given node and foreign source.

DELETEs (Removing Data)

Resource

Description

/requisitions/{name}

Delete the pending requisition for the named foreign source.

/requisitions/deployed/{name}

Delete the active requisition for the named foreign source.

/requisitions/{name}/nodes/{foreignId}

Delete the node with the given foreign ID from the given requisition.

/requisitions/{name}/nodes/{foreignId}/interfaces/{ipAddress}

Delete the IP address from the requisitioned node with the given foreign ID and foreign source.

5.9.23. SNMP Configuration

You can edit the community string, SNMP version, etc. for an IP address using this interface. If you make a change that would overlap with an existing snmp-config.xml, it will automatically create groups of <definition /> entries as necessary. If no <definition /> entry is created it matches the defaults.

There are different versions of the interface (see below).
The following operations are supported:

GETs (Reading Data)

Parameter

Description

/snmpConfig/{ipAddress}

Get the SNMP configuration for a given IP address.

/snmpConfig/{ipAddress}?location={location}

Get the SNMP configuration for a given IP address at a given location.

Returns the SNMP configuration for IP address 10.1.1.1 as defined in example 1.

API Version 2

Since Version 2 all attributes of a <definition /> entry defined in snmp-config.xsd (http://xmlns.opennms.org/xsd/config/snmp) can be set or get via the interface - except it is only possible to set the configuration for one IP address and not for a range of IP addresses.
This may change in the future.

The interface uses SnmpInfo objects for communication.
Therefore it is possible to set for example v1 and v3 parameters in one request (e.g. readCommunity String and privProtocol String).
However OpenNMS Horizon does not allow this.
It is only allowed to set attributes which have no version restriction (e.g. timeout value) or the attributes which are limited to the version (e.g. readCommunity String if version is v1/v2c).
The same is for getting data from the API, even if it is possible to store v1 and v3 parameters in one definition block in the snmp-config.xml manually, the ReST API will only return the parameters which match the version.
If no version is defined, the default is assumed (both in PUT and GET requests).

The following table shows all supported attributes, the mapping between snmp-info.xsd and snmp-config.xsd.
It also shows the version limitations, default values and the restrictions - if any.

attribute snmp-info.xml

attribute snmp-config.xml

default

restricted to version

restriction

version

version

v1

-

"v1", "v2c" or "v3" are valid arguments.
If an invalid or empty argument is provided "v1" is used.

port

port

161

-

Integer > 0

retries

retry

1

-

Integer > 0

timeout

timeout

3000

-

Integer > 0

maxVarsPerPdu

max-vars-per-pdu

10

-

Integer > 0

maxRepetitions

max-repetitions

2

-

Integer > 0

maxRequestSize

max-request-size

65535

-

Integer > 0

proxyHost

proxy-host

-

readCommunity

read-community

public

v1, v2c

writeCommunity

write-community

private

v1, v2c

securityName

security-name

opennmsUser

v3

securityLevel

security-level

noAuthNoPriv

v3

Integer value, which can be null, 1, 2, or 3. <ul><li>1 means noAuthNoPriv</li><li>2 means authNoPriv</li><li>3 means authPriv</li></ul> If you do not set the security level manually it is determined automatically: <ul><li>if no authPassPhrase set the securityLevel is 1</li><li>if a authPassPhrase and no privPassPhrase is set the security level is 2.</li><li>if a authPassPhrase and a privPassPhrase is set the security level is 3.</li></ul>

5.9.24. Users

Since users are not currently stored in the database, the ReST interface for them is not as full-fledged as that of nodes, etc.

You cannot use hibernate criteria for filtering.
You may need to touch the $OPENNMS_HOME/etc/users.xml file on the filesystem for any addition or modification actions to take effect (see NMS-6469 for details).

GETs (Reading Data)

Parameter

Description

/users

Get a list of users.

/users/{username}

Get a specific user, by username.

POSTs (Adding Data)

Parameter

Description

/users

Add a user. If supplying a password it is assumed to be hashed or encrypted already, at least as of 1.12.5.
To indicate that the supplied password uses the salted encryption algorithm rather than the older MD5 based algorithm, you need to pass an element named passwordSalt with text true after the password element (or key/value pairs if using JSON).

PUTs (Update defaults)

On a successful request, the Syslog NBI will be notified about the configuration change.

Resource

Description

/config/snmptrap-nbi/status?enabled=(true;false)

Sets the status of the SNMP Trap NBI.

POSTs (Adding Data)

POST requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the SNMP Trap NBI will be notified about the configuration change.

Resource

Description

/config/snmptrap-nbi

Updates the full content of the configuration.

/config/snmptrap-nbi/destinations

Adds a new or overrides an existing destination.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the SNMP Trap NBI will be notified about the configuration change.

Resource

Description

/config/snmptrap-nbi/destinations/{name}

Updates the content of the destination named {name}

DELETEs (Remove Data)

On a successful request, the SNMP Trap NBI will be notified about the configuration change.

Resource

Description

/config/snmptrap-nbi/destinations/{name}

Updates the content of the destination named {name}

5.9.26. Email Northbounder Interface Configuration

GETs (Reading Data)

Resource

Description

/config/email-nbi

Gets full content of the configuration.

/config/email-nbi/status

Gets the status of the Email NBI (returns either true or false).

/config/email-nbi/destinations

Gets the name of all the existing destinations.

/config/email-nbi/destinations/{name}

Gets the content of the destination named {name}

PUTs (Update defaults)

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/email-nbi/status?enabled=(true;false)

Sets the status of the Email NBI.

POSTs (Adding Data)

POST requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/email-nbi/destinations

Adds a new or overrides an existing destination.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/email-nbi/destinations/{name}

Updates the content of the destination named {name}

DELETEs (Remove Data)

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/email-nbi/destinations/{name}

Updates the content of the destination named {name}

5.9.27. Javamail Configuration

GETs (Reading Data)

Resource

Description

/config/javamail/default/readmail

Get the name of the default readmail config.

/config/javamail/default/sendmail

Get the name of the default sendmail config.

/config/javamail/readmails

Get the name of all the existing readmail configurations.

/config/javamail/sendmails

Get the name of all the existing sendmail configurations.

/config/javamail/end2ends

Get the name of all the existing end2end mail configurations.

/config/javamail/readmails/{name}

Get the content of the readmail configuration named {name}

/config/javamail/sendmails/{name}

Get the content of the sendmail configuration named {name}

/config/javamail/end2ends/{name}

Get the content of the end2end mail configuration named {name}

POSTs (Adding/Updating Data)

POST requires form data using application/xml or application/json as a Content-Type.

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/javamail/readmails

Adds a new or overrides an existing readmail configuration.

/config/javamail/sendmails

Adds a new or overrides an existing sendmail configuration.

/config/javamail/end2ends

Adds a new or overrides an existing end2ends mail configuration.

PUTs (Update defaults)

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

config/javamail/default/readmail/{name}

Sets the readmail named {name} as the new default.

config/javamail/default/sendmail/{name}

Sets the sendmail named {name} as the new default.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/javamail/readmails/{name}

Updates the content of the readmail configuration named {name}

/config/javamail/sendmails/{name}

Updates the content of the sendmail configuration named {name}

/config/javamail/end2ends/{name}

Updates the content of the end2end mail configuration named {name}

DELETEs (Remove Data)

On a successful request, the Email NBI will be notified about the configuration change.

Resource

Description

/config/javamail/readmails/{name}

Removes the readmail configuration named {name}

/config/javamail/sendmails/{name}

Removes the sendmail configuration named {name}

/config/javamail/end2ends/{name}

Removes the end2end mail configuration named {name}

5.9.28. Syslog Northbounder Interface Configuration

GETs (Reading Data)

Resource

Description

/config/syslog-nbi

Gets full content of the configuration.

/config/syslog-nbi/status

Gets the status of the Syslog NBI (returns either true or false).

/config/syslog-nbi/destinations

Gets the name of all the existing destinations.

/config/syslog-nbi/destinations/{name}

Gets the content of the destination named {name}

PUTs (Update defaults)

On a successful request, the Syslog NBI will be notified about the configuration change.

Resource

Description

/config/syslog-nbi/status?enabled=(true;false)

Sets the status of the Syslog NBI.

POSTs (Adding Data)

POST requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the Syslog NBI will be notified about the configuration change.

Resource

Description

/config/syslog-nbi

Updates the full content of the configuration.

/config/syslog-nbi/destinations

Adds a new or overrides an existing destination.

PUTs (Modifying Data)

PUT requires form data using application/x-www-form-urlencoded as a Content-Type.

On a successful request, the Syslog NBI will be notified about the configuration change.

Resource

Description

/config/syslog-nbi/destinations/{name}

Updates the content of the destination named {name}

DELETEs (Remove Data)

On a successful request, the Syslog NBI will be notified about the configuration change.

Resource

Description

/config/syslog-nbi/destinations/{name}

Updates the content of the destination named {name}

5.9.29. Business Service Monitoring

Every aspect of the Business Service Monitoring feature can be controlled via a ReST API.
The API’s endpoint for managing Business Services is located at /opennms/api/v2/business-services.
It supports XML content to represent the Business Services.
The schema file describing the API model is located in $OPENNMS_HOME/share/xsds/business-service-dto.xsd.
The responses generated by the ReST API do also include location elements that contain references to other entities managed by the API.
The Business Service response data model for the ReST API has the following basic structure:

5.10. ReST API Examples

5.10.1. Getting Graph data

While graphs aren’t technically available via ReST, you can parse some ReST variables to get enough data to pull a graph.
This isn’t ideal because it requires multiple fetches, but depending on your use case, this may be adequate for you.

I’m in-lining some sample PHP code which should do this (not tested at all, cut & paste from old code I have that does not use the ReST- interface, and/or coded straight into the browser so YMMV).
If you go to your NMS and click the resource graphs, then right click the graph you want and hit _View Image you will get the full URL that would need to be passed to pull that graph as a standalone image.

From that just take the URL and plug in the values you pulled from ReST to get a graph for whatever node you wanted.

6. Develop Documentation

This document is the guideline for people who wish to contribute to writing documentation for the OpenNMS project.
The OpenNMS software is free and open source, contribution of any kind is welcome.
We ask that you observe the rules and guidelines outlined here to maintain consistency across the project.

Each (sub)project is represented as a section of the documentation.
Each section will produce a HTML output in the file system that is generated in the target/generated sources folder.

Note that there are different ways to contribute documentation, each suitable for the different use cases:

Tutorials and How To’s should be published on the OpenNMS Wiki.
For example:
you want to describe how to use the Net-SNMP agent and the SNMP monitor from OpenNMS to solve a special use case with OpenNMS.

The documentation in the source code should be formal technical documentation.
The writing style should be accurate and concise.
However, ensure that you explain concepts in detail and do not make omissions.

6.1. File Structure in opennms-doc

Directory

Contents

guide-admin/

module with the guide for administrators configuring, optimizing and running OpenNMS

guide-development/

module with the guide for those who want to develop OpenNMS

guide-install/

module with the guide of how to install OpenNMS on different operating systems

releasenotes/

module with the changelog and release notes

6.2. Writing

The following rules will help you to commit correctly formatted and prepared documentation for inclusion in the OpenNMS project.
It is important that we maintain a level of consistency across all of our committers and the documentation they produce.

When writing place a single sentence on each line.
This makes it easy to move content around, and also easy to spot long, or fragmented, sentences.
This will also allow us to assign comments on a sentence in GitHub which will facilitate easier merging.

Other than writing documentation, you can help out by providing comments on documentation, reviewing, suggesting improvements or reporting bugs.
To do this head over to: issue tracker for documentation!

6.2.1. Conventions for text formatting

The following conventions are used:

File names and path are written in `poller-configuration.xml` they will be rendered in: poller-configuration.xml;

Names that indicate special attention, e.g. this configuration matches *any* entry: this is rendered as: this configuration matches any entry;

_Italics_ is rendered as Italics and used for emphasis and indicate internal names and abbreviations;

*Bold* is rendered as Bold and should be used sparingly, for strong emphasis only;

+methodName()+ is rendered as methodName() and is also used for literals,
(note: the content between the + signs will be parsed);

`command` is rendered as command (typically used for command-line or parts used in configuration files),
(note: the content between the ` signs will not be parsed);

`my/path/` is rendered as my/path/ this is used for file names and paths;

\``double quote'' (which is two grave accents to the left and two acute accents to the right) renders as ``double quote'';

\`single quote' (which is a single grave accent to the left and a single acute accent to the right) renders as `single quote'.

6.2.2. Gotchas

Always leave a blank line at the top of the documents section.
It might be the title ends up in the last paragraph of the document;

Start in line 2 setting a relative path to the images directory to picture rendering on GitHub:

// Allow image rendering
:imagesdir: relative/path/to/images/dir

Always leave a blank line at the end of documents;

As {} are used for Asciidoc attributes, everything inside will be treated as an attribute.
To avoid this you have to escape the opening brace: \\{.
If you do not escape the opening brace, the braces and the text inside them will be removed without any warning being issued!;

Forcing line breaks can be achieved with ` +` at the end of the line followed by a line break.

Example in source force line break

This is the first line +
and this a forced 2nd line

Rendered output with forced line break

This is the first line
and this a forced 2nd line

6.3. Headings and document structure

Each document starts over with headings from level zero (the document title).
Each document should have an id.
In some cases sections in the document need to have id’s as well, this depends on where they fit in the overall structure.
If you wish to have a link to specific content that content has to have an id.
A missing id in a mandatory place will cause the build to fail.

To start a document:

[[unique-id-verbose-is-ok]]
= The Document Title

If you are including the document inside another document and you need to push the headings down to the right level in the output, the leveloffset attribute is used.

Subsequent headings in a document should use the following syntax:

== Subheading
... content here ...
=== Subsubheading
content here ...

6.4. Links

When you need to link to other parts of the manual you use the target id.
To use a target id you follow this syntax:

It is acceptable to have a period trailing after the URL, it will not render as a part of the link.

6.5. Admonitions and useful notes

These are useful for defining specific sections, such as Notes, Tips and Important information.
We encourage the use of them in the documentation as long as they are used appropriately.
Choose from the following:

Source template for making a note for additional hints

NOTE: This is my note.

This is how its rendered:

This is my note.

Source for giving a tip

TIP: This is my tip.

This is how its rendered:

This is my tip.

Source for giving a important hint

IMPORTANT: This is my important hint.

This is how its rendered:

This is my important hint.

Source for giving a caution

CAUTION: This is my caution.

This is how its rendered:

This is my caution.

Source for giving a warning

WARNING: This is my warning.

This is how its rendered:

This is my warning.

A multiline variation:

TIP: Tiptext. +
Line 2.

Which is rendered as:

Tiptext.
Line 2.

Remember to write these in full caps. There is no easy manner in which to add new admonitions, do not create your own.

6.6. Attributes

Common attributes you can use in documents:

{opennms-version} - rendered as "24.0.0-SNAPSHOT"

These can substitute part of URLs that point to, for example, APIdocs or source code.
Note that opennms-git-tag also handles the case of snapshot/master.

Sample Asciidoc attributes which can be used:

{docdir} - root directory of the documents

{nbsp} - non-breaking space

6.7. Comments

There’s a separate build that includes comments.
When the comments are used they show up with a yellow background.
This build doesn’t run by default, but after a normal build, you can use make annotated to create a build yourself.
You can use the resulting 'annotated' page to search for content as the full manual is a single page.

To write a comment:

// this is a comment

Comments are not visible in the standard build.
Comment blocks won’t be included in the output of any build.
The syntax for a comment block is:

////
Note that includes in here will still be processed, but not make it into the output.
That is, missing includes here will still break the build!
////

6.8. Tables

For representing structured information you can use tables.
A table is constructed in the following manner:

Please align your columns in the AsciiDoc source in order to give better readability when editing in text view.
If you have a very long description, break at 120 characters and align the text to improve source readability.

Figure 1. Example in AsciiDoc source for very long table descriptions

this is rendered as:

Parameter

Description

Required

Default value

basic-authentication

Authentication credentials to perform basic authentication.
Credentials should comply to RFC1945 section 11.1,
without the Base64 encoding part. That’s: be a string made of the concatenation of:
1- the user ID;
2- a colon;
3- the password.basic-authentication takes precedence over the user and password parameters.

optional

-

header[0-9]+

Additional headers to be sent along with the request. Example of valid parameter’s names are
header0, header1 and header180. header is not a valid parameter name.

optional

-

6.9. Include images

When visualizing complex problems you can help the explanation and provide greater information by using an image.
We use in OpenNMS documentation modules two directories for images.

The image folder structure mirrors the text structure.
In this case it is a little bit easier to locate the AsciiDoc text file where the image is included.

The module for this documentation for target group of documentation contributors;

3

Indicates a source folder;

4

The documentation root folder;

5

Folder for images. Images should be *.png or *.jpg if included in the documentation;

6

The image used, the format is a leading <number>_ followed by a name using no spaces;

7

Some images are created from tools like yED, this folder should contain the editable version of the file with the same file name;

8

Editable version of the image source file, note no spaces in the name;

9

Main document file which includes all documentation parts and is rendered as index.html for the web;

10

AsciiDoc source file which can include images;

11

Target folder with generated HTML output after mvn clean package has been performed;

All images in the entire manual share the same namespace, it is therefore best practice to use unique identifiers for images.

To include an image file, make sure that it resides in the 'images/' directory relative to the document you’re including it within.
Then use the following syntax for inclusion in the document:

First included image

.This is a caption of the image
image::docs/02_opennms-logo.png[]

Which is rendered as:

Figure 2. This is a caption of the image

The image path for the images you include is relative to the *.adoc source file, where you use the image.

6.10. Code Snippets

You can include code snippets, configuration- or source code files in the documentation.
You can enable syntax highlighting by providing the given language parameter, this will work on source code or configuration.

6.10.1. Explicitly defined in the document

be careful to use this kind of code snippets as sparsely as possible.
Code becomes obsolete very quickly, archaic usage practices are detrimental.

6.10.2. Included from an example file

You can include source or configuration from an external file.
In this way you can provide a working example configuration maintaining doc and example at the same time.
The procedure and rules are the same as with images, the path is relative to the *.adoc file where the file to be used is included.

6.10.3. Include parts of a file

If you want to include just a specific segment of a large configuration file, you can assign tags that indicate to AsciiDoc the section that is to be included.
In this example just the service definition of the ICMP monitor should be included.

In the 'poller-configuration.xml' tag the section in the following manner:

6.12. Migrating content from project wiki

The project wiki contains much information that ought to be migrated to the official documentation set.
To help with this effort, we have a wiki template which informs readers of articles that are tagged for migration to the official docs, or that have already been migrated.
When you identify an article in the OpenNMS wiki whose information should be migrated (either in its entirety, or just individual sections), use the following process.

Migrate the information, making sure to follow the guidelines laid out earlier in this section; do not just copy and paste, and watch out for obsolete information. If you need help, contact the developers through one of the methods mentioned above.

Once the migration is complete and the issue is closed, edit the wiki article again and change completed=false to completed=true.

The rendering of the template will change to indicate that the migration has been completed.

Adding the {{OfficialDocs}} template to an article will implicitly add that article to a pair of wiki categories:

Migration to official docs pending or Migration to official docs completed, according to the value of the completed attribute

Migrate to X guide, according to the value of the guide attribute

7. AMQP Integration

The AMQP Integration allows external systems to communicate with the event bus of OpenNMS Horizon and receive alarms via the AMQP protocol.

AMQP is standard messaging protocol supported by a number of brokers including ActiveMQ and QPID.

The integration is written using Camel + OSGi and has the following components:

Event Forwarder

Event Receiver

Alarm Northbounder

Custom filtering (i.e. which events to forward) and transformations (i.e. how the events are represented in the messages) can be used in each of the components.
Generic implementations

Each componenent can be configured and setup independently, i.e. you can choose to only forward alarms.

7.1. Event Forwarder

The event forwarder listens for all events on the internal event bus of OpenNMS Horizon.
Events from the bus are sent to a Camel processor, which can filter or transform these, before being sent to the AMQP endpoint.

The event forwarder exposes the following properties via the org.opennms.features.amqp.eventforwarder pid:

Named org.apache.camel.Processor implementation used to filter and/or format the events.

The default processor, the default-event-forwarder-processor, marshalls events to XML and does not perform any filtering.
This means that when enabled, all events will be forwarded to the AMQP destination with XML strings as the message body.

7.1.2. Debugging

You can get detailed information on the Camel route using:

camel:route-info forwardEvent

7.2. Event Receiver

The event receiver listens for messages from an AMQP target and forwards them onto the internal event bus of OpenNMS Horizon.
Messages are sent to a Camel processor, which can filter or transform these, before being sent onto the event bus.

The event receiver exposes the following properties via the org.opennms.features.amqp.eventreceiver pid:

Named org.apache.camel.Processor implementation used to filter and/or format the alarms.

The default processor, the default-alarm-northbounder-processor, converts the alarms to a string and does not perform any filtering.
This means that when enabled, all alarms will be forwarded to the AMQP destination with strings as the message body.

If the event forwarder feature was already started, it should automatically restart and start using the new processor.
Otherwise, you can start the feature with:

feature:install opennms-amqp-event-forwarder

8. Design and Styleguidelines

8.1. Jasper Report Guideline

Building and contributing JasperReports is a way to contribute to the project.
To make it easier to maintain and style reports the following layout guideline can be used to have similar and more consistent report layout.

Figure 6. Layout for creating JasperReports

The following formatting can be applied:

Type

Convention

Date

yyyy/MM/dd HH:mm:ss

Report Range

Report Begin: ${startDate} Report End: ${endDate}

Paging

Page ${current} of ${total}

Based on this template definition there exist a GitHub repository which contains a JasperReport template.