客户要求我们将 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)
Run Code Online (Sandbox Code Playgroud)
任何帮助表示感谢!谢谢。