Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d940202
upload, get and update rest endpoints
Shahbaz-dataq Mar 17, 2026
1a4d4c2
changes for dto
Shahbaz-dataq Mar 17, 2026
2a4c5ac
test cases
Shahbaz-dataq Mar 17, 2026
dbfa3e4
new rest endpoints or snmp v3 users
Shahbaz-dataq Mar 17, 2026
dbab24d
mappers fixes
Shahbaz-dataq Mar 17, 2026
9093b6f
Merge commit '2d2fde87e254ed9b5baa6146e52423eb838a652a' into jira/NMS…
Shahbaz-dataq Mar 18, 2026
7b025ce
field use address from varbind fix
Shahbaz-dataq Mar 18, 2026
2dc702d
Trapd UI rest endpoint integration
Shahbaz-dataq Mar 18, 2026
0622433
new changes
Shahbaz-dataq Mar 18, 2026
9d79643
new changes
Shahbaz-dataq Mar 19, 2026
5e211ab
changes
Shahbaz-dataq Mar 19, 2026
09781f6
changes
Shahbaz-dataq Mar 19, 2026
6d8a9e6
changes
Shahbaz-dataq Mar 19, 2026
3871d57
change
Shahbaz-dataq Mar 20, 2026
38a969d
search changes
Shahbaz-dataq Mar 24, 2026
474dd50
changes
Shahbaz-dataq Mar 24, 2026
58e68cd
new fixes
Shahbaz-dataq Mar 24, 2026
6f0c791
new changes
Shahbaz-dataq Mar 25, 2026
f4fcae4
test cases fix
Shahbaz-dataq Mar 25, 2026
08f3209
test fix
Shahbaz-dataq Mar 26, 2026
b67b910
Merge commit '08f3209b0e98781439c04622375e08797d0b5caa' into jira/NMS…
Shahbaz-dataq Mar 26, 2026
97c4b04
api changes
Shahbaz-dataq Mar 26, 2026
c8cff3e
checkes reverted
Shahbaz-dataq Mar 26, 2026
96b4132
new changes for fe
Shahbaz-dataq Mar 26, 2026
eec16d1
changes
Shahbaz-dataq Mar 26, 2026
12e226c
test coverage
Shahbaz-dataq Mar 27, 2026
6193e7a
user updates changes
Shahbaz-dataq Mar 29, 2026
e583a11
scv changes and test coverage
Shahbaz-dataq Mar 29, 2026
7539ffc
Merge commit '6193e7a863d6a37011662798d92f94b41ccd8ffa' into jira/NMS…
Shahbaz-dataq Mar 29, 2026
a1405f3
unused code removed
Shahbaz-dataq Mar 29, 2026
de9a756
menu item
Shahbaz-dataq Mar 29, 2026
8264e12
route fix
Shahbaz-dataq Mar 29, 2026
85a1195
Merge commit 'de9a756e3352d59309877e92e0cd95953c1d21c9' into jira/NMS…
Shahbaz-dataq Mar 29, 2026
9a4c9c2
Merge commit '0fb1f5d1660192c53d89875166e44a66179b1cd3' into jira/NMS…
Shahbaz-dataq Mar 29, 2026
14ae536
Merge commit '9a4c9c2adeae117335e87852c90f681565648000' into jira/NMS…
Shahbaz-dataq Mar 29, 2026
4d18483
test fixes
Shahbaz-dataq Mar 29, 2026
e4e3431
naming fixes
Shahbaz-dataq Mar 29, 2026
1c0b88a
unused imports
Shahbaz-dataq Mar 30, 2026
15cd590
review changes
Shahbaz-dataq Mar 31, 2026
26cf6f3
trapd documentation
Shahbaz-dataq Apr 1, 2026
77991d7
response messages update
Shahbaz-dataq Apr 1, 2026
f9a4b9c
Merge commit '77991d754a13b9d045e09c4c1230269bff073980' into jira/NMS…
Shahbaz-dataq Apr 2, 2026
bdda3bf
validator fix
Shahbaz-dataq Apr 2, 2026
bf38a54
DAO update fix
Shahbaz-dataq Apr 2, 2026
a435ae4
Merge commit 'bf38a5450574cc81149b1bac749fb561b95fdd81' into jira/NMS…
Shahbaz-dataq Apr 2, 2026
d4eba69
Merge commit 'cfe68c24e855db79780682a8aea09fdc0e0e51ca' into jira/NMS…
Shahbaz-dataq Apr 3, 2026
8e30322
Merge commit 'd4eba699928584da372e000693750d2fc791b712' into jira/NMS…
Shahbaz-dataq Apr 3, 2026
adefa0d
config dao fix
Shahbaz-dataq Apr 3, 2026
5e82549
DAO fixes
Shahbaz-dataq Apr 3, 2026
161952c
Merge commit '5e82549b16cb35429335f55016cfe89cfe6d4ec5' into jira/NMS…
Shahbaz-dataq Apr 3, 2026
3362b19
changelog
Shahbaz-dataq Apr 3, 2026
00dd9e3
Merge commit '3362b191c175433e1cf5b06e3ec1c8df8bdc4308' into jira/NMS…
Shahbaz-dataq Apr 3, 2026
26e56f2
Merge commit '527edf54617e7f7c88356441eea41ae1c8664bc3' into jira/NMS…
Shahbaz-dataq Apr 6, 2026
433e641
changes
Shahbaz-dataq Apr 6, 2026
b001372
menu code revert
Shahbaz-dataq Apr 6, 2026
d971b4b
review comment
Shahbaz-dataq Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/development/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
*** xref:rest/emailnbi-config.adoc[]
*** xref:rest/javamail-config.adoc[]
*** xref:rest/syslognbi-config.adoc[]
*** xref:rest/trapd-rest-api.adoc[]
*** xref:bsm/bsm-development.adoc[]
*** xref:rest/situation-feedback.adoc[]
Expand Down
179 changes: 179 additions & 0 deletions docs/modules/development/pages/rest/trapd-rest-api.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
[[ga-events-sources-trapd-rest-api]]
= Trapd REST API (v2)
:description: Manage trapd configuration through the OpenNMS REST v2 API.

You can view and update trapd configuration over REST.
These endpoints are useful for automation and external configuration tooling.

The Trapd REST API base path is `/api/v2/trapd`.

== Endpoint overview

[options="header"]
|===
| Method | Path | Content type | Description

| `GET`
| `/api/v2/trapd/config`
| `application/json`
| Get the current trapd configuration.

| `PUT`
| `/api/v2/trapd/config`
| `application/json`
| Replace trapd configuration using JSON payload.

| `POST`
| `/api/v2/trapd/upload`
| `multipart/form-data`
| Upload `trapd-configuration.xml` content as XML.
|===

== Get configuration

[source, bash]
----
curl -u admin:admin "http://localhost:8980/opennms/api/v2/trapd/config"
----

.Example response
[source, json]
----
{
"snmpTrapAddress": "*",
"snmpTrapPort": 1162,
"newSuspectOnTrap": false,
"includeRawMessage": false,
"threads": 0,
"queueSize": 10000,
"batchSize": 1000,
"batchInterval": 500,
"useAddressFromVarbind": true,
"snmpv3User": [
{
"engineId": "0x8000000001020304",
"securityName": "opennms",
"securityLevel": 3,
"authProtocol": "SHA",
"authPassphrase": "my-auth-secret",
"privacyProtocol": "AES",
"privacyPassphrase": "my-privacy-secret"
}
]
}
----

WARNING: The current implementation returns SNMPv3 passphrases as stored values when they are present.
They are not masked in `GET /api/v2/trapd/config` responses.

== Update configuration with JSON

[source, bash]
----
curl -u admin:admin \
-H "Content-Type: application/json" \
-X PUT "http://localhost:8980/opennms/api/v2/trapd/config" \
-d '{
"snmpTrapAddress": "*",
"snmpTrapPort": 1162,
"newSuspectOnTrap": false,
"includeRawMessage": true,
"threads": 4,
"queueSize": 10000,
"batchSize": 1000,
"batchInterval": 500,
"useAddressFromVarbind": true,
"snmpv3User": [
{
"securityName": "opennms",
"securityLevel": 3,
"authProtocol": "SHA",
"authPassphrase": "my-auth-secret",
"privacyProtocol": "AES",
"privacyPassphrase": "my-privacy-secret"
}
]
}'
----

== Upload trapd XML

The multipart form field name must be `upload`.

.Sample `trapd-configuration.xml` for upload
[source, xml]
----
<trapd-configuration xmlns="http://xmlns.opennms.org/xsd/config/trapd"
snmp-trap-address="*"
snmp-trap-port="1162"
new-suspect-on-trap="false"
include-raw-message="true"
queue-size="10000"
batch-size="1000"
batch-interval="500"
use-address-from-varbind="true">
<snmpv3-user security-name="opennms"
security-level="3"
auth-protocol="SHA"
auth-passphrase="${scv:trapd-v3-user:authPassphrase}"
privacy-protocol="AES"
privacy-passphrase="${scv:trapd-v3-user:privacyPassphrase}"/>
</trapd-configuration>
----

You can use SCV metadata expressions for passphrases in uploaded XML (`${scv:<alias>:<attribute>}`).

[source, bash]
----
curl -u admin:admin \
-X POST "http://localhost:8980/opennms/api/v2/trapd/upload" \
-F "upload=@/opt/opennms/etc/trapd-configuration.xml;type=application/xml"
----

== Validation rules

The API validates both top-level trapd fields and SNMPv3 user definitions.

.PUT pre-validation (service layer)
* `snmpTrapAddress` is required for `PUT /api/v2/trapd/config`.
* `snmpTrapPort` is required and must be between `1` and `65535`.
* `newSuspectOnTrap` is required.
* `threads`, `queueSize`, `batchSize`, and `batchInterval` must be `>= 0` when provided.

.Additional schema validation (DAO layer, applies on persist)
* `queueSize` must be `>= 1`.
* `batchSize` must be `>= 1`.
* In XML uploads, `snmp-trap-address` is optional and defaults to `*` when omitted.

.SNMPv3 user fields
* `securityName` is required.
* `securityLevel` is required and must be `1`, `2`, or `3`.
* Supported `authProtocol`: `MD5`, `SHA`, `SHA-224`, `SHA-256`, `SHA-512`.
* Supported `privacyProtocol`: `DES`, `AES`, `AES192`, `AES256`.
* `authProtocol` and `authPassphrase` must be provided together.
* `privacyProtocol` and `privacyPassphrase` must be provided together.
* `securityLevel=1`: no auth or privacy credentials allowed.
* `securityLevel=2`: auth credentials required, privacy credentials not allowed.
* `securityLevel=3`: both auth and privacy credentials are required.

== Response codes

[options="header"]
|===
| Endpoint | Success | Error responses

| `GET /api/v2/trapd/config`
| `200 OK`
| `404 Not Found` (`Trapd configuration not found.`), `500 Internal Server Error` (`Failed to retrieve trapd configuration.`)

| `PUT /api/v2/trapd/config`
| `200 OK`
| `400 Bad Request` (validation errors), `500 Internal Server Error` (`Failed to persist trapd configuration.`)

| `POST /api/v2/trapd/upload`
| `200 OK`
| `400 Bad Request` (missing `upload`, invalid XML, schema validation errors), `500 Internal Server Error` (`Failed to persist trapd configuration.`)
|===

For XML-based upload, schema validation errors are returned as the response body text.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{page-component-title} can receive and process SNMP traps/informs from SNMP-capable devices out of the box.
It receives SNMP traps via the xref:reference:daemons/daemon-config-files/trapd.adoc[trapd service daemon], which is enabled by default.

To manage trapd configuration through REST, see xref:development:rest/trapd-rest-api.adoc[Trapd REST API (v2)].

{page-component-title} transforms these traps into events based on event definitions.
{page-component-title} includes trap definitions from many major manufacturers by default, and you can create your own event definitions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Based around traditional UDP-based SNMP traps, it receives traps that remote dev
It enables OpenNMS to receive SNMP traps and convert them into events and, if configured accordingly, convert those events into alarms and notifications.
Its functionality is similar to how xref:reference:daemons/daemon-config-files/syslogd.adoc[syslogd] handles syslog entries.

You can also manage trapd configuration over REST; see xref:development:rest/trapd-rest-api.adoc[Trapd REST API (v2)].

Trapd supports V1 traps, V2 traps and notifications, and V3 traps and notifications.
It also accepts traps with any community name (V1, V2c).
You can use that community name in event definitions as part of a mask.
Expand Down Expand Up @@ -69,11 +71,26 @@ Note that for V3, you must specify the SNMPv3 credentials used to authenticate a
privacy-passphrase="super-secret" privacy-protocol="DES"/>
</trapd-configuration>
----
For `privacy-protocol`, the available options are `DES`, `AES`, `AES192`, and `AES256`
For `auth-protocol`, the available options are `MD5`, `SHA`, `SHA-224`, `SHA-256`, and `SHA-512`
For `privacy-protocol`, the available options are `DES`, `AES`, `AES192`, and `AES256`.
For `auth-protocol`, the available options are `MD5`, `SHA`, `SHA-224`, `SHA-256`, and `SHA-512`.

NOTE: Metadata expressions can also be used in attributes of the `trapd-configuration.xml` configuration file.
This lets the user to also reference credentials stored in the secure credentials.
This lets you reference credentials from the Secure Credentials Vault (SCV), including SNMPv3 passphrases.

.Example using SCV metadata for SNMPv3 passphrases
[source, xml]
----
<trapd-configuration snmp-trap-port="162" new-suspect-on-trap="true">
<snmpv3-user security-name="opennms"
auth-protocol="SHA"
auth-passphrase="${scv:trapd-v3-user:authPassphrase}"
privacy-protocol="AES"
privacy-passphrase="${scv:trapd-v3-user:privacyPassphrase}"/>
</trapd-configuration>
----

The SCV expression format is `${scv:<alias>:<attribute>}`.
For SCV setup and management, see xref:operation:deep-dive/admin/configuration/scv-configuration.adoc[SCV configuration] and xref:operation:deep-dive/meta-data.adoc#ga-metadata-scv[secure credentials vault metadata].

== Trap metrics

Expand Down
Loading