微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用pysnmp时是否可以发送带有源地址的snmp陷阱

如何解决使用pysnmp时是否可以发送带有源地址的snmp陷阱

当前,我能够发送陷阱,但来源是陷阱源自的VM的mgmt ip。我希望能够在脚本中指定源IP。

脚本片段:

import sys
from pysnmp.hlapi import *
from pysnmp.entity.rfc3413 import context
from pysnmp.smi import builder
import requests
from requests.auth import _basic_auth_str
from uuid import uuid1
import os


def send_ce_notification(engine_id):
    snmp_engine = SnmpEngine (OctetString (engine_id))
    set_mib_source(snmp_engine,'/home/abc/pysnmp_cisco_mibs')
    errorIndication,errorStatus,errorIndex,varBinds = next(
        sendNotification(
            snmp_engine,UsmUserData(userName='xxxx',authKey='xxxxxxxxxxxx',privKey='xxxxxxxxxxxxx',authProtocol=usmHMACSHAAuthProtocol,privProtocol=xxxxxxxxxxxxxxx
                         ),UdpTransportTarget(('10.10.10.26',162)),ContextData(),'inform',NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.3'))
                .addVarBinds(
                ObjectType(ObjectIdentity('IF-MIB','ifAdminStatus',517),'down').loadMibs('IF-MIB'))
        )
    )
    print(f'errorIndicator :{errorIndication}')
    print(f'errorStatus :{errorStatus}')
    print(f'errorIndex :{errorIndex}')
    print(f'varBinds :{varBinds}')
    return errorIndication,varBinds

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。