Verified Commit c0c73e31 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Add docs.

parent c671f819
# snmptrap MX Message
`snmptrap` message is generated by [trapcollector](../../../admin/reference/services/trapcollector.md)
service when managed object SNMP Trap is received.
## Message Headers
Message-Type
: Type of message. Always `snmptrap`.
Sharding-Key
: Key for consistent sharding.
Labels
: Managed Object's effective labels.
## Message Format
Message contains JSON array, containing objects of following structure
| Name | Type | Description |
| ---------- | -------- | -------------------------------------------------------------------- |
| timestamp | DateTime | ISO 8601 timestamp (i.e. `YYYY-MM-DDTHH:MM:SS`) of collected metrics |
| uuid | String | Global `UUID` |
| collector_type | String | Always `snmptrap` |
| collector | String | Collector Pool |
| address | String | SNMP Trap Source Address |
| object | Object {{ complex }} | Managed Object |
| {{ tab }} id | String | Managed Object's ID |
| {{ tab }} bi_id | Integer | Managed Object's BI ID |
| {{ tab }} name | String | Managed Object's name |
| {{ tab }} labels | Array of String | Managed Object's labels |
| {{ tab }} administrative_domain | Object {{ complex }} | Managed Object Administrative Domain's |
| {{ tab2 }} remote_system | Object {{ complex }} | Managed Object Administrative Domain's [Remote System](../../../user/reference/concepts/remote-system/index.md) (if imported) |
| {{ tab4 }} id | String | Remote System's ID |
| {{ tab4 }} name | String | Remote System's Name |
| {{ tab2 }} id | Integer | Managed Object Administrative Domain's ID |
| {{ tab2 }} name | String | Managed Object Administrative Domain's Name |
| {{ tab2 }} remote_id | String | Managed Object Administrative Domain's ID in Remote System (if any) |
| {{ tab }} remote_system | Object {{ complex }} | Managed Object's [Remote System](../../../user/reference/concepts/remote-system/index.md) (if imported) |
| {{ tab2 }} id | String | Remote System's ID |
| {{ tab2 }} name | String | Remote System's Name |
| {{ tab }} remote_id | String | Managed Object's ID in Remote System (if any) |
| snmptrap | Object {{ complex }} | SNMP Trap message body content |
| {{ tab }} vars | Array of {{ complex }} | SNMP Trap varbinds |
| {{ tab2 }} oid | String | Var OID value |
| {{ tab2 }} value | String | Var OID value |
## Example
```json
{
"timestamp": "2022-06-20T10:07:15",
"uuid": "3d6a2405-447c-44e7-b885-7a2deb43a26a",
"collector_type": "snmptrap",
"collector": "default",
"address": "127.0.0.1",
"managed_object": {
"id": "450",
"bi_id": 7602684790455147111,
"name": "device-1",
"administrative_domain": {
"id": 11,
"name": "default",
"remote_system": {
"id": "596e715fc165cf1e082ea14c",
"name": "TEST"
},
"remote_id": "1"
},
"labels": [],
"remote_system": {
"id": "596e715fc165cf1e082ea14c",
"name": "TEST"
},
"remote_id": "22"
},
"snmptrap": {
"vars": [
{
"oid": "1.3.6.1.2.1.1.3.0",
"value": "2199886748",
"value_rest": ""
},
{
"oid": "1.3.6.1.6.3.1.1.4.1.0",
"value": "1.3.6.1.6.3.1.1.5.3",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.2.1.1.9",
"value": "10104",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.2.1.7.9",
"value": "1",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.2.1.8.9",
"value": "2",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.3",
"value": "This is a Test",
"value_rest": ""
}
],
}
}
```
\ No newline at end of file
......@@ -1292,6 +1292,7 @@ nav:
- managedobject: user/reference/mx/managedobject.md
- metrics: user/reference/mx/metrics.md
- reboot: user/reference/mx/reboot.md
- snmptrap: user/reference/mx/snmptrap.md
- Technologies:
- Group: user/reference/technology/group.md
- "Network | CGNAT Termination": user/reference/technology/Network/cgnat-termination.md
......
# snmptrap MX Message
`snmptrap` message is generated by [trapcollector](../../../admin/reference/services/trapcollector.md)
service when managed object SNMP Trap is received.
## Message Headers
Message-Type
: Type of message. Always `snmptrap`.
Sharding-Key
: Key for consistent sharding.
Labels
: Managed Object's effective labels.
## Message Format
Message contains JSON array, containing objects of following structure
| Name | Type | Description |
| ---------- | -------- | -------------------------------------------------------------------- |
| timestamp | DateTime | ISO 8601 timestamp (i.e. `YYYY-MM-DDTHH:MM:SS`) of collected metrics |
| uuid | String | Global `UUID` |
| collector_type | String | Always `snmptrap` |
| collector | String | Collector Pool |
| address | String | SNMP Trap Source Address |
| object | Object {{ complex }} | Managed Object |
| {{ tab }} id | String | Managed Object's ID |
| {{ tab }} bi_id | Integer | Managed Object's BI ID |
| {{ tab }} name | String | Managed Object's name |
| {{ tab }} labels | Array of String | Managed Object's labels |
| {{ tab }} administrative_domain | Object {{ complex }} | Managed Object Administrative Domain's |
| {{ tab2 }} remote_system | Object {{ complex }} | Managed Object Administrative Domain's [Remote System](../../../user/reference/concepts/remote-system/index.md) (if imported) |
| {{ tab4 }} id | String | Remote System's ID |
| {{ tab4 }} name | String | Remote System's Name |
| {{ tab2 }} id | Integer | Managed Object Administrative Domain's ID |
| {{ tab2 }} name | String | Managed Object Administrative Domain's Name |
| {{ tab2 }} remote_id | String | Managed Object Administrative Domain's ID in Remote System (if any) |
| {{ tab }} remote_system | Object {{ complex }} | Managed Object's [Remote System](../../../user/reference/concepts/remote-system/index.md) (if imported) |
| {{ tab2 }} id | String | Remote System's ID |
| {{ tab2 }} name | String | Remote System's Name |
| {{ tab }} remote_id | String | Managed Object's ID in Remote System (if any) |
| snmptrap | Object {{ complex }} | SNMP Trap message body content |
| {{ tab }} vars | Array of {{ complex }} | SNMP Trap varbinds |
| {{ tab2 }} oid | String | Var OID value |
| {{ tab2 }} value | String | Var OID value |
## Example
```json
{
"timestamp": "2022-06-20T10:07:15",
"uuid": "3d6a2405-447c-44e7-b885-7a2deb43a26a",
"collector_type": "snmptrap",
"collector": "default",
"address": "127.0.0.1",
"managed_object": {
"id": "450",
"bi_id": 7602684790455147111,
"name": "device-1",
"administrative_domain": {
"id": 11,
"name": "default",
"remote_system": {
"id": "596e715fc165cf1e082ea14c",
"name": "TEST"
},
"remote_id": "1"
},
"labels": [],
"remote_system": {
"id": "596e715fc165cf1e082ea14c",
"name": "TEST"
},
"remote_id": "22"
},
"snmptrap": {
"vars": [
{
"oid": "1.3.6.1.2.1.1.3.0",
"value": "2199886748",
"value_rest": ""
},
{
"oid": "1.3.6.1.6.3.1.1.4.1.0",
"value": "1.3.6.1.6.3.1.1.5.3",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.2.1.1.9",
"value": "10104",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.2.1.7.9",
"value": "1",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.2.1.8.9",
"value": "2",
"value_rest": ""
},
{
"oid": "1.3.6.1.2.1.2.3",
"value": "This is a Test",
"value_rest": ""
}
],
}
}
```
\ No newline at end of file
......@@ -1303,6 +1303,7 @@ nav:
- managedobject: user/reference/mx/managedobject.md
- metrics: user/reference/mx/metrics.md
- reboot: user/reference/mx/reboot.md
- snmptrap: user/reference/mx/snmptrap.md
- Technologies:
- Group: user/reference/technology/group.md
- "Network | CGNAT Termination": user/reference/technology/Network/cgnat-termination.md
......
# ----------------------------------------------------------------------
# cfgtrap datastream
# ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
......@@ -83,6 +83,7 @@ class CfgTrapDataStream(DataStream):
"trap_community": trap_community,
"managed_object": {
"id": str(mo_id),
"bi_id": str(bi_id),
"name": name,
"administrative_domain": {"id": adm_domain, "name": adm_domain_name},
"labels": [
......
......@@ -2,14 +2,15 @@
# ---------------------------------------------------------------------
# Syslog Collector service
# ---------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from collections import defaultdict
import datetime
import asyncio
import base64
from collections import defaultdict
from dataclasses import asdict
from typing import Optional, Any, Dict
......@@ -116,10 +117,11 @@ class TrapCollectorService(FastAPIService):
if config.message.enable_snmptrap:
metrics["events_message"] += 1
n_partitions = get_mx_partitions()
now = datetime.datetime.now()
self.publish(
value=orjson.dumps(
{
"timestamp": timestamp,
"timestamp": now.replace(microsecond=0),
"uuid": uuid.uuid4(),
"collector_type": "snmptrap",
"collector": config.pool,
......
......@@ -26,6 +26,7 @@ class AdministrativeDomainData(object):
@dataclass
class ManagedObjectData(object):
id: str
bi_id: int
name: str
administrative_domain: AdministrativeDomainData
labels: List[str] = None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment