• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python config.addNotificationTarget函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pysnmp.entity.config.addNotificationTarget函数的典型用法代码示例。如果您正苦于以下问题:Python addNotificationTarget函数的具体用法?Python addNotificationTarget怎么用?Python addNotificationTarget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了addNotificationTarget函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: cfgNtfOrg

 def cfgNtfOrg(self, authData, transportTarget, notifyType, tagList):
     addrName, paramsName = self.cfgCmdGen(
         authData, transportTarget, tagList
         )
     k = paramsName, tagList, notifyType
     if self.__knownNotifyNames.has_key(k):
         notifyName, _ = self.__knownNotifyNames[k]
     else:
         notifyName = 'n%s' % cmdgen.nextID()
         config.addNotificationTarget(
             self.snmpEngine,
             notifyName,
             paramsName,
             tagList,
             notifyType
             )
         self.__knownNotifyNames[k] = notifyName, paramsName
     if not self.__knownAuths.has_key(authData):
         subTree = (1,3,6)
         config.addTrapUser(
             self.snmpEngine,
             authData.securityModel,
             authData.securityName,
             authData.securityLevel,
             subTree
             )
         self.__knownAuths[authData] = subTree
     if self.snmpContext is None:
         self.snmpContext = context.SnmpContext(self.snmpEngine)
         config.addContext(
             self.snmpEngine, ''  # this is leaky
         )
     return notifyName
开发者ID:chrisliom,项目名称:pysnmp,代码行数:33,代码来源:ntforg.py


示例2: configure

    def configure(self, snmpEngine, authData, transportTarget, notifyType,
                  contextName, **options):
        cache = self._getCache(snmpEngine)

        notifyName = None

        # Create matching transport tags if not given by user. Not good!
        if not transportTarget.tagList:
            transportTarget.tagList = str(
                hash((authData.securityName, transportTarget.transportAddr))
            )

        if isinstance(authData, CommunityData) and not authData.tag:
            authData.tag = transportTarget.tagList.split()[0]

        addrName, paramsName = self._cmdGenLcdCfg.configure(
            snmpEngine, authData, transportTarget, contextName, **options)

        tagList = transportTarget.tagList.split()

        if not tagList:
            tagList = ['']

        for tag in tagList:
            notifyNameKey = paramsName, tag, notifyType

            if notifyNameKey in cache['name']:
                notifyName, paramsName, useCount = cache['name'][notifyNameKey]

                cache['name'][notifyNameKey] = notifyName, paramsName, useCount + 1

            else:
                notifyName = 'n%s' % self.nextID()

                config.addNotificationTarget(
                    snmpEngine, notifyName, paramsName, tag, notifyType)

                cache['name'][notifyNameKey] = notifyName, paramsName, 1

        authDataKey = authData.securityName, authData.securityModel, authData.securityLevel, contextName

        if authDataKey in cache['auth']:
            authDataX, subTree, useCount = cache['auth'][authDataKey]

            cache['auth'][authDataKey] = authDataX, subTree, useCount + 1

        else:
            subTree = (1, 3, 6)

            config.addVacmUser(
                snmpEngine,authData.securityModel, authData.securityName,
                authData.securityLevel, (), (), subTree,
                contextName=contextName)

            cache['auth'][authDataKey] = authData, subTree, 1

        return notifyName
开发者ID:etingof,项目名称:pysnmp,代码行数:57,代码来源:lcd.py


示例3: setTrapReceiver

 def setTrapReceiver(self, host, community):
     config.addV1System(self._snmpEngine, 'nms-area', community)
     config.addVacmUser(self._snmpEngine, 2, 'nms-area', 'noAuthNoPriv',
                        notifySubTree=(1, 3, 6, 1, 4, 1))
     config.addTargetParams(self._snmpEngine,
                            'nms-creds', 'nms-area', 'noAuthNoPriv', 1)
     config.addTargetAddr(self._snmpEngine, 'my-nms', udp.domainName,
                          (host, 162), 'nms-creds',
                          tagList='all-my-managers')
     # set last parameter to 'notification' to have it send
     # informs rather than unacknowledged traps
     config.addNotificationTarget(
                                  self._snmpEngine,
                                  'test-notification', 'my-filter',
                                  'all-my-managers', 'trap')
开发者ID:vincentwang901130,项目名称:gr-llsr,代码行数:15,代码来源:llsrSnmpAgent.py


示例4: initTarget

def initTarget(host='127.0.0.1', port=162, community='LIC_OSS'):
    #global snmpEngine, snmpContext, ntfOrg
    # Create SNMP engine instance
    snmpEngine = engine.SnmpEngine()
    
    # SecurityName <-> CommunityName mapping
    config.addV1System(snmpEngine, 'my-area', community)
    
    # Specify security settings per SecurityName (SNMPv2c -> 1)
    config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1)
    
    # Setup transport endpoint and bind it with security settings yielding
    # a target name
    config.addSocketTransport(
        snmpEngine,
        udp.domainName,
        udp.UdpSocketTransport().openClientMode()
    )
    config.addTargetAddr(
        snmpEngine, 'my-nms',
        udp.domainName, (host, port),
        'my-creds',
        tagList='all-my-managers'
    )
    
    # Specify what kind of notification should be sent (TRAP or INFORM),
    # to what targets (chosen by tag) and what filter should apply to
    # the set of targets (selected by tag)
    config.addNotificationTarget(
        snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap'
    )
    
    # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
    # and SecurityName
    config.addContext(snmpEngine, '')
    config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
    
    # *** SNMP engine configuration is complete by this line ***
    
    # Create default SNMP context where contextEngineId == SnmpEngineId
    snmpContext = context.SnmpContext(snmpEngine)
    
    # Create Notification Originator App instance. 
    ntfOrg = ntforg.NotificationOriginator(snmpContext)
    return snmpEngine, ntfOrg
开发者ID:lowitty,项目名称:alarmfiles,代码行数:45,代码来源:SnmpTraps.py


示例5: cfgNtfOrg

 def cfgNtfOrg(self, authData, transportTarget, notifyType):
     addrName, paramsName = self.cfgCmdGen(authData, transportTarget)
     tagList = transportTarget.tagList.split()
     if not tagList:
         tagList = ['']
     for tag in tagList:
         notifyNameKey = paramsName, tag, notifyType
         if notifyNameKey in self.__knownNotifyNames:
             notifyName, paramsName, useCount = self.__knownNotifyNames[notifyNameKey]
             self.__knownNotifyNames[notifyNameKey] = notifyName, paramsName, useCount + 1
         else:
             notifyName = 'n%s' % nextID()
             config.addNotificationTarget(
                 self.snmpEngine,
                 notifyName,
                 paramsName,
                 tag,
                 notifyType
             )
             self.__knownNotifyNames[notifyNameKey] = notifyName, paramsName, 1
     authDataKey = authData.securityName, authData.securityModel
     if  authDataKey in self.__knownAuths:
         authDataX, subTree, useCount = self.__knownAuths[authDataKey]
         self.__knownAuths[authDataKey] = authDataX, subTree, useCount + 1
     else:
         subTree = (1,3,6)
         config.addTrapUser(
             self.snmpEngine,
             authData.securityModel,
             authData.securityName,
             authData.securityLevel,
             subTree
         )
         self.__knownAuths[authDataKey] = authData, subTree, 1
     if self.snmpContext is None:
         self.snmpContext = context.SnmpContext(self.snmpEngine)
         config.addContext(
             self.snmpEngine, ''  # this is leaky
         )
     return notifyName
开发者ID:BoundaryDev,项目名称:boundary-plugin-mongodb-enterprise-dev,代码行数:40,代码来源:ntforg.py


示例6: cfgNtfOrg

    def cfgNtfOrg(self, snmpEngine, authData, transportTarget, notifyType):
        cache = self._getNtfCache(snmpEngine)
        addrName, paramsName = self.cfgCmdGen(
            snmpEngine, authData, transportTarget
        )
        tagList = transportTarget.tagList.split()
        if not tagList:
            tagList = ['']
        for tag in tagList:
            notifyNameKey = paramsName, tag, notifyType
            if notifyNameKey in cache['name']:
                notifyName, paramsName, useCount = cache['name'][notifyNameKey]
                cache['name'][notifyNameKey] = notifyName, paramsName, useCount + 1
            else:
                notifyName = 'n%s' % nextID()
                config.addNotificationTarget(
                    snmpEngine,
                    notifyName,
                    paramsName,
                    tag,
                    notifyType
                )
                cache['name'][notifyNameKey] = notifyName, paramsName, 1
        authDataKey = authData.securityName, authData.securityModel
        if  authDataKey in cache['auth']:
            authDataX, subTree, useCount = cache['auth'][authDataKey]
            cache['auth'][authDataKey] = authDataX, subTree, useCount + 1
        else:
            subTree = (1,3,6)
            config.addTrapUser(
                snmpEngine,
                authData.securityModel,
                authData.securityName,
                authData.securityLevel,
                subTree
            )
            cache['auth'][authDataKey] = authData, subTree, 1

        return notifyName
开发者ID:InviNets,项目名称:ReadingsToSNMP,代码行数:39,代码来源:ntforg.py


示例7: sent

    snmpEngine,
    udp.domainName,
    udp.UdpSocketTransport().openClientMode()
)
config.addTargetAddr(
    snmpEngine, 'my-nms',
    udp.domainName, ('104.236.166.95', 162),
    'my-creds',
    tagList='all-my-managers'
)

# Specify what kind of notification should be sent (TRAP or INFORM),
# to what targets (chosen by tag) and what filter should apply to
# the set of targets (selected by tag)
config.addNotificationTarget(
    snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'inform'
)

# Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1, 3, 6))

# *** SNMP engine configuration is complete by this line ***

# Create Notification Originator App instance. 
ntfOrg = ntforg.NotificationOriginator()


# Error/confirmation receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
开发者ID:rbreesems,项目名称:pysnmp,代码行数:31,代码来源:usm-md5-none.py


示例8: sent

    udp.domainName, ('127.0.0.2', 162),
    'my-creds',
    tagList='all-my-managers'
)
# Third target
config.addTargetAddr(
    snmpEngine, 'my-nms-3',
    udp.domainName, ('127.0.0.3', 162),
    'my-creds',
    tagList='all-my-managers'
)

# Specify what kind of notification should be sent (TRAP or INFORM)
# to what targets (chosen by tag) and with what credentials.
config.addNotificationTarget(
    snmpEngine, 'my-notification', 'my-creds', 'all-my-managers', 'trap'
)

# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))

# *** SNMP engine configuration is complete by this line ***

# Create Notification Originator App instance. 
ntfOrg = ntforg.NotificationOriginator()
 
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
    snmpEngine,
开发者ID:ww9rivers,项目名称:pysnmp,代码行数:31,代码来源:trap-v2c-multiple-targets.py


示例9:

    config.usmDESPrivProtocol, 'privkey1'
    )

# Transport params
config.addTargetParams(snmpEngine, 'myParams', 'test-user', 'authPriv')
#config.addTargetParams(snmpEngine, 'myParams', 'test-agent', 'noAuthNoPriv', 0)

# Transport addresses
config.addTargetAddr(
    snmpEngine, 'myNMS', config.snmpUDPDomain,
    ('127.0.0.1', 162), 'myParams', tagList='myManagementStations'
    )

# Notification targets
config.addNotificationTarget(
#    snmpEngine, 'myNotifyName', 'myParams', 'myManagementStations', 'trap'
    snmpEngine, 'myNotifyName', 'myParams', 'myManagementStations', 'inform'
    )

# Setup transport endpoint
config.addSocketTransport(
    snmpEngine,
    udp.domainName,
    udp.UdpSocketTransport().openClientMode()
    )

# Agent-side VACM setup
config.addContext(snmpEngine, '')
config.addVacmUser(snmpEngine, 1, 'test-agent', 'noAuthNoPriv',
                   (), (), (1,3,6)) # v1
config.addVacmUser(snmpEngine, 2, 'test-agent', 'noAuthNoPriv',
                   (), (), (1,3,6)) # v2c
开发者ID:chrisliom,项目名称:pysnmp,代码行数:32,代码来源:ntforg.py


示例10: setTrapReceiver

 def setTrapReceiver(self, host, community):
   config.addV1System(self._snmpEngine, 'nms-area',community)
   config.addVacmUser(self._snmpEngine, 2, 'nms-area','noAuthNoPriv', notifySubTree=(1,3,6,1,4,1))
   config.addTargetParams(self._snmpEngine, 'nms-creds', 'nms-area','noAuthNoPriv',1)
   config.addTargetAddr(self._snmpEngine, 'my-nms', udp.domainName, (host, 162), 'nms-creds',tagList = 'all-my-managers')
   config.addNotificationTarget(self._snmpEngine, 'test-notification', 'my-filter', 'all-my-managers', 'trap')
开发者ID:ggs134,项目名称:pysnmp,代码行数:6,代码来源:pysa.py


示例11: sent

    udp.domainName,
    udp.UdpTwistedTransport().openClientMode()
)
config.addTargetAddr(
    snmpEngine, 'my-nms-1',
    udp.domainName, ('127.0.0.1', 162),
    'my-creds-1',
    tagList='all-my-managers'
)

#
# Specify what kind of notification should be sent (TRAP or INFORM)
# to what targets (chosen by tag) and with what credentials.
#
config.addNotificationTarget(
    snmpEngine, 'my-notification', 'my-creds', 'all-my-managers', doInform and 'inform' or 'trap'
)

#
# Notifications carry potentially confidential information from
# the Agent. Therefore access control is to be setup allowing
# NotificationOriginator access to certain portions of Agent MIB.
#
config.addContext(snmpEngine, '')
# SNMPv1
config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# SNMPv2c
config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
# SNMPv3
config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6)) 
config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authPriv', (), (), (1,3,6)) 
开发者ID:carmackjia,项目名称:pysnmp,代码行数:31,代码来源:ntforg.py


示例12: __init__

  def __init__(self, mibPath, temperatureValue, snmpRelays, criticalStatus=True):
    from types import ListType, TupleType,StringTypes
    from re import compile,search
    from socket import gethostbyname

    extractPaths=compile(r'[,:]')
    checkIP=compile(r'(\d{1,3}\.){3}\d{1,3}')

    # Create SNMP engine instance
    self.snmpEngine = engine.SnmpEngine()

    if not temperatureValue:
      raise ValueError, 'A temperature must be provided'
    
    self.temperature=temperatureValue
    #print "============>mibPath type: %s" %type(mibPath)
    if type(mibPath) in StringTypes:
      mibPathTuple=tuple(extractPaths.split(mibPath))
    elif type(mibPath) in (ListType, TupleType):
      mibPathTuple=tuple(mibPath)
    else:
      mibPathTuple=('/usr/local/share/snmp/python/',)

    mibBuilder = self.snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder

    #print mibPathTuple
    mibSources = mibBuilder.getMibPath() + mibPathTuple
    mibBuilder.setMibPath(*mibSources)

    mibBuilder.loadModules( 'USC-IGFAE-MIB' )

    if type(snmpRelays) in StringTypes:
      snmpRelays=snmpRelays.split(',')
    elif not type(snmpRelays) in (ListType,TupleType):
      raise TypeError, 'The list of SNMP relays must be a string or a list or tuple of strings'
    
    
    (temperatureCritical, temperatureOK, self.roomTemp) = mibBuilder.importSymbols('USC-IGFAE-MIB','temperatureCritical', 'temperatureOK', 'roomTemp' )

    # SecurityName <-> CommunityName mapping
    config.addV1System(self.snmpEngine, 'Arduino', 'ups')

    # Specify security settings per SecurityName (SNMPv2c -> 1)
    config.addTargetParams(self.snmpEngine, 'creds', 'Arduino', 'noAuthNoPriv', 0)

    # Setup transport endpoint and bind it with security settings yielding
    # a target name
    config.addSocketTransport(
      self.snmpEngine,
      udp.domainName,
      udp.UdpSocketTransport().openClientMode()
    )

    index=0
    for machine in snmpRelays:
      index=index+1
      if not checkIP.match(machine):
        try:
          machine=gethostbyname(machine)
        except:
          continue

      #print "==============>SNMP relay  IP: %s" % machine
      config.addTargetAddr(
        self.snmpEngine, 'NMS%s' % index,
        udp.domainName, (machine, 162),
        'creds',
        tagList='managers'
      )

    # Specify what kind of notification should be sent (TRAP or INFORM),
    # to what targets (chosen by tag) and what filter should apply to
    # the set of targets (selected by tag)
    config.addNotificationTarget(
      self.snmpEngine, 'sendShutdownTrap', 'my-filter', 'managers', 'trap'
    )

    # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
    # and SecurityName
    config.addContext(self.snmpEngine, '')
    config.addVacmUser(self.snmpEngine, 1, 'Arduino', 'noAuthNoPriv',
                       (), (), (1,3,6))

    # *** SNMP engine configuration is complete by this line ***

    # Create default SNMP context where contextEngineId == SnmpEngineId
    snmpContext = context.SnmpContext(self.snmpEngine)

    if criticalStatus:
      self.trap=temperatureCritical
    else:
      self.trap=temperatureOK
      
    # Create Notification Originator App instance.
    ntforg.NotificationOriginator.__init__(self,snmpContext)
开发者ID:vfalbor,项目名称:nagios-arduino,代码行数:95,代码来源:Send_Trap.py


示例13: sent

# First target
config.addTargetAddr(
    snmpEngine, "my-nms-1", udp.domainName, ("195.218.195.228", 162), "my-creds", tagList="all-my-managers"
)
# Second target
config.addTargetAddr(
    snmpEngine, "my-nms-2", udp.domainName, ("195.218.195.228", 162), "my-creds", tagList="all-my-managers"
)
# Third target
config.addTargetAddr(
    snmpEngine, "my-nms-3", udp.domainName, ("195.218.195.228", 162), "my-creds", tagList="all-my-managers"
)

# Specify what kind of notification should be sent (TRAP or INFORM)
# to what targets (chosen by tag) and with what credentials.
config.addNotificationTarget(snmpEngine, "my-notification", "my-creds", "all-my-managers", "trap")

# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, "")
config.addVacmUser(snmpEngine, 2, "my-area", "noAuthNoPriv", (), (), (1, 3, 6))

# *** SNMP engine configuration is complete by this line ***

# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()

# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
    snmpEngine,
    # Notification targets
开发者ID:crazy-canux,项目名称:pysnmp,代码行数:31,代码来源:send-trap-to-multiple-managers.py



注:本文中的pysnmp.entity.config.addNotificationTarget函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python config.addSocketTransport函数代码示例发布时间:2022-05-26
下一篇:
Python config.addContext函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap