【发布时间】:2016-04-11 19:57:28
【问题描述】:
客户要求我们将 SNMP 陷阱发送到他们的 Nagios 服务器,而不是电子邮件警报。昨天我对 SNMP 的唯一了解是它听起来像是一个首字母缩略词,所以请原谅(并纠正我)我可能对它的任何误解。
需要在陷阱中发送的唯一信息是关于我们向客户发出警报的事件的数据,这只是从我们的数据库中提取的几个值。不用说这些不在任何类型的 MIB 中,也没有任何 OID,这就是我无法找到答案的地方。
如果不使用我没有的 MIB OID,我无法弄清楚如何将我们的特定数据添加到陷阱中。
我正在使用 PySNMP 生成请求,现在只有不完整的代码,因为我不确定如何将我们的数据合并到数据包中。
from pysnmp.hlapi import *
def sendSNMP(destination, community_string, data):
community = CommunityData(community_string, mpModel = 0)
target = UdpTransportTarget((destination, 162))
notification_type = None
req = sendNotification(SnmpEngine(), community, target, ContextData(), 'trap', notification_type)
errorIndication, errorStatus, errorIndex, varBinds = next(req)
感谢任何帮助!谢谢。
【问题讨论】: