bundlewrap/bundles/routeros-monitoring/metadata.py

143 lines
6.4 KiB
Python

h = repo.libs.hashable.hashable
defaults = {
'apt': {
'packages': {
'snmp': {},
'snmp-mibs-downloader': {},
},
},
}
@metadata_reactor.provides(
'telegraf/config/inputs/snmp',
)
def routeros_monitoring_telegraf_inputs(metadata):
return {
"telegraf": {
"config": {
"inputs": {
"snmp": [
{
"agents": [f"udp://{routeros_node.hostname}:161"],
"version": 2,
"community": "public",
"interval": "30s",
"tags": {
"host": routeros_node.name,
"operating_system": "routeros",
},
# scalar -> input-level
"field": [
{
"name": "switch_name",
"oid": "SNMPv2-MIB::sysName.0",
"is_tag": True,
},
],
"table": [
# Interface statistics
{
"name": "interface",
"oid": "IF-MIB::ifTable",
"field": [
# Labels (optional but recommended)
{
"name": "ifName",
"oid": "IF-MIB::ifName",
"is_tag": True,
},
{
"name": "ifAlias",
"oid": "IF-MIB::ifAlias",
"is_tag": True,
},
# Bytes (64-bit)
{
"name": "in_octets",
"oid": "IF-MIB::ifHCInOctets",
},
{
"name": "out_octets",
"oid": "IF-MIB::ifHCOutOctets",
},
# Packets (64-bit unicast)
{
"name": "in_ucast_pkts",
"oid": "IF-MIB::ifHCInUcastPkts",
},
{
"name": "out_ucast_pkts",
"oid": "IF-MIB::ifHCOutUcastPkts",
},
# Drops / Errors
{
"name": "in_discards",
"oid": "IF-MIB::ifInDiscards",
},
{
"name": "out_discards",
"oid": "IF-MIB::ifOutDiscards",
},
{
"name": "in_errors",
"oid": "IF-MIB::ifInErrors",
},
{
"name": "out_errors",
"oid": "IF-MIB::ifOutErrors",
},
],
},
# PoE
{
"name": "poe",
"oid": "MIKROTIK-MIB::mtxrPOETable",
"field": [
{
"name": "ifName",
"oid": "IF-MIB::ifName",
"is_tag": True,
},
{
"name": "ifAlias",
"oid": "IF-MIB::ifAlias",
"is_tag": True,
},
{
"name": "poe_ifindex",
"oid": "MIKROTIK-MIB::mtxrPOEInterfaceIndex",
"is_tag": True,
},
{
"name": "poe_status",
"oid": "MIKROTIK-MIB::mtxrPOEStatus",
},
{
"name": "poe_voltage",
"oid": "MIKROTIK-MIB::mtxrPOEVoltage",
},
{
"name": "poe_current",
"oid": "MIKROTIK-MIB::mtxrPOECurrent",
},
{
"name": "poe_power",
"oid": "MIKROTIK-MIB::mtxrPOEPower",
},
],
},
],
}
for routeros_node in repo.nodes_in_group("routeros")
]
}
}
}
}