Esempio n. 1
0
def declared_hostinfo(monkeypatch, request):
    data = [[
        ObjectName('.1.3.6.1.2.1.1.2.0'),
        ObjectIdentifier(request.param['sysobjectid'])
    ],
            [
                ObjectName('.1.3.6.1.2.1.1.1.0'),
                OctetString(request.param['description'])
            ]]
    get_oids = request.param.get('get_oids')
    if get_oids:
        for entry in get_oids:
            data.append([
                ObjectName(get_oids[entry]['oid']),
                OctetString(get_oids[entry]['value'])
            ])

    if 'walk_oids' in request.param.keys():
        get_next_return = []
        for extra_oid in request.param['walk_oids']:
            get_next_return.append([
                ObjectName('.' + request.param['walk_oids'][extra_oid]['oid']),
                OctetString(request.param['walk_oids'][extra_oid]['value'])
            ])
        walk_data = [get_next_return]
    else:
        walk_data = None
    return GetCmd(monkeypatch,
                  return_value=data,
                  walk_data=walk_data,
                  params=request.param)
Esempio n. 2
0
def declared_hostinfo(monkeypatch):
    data = [
        [ObjectName('.1.3.6.1.2.1.1.1.0'),
         OctetString('Cisco Adaptive Security Appliance Version 9.3(2)2')],
        [ObjectName('.1.3.6.1.2.1.1.2.0'),
         ObjectIdentifier('1.3.6.1.4.1.9.1.2114')],
        [ObjectName('.1.3.6.1.2.1.1.3.0'),
         OctetString('replace with uptime')],
        [ObjectName('.1.3.6.1.2.1.1.4.0'),
         OctetString('Networklore')],
        [ObjectName('.1.3.6.1.2.1.1.6.0'),
         OctetString('Westeros')],
    ]
    return GetCmd(monkeypatch, return_value=data)
Esempio n. 3
0
    def test_extract_policy_indexes():
        table = [[(ObjectName('1.3.6.1.4.1.9.9.166.1.2.1.1.1.155.1'),
                   Gauge32(1654707672))],
                 [(ObjectName('1.3.6.1.4.1.9.9.166.1.2.1.1.1.155.2'),
                   Gauge32(996352128))]]

        expected = {
            '996352128': PolicyIndex('155', 'out'),
            '1654707672': PolicyIndex('155', 'in')
        }

        actual = qos.extract_policy_interface_indexes(table)

        assert_that(actual, has_entries(expected))
Esempio n. 4
0
 def _get_snmpdata(self, *snmp_data):
     if self.return_value:
         return self.return_value
     else:
         for snmp in snmp_data:
             dat = snmp
         snmpdata = [[ObjectName('1.1'), OctetString(dat)]]
         return snmpdata
Esempio n. 5
0
    def test_group_key_object_name(self):
        mock1 = Mock()

        mock1._value = ObjectName("1.2.3.4.5")

        index = [mock1]
        key = get_group_key("some-mib", "1.2.3.4.5", index)
        self.assertEqual("some-mib::ObjectName=1.2.3.4.5", key)
Esempio n. 6
0
    def dispatch(self, event):
        hostname = self._device_requester.get_nagios_hostname(event.ipaddr)
        traps = self._device_requester.get_trap_settings(event.ipaddr)

        trap_valid = False
        for trap in traps:
            if event.name == trap['name']:
                if 'oid' in trap:
                    oid = ObjectName(trap['oid'])
                    if str(event.arguments[oid]) == str(trap['value']):
                        trap_valid = True
                        break
                else:
                    trap_valid = True
                    break

        if not trap_valid:
            log.error('TrapEventDispatcher: Trap is not valid %s' % event.to_json())
            return

        command = self._config['dispatcher']['command']
        command_exists = os.path.isfile(command)
        if not command_exists:
            log.error('TrapEventDispatcher: Dispatcher command does not exist.')
            return False

        success = len(event.handlers) > 0

        for handler in event.handlers:
            output_dict = {
                'nagios_status': event.status,
                'output': event.output,
                'type': event.type
            }

            output = '!' + json.dumps(output_dict)

            log.debug('TrapEventDispatcher: command called %s %s %s %s %s' % (command,
                                                                              hostname,
                                                                              handler,
                                                                              str(event.status),
                                                                              output))

            ret = call([command, hostname, handler, str(event.status), output])

            print(event.to_json())
            log.debug('TrapEventDispatcher: Message has been sent to nagios (%s).' % hostname)
            success = ret == 0

        return success
Esempio n. 7
0
    def _fan(self, command):
        """ Synse API fan command implementation for the TestDevice1 SNMP
        server.

        Args:
            command (Command): the command issued by the Synse endpoint
                containing the data and sequence for the request.

        Returns:
            Response: a Response object for the incoming Command object
                containing the data for the fan response.
        """
        logger.debug('TestDevice1 _fan')
        logger.debug('vars(command) {}'.format(vars(command)))

        # Find the device to write.
        device = self.get_device_from_command(command)
        base_oid = device['snmp_row'][
            'base_oid']  # base_oid of the row we need to write.
        table_name = device['snmp_row']['table_name']  # Which table to write

        if table_name != 'Synse-TestDevice1-Fan-Table':
            raise CommandNotSupported(
                'Fan command not supported on this device.')

        # The index of the oid we need to write is the index of rpm in the
        # table + 1 because SNMP is one based and not zero based.
        write_index = self.fan_table.column_list.index('rpm') + 1
        # The OID we need to write is below.
        write_oid = base_oid.format(write_index)
        logger.debug('write_oid {}'.format(write_oid))

        # SNMP write as a tuple of (OID, data).
        # data needs to be converted to the correct SNMP type.
        fan_speed = Integer(int(command.data['fan_speed']))
        data = (ObjectName(write_oid), fan_speed)
        result = self.snmp_client.set(data)

        # Result[1] is the written fan_speed.
        written = int(result[1])
        logger.debug('written {}'.format(written))

        # Update table data. Generate and return response.
        self.fan_table.update_cell(base_oid, write_index, written)
        response_data = {'health': 'ok', 'states': [], 'speed_rpm': written}

        return Response(command=command, response_data=response_data)
Esempio n. 8
0
    def snmp_set(self, write_oid, data):
        """ Write to the SNMP server.

        Args:
            write_oid (str): the SNMP OID to write to.
            data: the data to write. data needs to be converted to the correct
                SNMP type by the caller.

        Returns:
            the written data in result[1].
        """
        logger.debug('_snmp_set write_oid, data: {}, {}'.format(
            write_oid, data))
        # SNMP write as a tuple of (OID, data).
        power_state = data
        data = (ObjectName(write_oid), power_state)
        result = self.snmp_client.set(data)
        return result
Esempio n. 9
0
    def bulk_walk(self,
                  host,
                  community,
                  str_oid,
                  port=DEFAULT_PORT,
                  timeout=DEFAULT_TIMEOUT,
                  retries=DEFAULT_RETRIES,
                  non_repeaters=0,
                  max_repetitions=50):
        cmd_oid = self.__convert_to_pysnmp_oid_format(str_oid)
        try:
            # timeout and retries are optional=> Just detect that the pysnmp fails, do not use them
            err_indication, err_status, err_index, var_binds = cmdgen.CommandGenerator(
            ).bulkCmd(
                cmdgen.CommunityData('my-agent', community),
                cmdgen.UdpTransportTarget((host, port),
                                          timeout=timeout,
                                          retries=retries), non_repeaters,
                max_repetitions, ObjectName(cmd_oid))

            gc.collect()

            if err_indication:
                raise exceptions.SNMPLevelError(msg="SNMP error %s - %s" %
                                                (host, err_indication))
            if err_status:
                raise exceptions.SNMPLevelError(
                    msg="SNMP PDU-level error %s status %s at %s" %
                    (host, err_status, err_index))

            result = []
            for snmp_value in var_binds:
                snmp_value = snmp_value[0]
                oid, value = self.__extract_oid_and_value_from_varbind(
                    snmp_value)
                if self.__is_suboid(oid, str_oid) and value.is_valid():
                    result.append((oid, value))
            return tuple(result)
        except socket.error as exc:
            raise exceptions.SNMPSocketError(exc)
Esempio n. 10
0
 def test_extract_classmaps():
     table = [[(ObjectName('1.3.6.1.4.1.9.9.166.1.7.1.1.1.748129779'),
                OctetString('cs6'))],
              [(ObjectName('1.3.6.1.4.1.9.9.166.1.7.1.1.1.1201419584'),
                OctetString('af4'))],
              [(ObjectName('1.3.6.1.4.1.9.9.166.1.7.1.1.1.1201419589'),
                OctetString('af1'))],
              [(ObjectName('1.3.6.1.4.1.9.9.166.1.7.1.1.1.1201419590'),
                OctetString('af2'))],
              [(ObjectName('1.3.6.1.4.1.9.9.166.1.7.1.1.1.1819748200'),
                OctetString('ef'))],
              [(ObjectName('1.3.6.1.4.1.9.9.166.1.7.1.1.1.1965376995'),
                OctetString('class-default'))]]
     class_maps = qos.extract_classmaps(table)
     expected = {
         '748129779': 'cs6',
         '1201419589': 'af1',
         '1201419584': 'af4',
         '1201419590': 'af2',
         '1965376995': 'class-default',
         '1819748200': 'ef'
     }
     assert_that(class_maps, has_entries(expected))
Esempio n. 11
0
    def test_extract_cm_stats_table():
        table = [[
            (ObjectName('1.3.6.1.4.1.9.9.166.1.15.1.1.7.996352128.759637879'),
             Gauge32(193536)),
            (ObjectName(
                '1.3.6.1.4.1.9.9.166.1.15.1.1.7.1654707672.1924233547'),
             Gauge32(1580032)),
            (ObjectName('1.3.6.1.4.1.9.9.166.1.15.1.1.11.996352128.759637879'),
             Gauge32(0)),
            (ObjectName(
                '1.3.6.1.4.1.9.9.166.1.15.1.1.11.1654707672.1924233547'),
             Gauge32(0)),
            (ObjectName('1.3.6.1.4.1.9.9.166.1.15.1.1.18.996352128.759637879'),
             Gauge32(0)),
            (ObjectName(
                '1.3.6.1.4.1.9.9.166.1.15.1.1.18.1654707672.1924233547'),
             Gauge32(153600))
        ]]

        expected = [('996352128', '759637879'), ('1654707672', '1924233547'),
                    ('996352128', '759637879'), ('1654707672', '1924233547'),
                    ('996352128', '759637879'), ('1654707672', '1924233547')]
        actual = qos.extract_classmap_stats(table)
        assert_that(actual, contains_inanyorder(*expected))
Esempio n. 12
0
 def setUp(self):
     self.oids = {ObjectName('1.2.3.4'): OctetString('eth0')}
Esempio n. 13
0
class OID:

    sysName = ObjectName("1.3.6.1.2.1.1.5.0")
    sysDescr = ObjectName("1.3.6.1.2.1.1.1.0")
    sysUpTimeInstance = ObjectName("1.3.6.1.2.1.1.3.0")
    sysContact = ObjectName("1.3.6.1.2.1.1.4.0")
    sysLocation = ObjectName("1.3.6.1.2.1.1.6.0")

    dot1dBaseNumPorts = ObjectName("1.3.6.1.2.1.17.1.2.0")
    dot1dBasePortIfIndex = ObjectName("1.3.6.1.2.1.17.1.4.1.2")

    dot1dTpFdbAddress = ObjectName("1.3.6.1.2.1.17.4.3.1.1")
    dot1dTpFdbPort = ObjectName("1.3.6.1.2.1.17.4.3.1.2")
    dot1dTpFdbStatus = ObjectName("1.3.6.1.2.1.17.4.3.1.3")

    ifAdminStatus = ObjectName("1.3.6.1.2.1.2.2.1.7")
    ifOperStatus = ObjectName("1.3.6.1.2.1.2.2.1.8")
    ifDescr = ObjectName("1.3.6.1.2.1.2.2.1.2")
    ifIndex = ObjectName("1.3.6.1.2.1.2.2.1.1")
    ifType = ObjectName("1.3.6.1.2.1.2.2.1.3")
    ifAlias = ObjectName("1.3.6.1.2.1.31.1.1.1.18")

    ifName = ObjectName("1.3.6.1.2.1.31.1.1.1.1")
    ifStackStatus = ObjectName("1.3.6.1.2.1.31.1.2.1.3")
    ifInOctects = ObjectName("1.3.6.1.2.1.2.2.1.10")
    ifInUcastPkts = ObjectName("1.3.6.1.2.1.2.2.1.11")
    ifOutUcastPkts = ObjectName("1.3.6.1.2.1.2.2.1.17")
    ifSpeed = ObjectName("1.3.6.1.2.1.2.2.1.5")

    dot1qTpFdbEntry = ObjectName("1.3.6.1.2.1.17.7.1.2.2.1")
    dot1qTpFdbPort = ObjectName("1.3.6.1.2.1.17.7.1.2.2.1.2")
    dot1qTpFdbStatus = ObjectName("1.3.6.1.2.1.17.7.1.2.2.1.3")

    dot1qVlanStaticEntry = ObjectName(
        "1.3.6.1.2.1.17.7.1.4.3.1")  # Dot1qVlanStaticEntry
    dot1qVlanStaticName = ObjectName("1.3.6.1.2.1.17.7.1.4.3.1.1")
    dot1qVlanFdbId = ObjectName("1.3.6.1.2.1.17.7.1.4.2.1.3")
    dot1qVlanStaticEgressPorts = ObjectName(
        "1.3.6.1.2.1.17.7.1.4.3.1.2")  # portlist
    dot1qVlanForbiddenEgressPorts = ObjectName(
        "1.3.6.1.2.1.17.7.1.4.3.1.3")  # portlist
    dot1qVlanStaticUntaggedPorts = ObjectName(
        "1.3.6.1.2.1.17.7.1.4.3.1.4")  # portlist
    dot1qVlanStaticRowStatus = ObjectName(
        "1.3.6.1.2.1.17.7.1.4.3.1.5"
    )  #    RowStatus 1:active, 2:notInService, 3:notReady, 4:createAndGo, 5:createAndWait, 6:destroy
    dot1qPvid = ObjectName("1.3.6.1.2.1.17.7.1.4.5.1.1")

    linksysGeneralPortAccess = ObjectName("1.3.6.1.4.1.89.48.22.1.1")

    force10chSysCardUpperTemp = ObjectName("1.3.6.1.4.1.6027.3.1.1.2.3.1.8")
    force10chSerialNumber = ObjectName("1.3.6.1.4.1.6027.3.1.1.1.2.0")

    # 4526.1.2.13.1.1.1.<vlan id> = i <vlan id>
    # 4526.1.2.13.1.1.2.<vlan id> = s <vlan name>
    # 4526.1.2.13.1.1.3.<vlan id> = i <active 1 ? >
    netgearVlanStaticId = ObjectName("1.3.6.1.4.1.4516.1.2.13.1.1.1")
    netgearVlanStaticName = ObjectName("1.3.6.1.4.1.4526.1.2.13.1.1.2")
    netgearVlanStaticRowStatus = ObjectName(
        "1.3.6.1.4.1.4526.1.2.13.1.1.3"
    )  # i 6 destroy, i 1 active , 5 create (and wait ? ) 4 works too
    # pvid 1.3.6.1.4.1.4526.1.2.11.6.1.12.<pid> i <vlan id>
    netgearGeneralPortAccess = ObjectName("1.3.6.1.4.1.4526.1.2.11.6.1.12")
    # port member
    #4526.1.2.13.2.1.1.<pid>.<vlan id> = i <pid>
    #4526.1.2.13.2.1.2.<pid>.<vlan id> = i <vlan id>
    #4526.1.2.13.2.1.3.<pid>.<vlan id> = i 1
    #4526.1.2.13.2.1.4.<pid>.<vlan id> = i <tagged = 2, untagged = 1>
    netgearVlanTaggedTable = ObjectName("1.3.6.1.4.1.4526.1.2.13.2.1")
    netgearVlanTaggedPortId = ObjectName("1.3.6.1.4.1.4526.1.2.13.2.1.1")
    netgearVlanTaggedVlanId = ObjectName("1.3.6.1.4.1.4526.1.2.13.2.1.2")
    # guess work about this row
    netgearVlanTaggedRowStatus = ObjectName("1.3.6.1.4.1.4526.1.2.13.2.1.3")
    netgearVlanTaggedType = ObjectName("1.3.6.1.4.1.4526.1.2.13.2.1.4")

    ciscoVtpVlanState = ObjectName("1.3.6.1.4.1.9.9.46.1.3.1.1.2")
    ciscoVtpVlanEditTable = ObjectName("1.3.6.1.4.1.9.9.46.1.4.2")
    ciscoVtpVlanEditOperation = ObjectName("1.3.6.1.4.1.9.9.46.1.4.1.1.1")  #.1
    ciscoVtpVlanEditBufferOwner = ObjectName(
        "1.3.6.1.4.1.9.9.46.1.4.1.1.3")  # .1
    ciscoVtpVlanEditRowStatus = ObjectName(
        "1.3.6.1.4.1.9.9.46.1.4.2.1.11")  #.1.<vlan id>
    ciscoVtpVlanEditType = ObjectName(
        "1.3.6.1.4.1.9.9.46.1.4.2.1.3")  #.1.<vlan id>
    ciscoVtpVlanEditName = ObjectName(
        "1.3.6.1.4.1.9.9.46.1.4.2.1.4")  #.1.<vlan id>
    ciscoVtpVlanEditDot10Said = ObjectName(
        " 1.3.6.1.4.1.9.9.46.1.4.2.1.6")  #.1.<vlan id>
    ciscoVtpVlanType = ObjectName("1.3.6.1.4.1.9.9.46.1.3.1.1.3")
    ciscoVtpVlanName = ObjectName("1.3.6.1.4.1.9.9.46.1.3.1.1.4")
    ciscoVtpVlanifIndex = ObjectName("1.3.6.1.4.1.9.9.46.1.3.1.1.18")
    ciscoVmVlan = ObjectName("1.3.6.1.4.1.9.9.68.1.2.2.1.2")
    ciscoVmMembershipSummaryMemberPorts = ObjectName(
        "1.3.6.1.4.1.9.9.68.1.2.1.1.2")

    ciscoVlanTrunkPortEncapsulationType = ObjectName(
        "1.3.6.1.4.1.9.9.46.1.6.1.1.3")
    ciscoVlanTrunkPortVlansEnabled = ObjectName("1.3.6.1.4.1.9.9.46.1.6.1.1.4")
    ciscoVlanTrunkPortVlansPruningEligible = ObjectName(
        "1.3.6.1.4.1.9.9.46.1.6.1.1.10")

    extremeVlanStaticName = ObjectName("1.3.6.1.4.1.1916.1.2.1.2.1.2")
    extremeVlanStaticType = ObjectName("1.3.6.1.4.1.1916.1.2.1.2.1.3")
    extremeVlanStaticExternalID = ObjectName("1.3.6.1.4.1.1916.1.2.1.2.1.4")
    extremeVlanStaticRowStatus = ObjectName("1.3.6.1.4.1.1916.1.2.1.2.1.6")
    extremeVlanNextAvailableIndex = ObjectName("1.3.6.1.4.1.1916.1.2.2.1.0")
    extremeVlanTaggedType = ObjectName("1.3.6.1.4.1.1916.1.2.3.1.1.2")
    extremeVlanTaggedTag = ObjectName("1.3.6.1.4.1.1916.1.2.3.1.1.3")
    extremeVlanTaggedRowStatus = ObjectName("1.3.6.1.4.1.1916.1.2.3.1.1.4")
    extremeOverTemperatureAlarm = ObjectName("1.3.6.1.4.1.1916.1.1.1.7.0")
    extremeCurrentTemperature = ObjectName("1.3.6.1.4.1.1916.1.1.1.8.0")
    extremeFanStatusTable = ObjectName("1.3.6.1.4.1.1916.1.1.1.9.1.2")
    extremeSystemID = ObjectName("1.3.6.1.4.1.1916.1.1.1.18.0")

    threecomVlanStaticName = ObjectName("1.3.6.1.4.1.43.10.1.14.1.2.1.2")
    threecomVlanStaticType = ObjectName("1.3.6.1.4.1.43.10.1.14.1.2.1.3")
    threecomVlanStaticExternalID = ObjectName("1.3.6.1.4.1.43.10.1.14.1.2.1.4")
    threecomVlanStaticRowStatus = ObjectName("1.3.6.1.4.1.43.10.1.14.1.2.1.6")
    threecomVlanNextAvailableIndex = ObjectName("1.3.6.1.4.1.43.10.1.14.3.1.0")
    threecomVlanTaggedType = ObjectName("1.3.6.1.4.1.43.10.1.14.4.1.1.2")
    threecomVlanTaggedTag = ObjectName("1.3.6.1.4.1.43.10.1.14.4.1.1.3")
    threecomVlanTaggedRowStatus = ObjectName("1.3.6.1.4.1.43.10.1.14.4.1.1.4")
    threecomStackUnitSerialNumber = ObjectName(
        "1.3.6.1.4.1.43.10.27.1.1.1.13.1")

    hpPoeTable = ObjectName("1.3.6.1.2.1.105.1.1.1.3.1")
    hpPoeDeliveringStatusTable = ObjectName("1.3.6.1.2.1.105.1.1.1.6.1")
    hpPoePowerPriorityTable = ObjectName("1.3.6.1.2.1.105.1.1.1.7.1")
    hpPoeOverloadCounterTable = ObjectName("1.3.6.1.2.1.105.1.1.1.13.1")
    hpPoeNominalPower = ObjectName("1.3.6.1.2.1.105.1.3.1.1.2.1")
    hpPoeOperationalStatus = ObjectName("1.3.6.1.2.1.105.1.3.1.1.3.1")
    hpPoePowerConsumption = ObjectName("1.3.6.1.2.1.105.1.3.1.1.4.1")

    apcSerialNumber = ObjectName("1.3.6.1.4.1.318.1.1.12.1.6.0")
    apcCurrent = ObjectName("1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1")
    apcControl = ObjectName("1.3.6.1.4.1.318.1.1.12.3.3.1.1.4")
    apcStatus = ObjectName("1.3.6.1.4.1.318.1.1.12.3.5.1.1.4")

    sensatronicsProbe = ObjectName("1.3.6.1.4.1.16174.1.1.1.3")
Esempio n. 14
0
    def test_create_snmpif_splunk_event():
        var_binds = [
            (ObjectName('1.3.6.1.2.1.2.2.1.1.86'), Gauge32(86)),
            (ObjectName('1.3.6.1.2.1.2.2.1.2.86'),
             OctetString('Bundle-Ether1')),
            (ObjectName('1.3.6.1.2.1.2.2.1.3.86'),
             OctetString('ieee8023adLag')),
            (ObjectName('1.3.6.1.2.1.2.2.1.4.86'), Integer32(1514)),
            (ObjectName('1.3.6.1.2.1.2.2.1.5.86'), Gauge32(4294967295)),
            (ObjectName('1.3.6.1.2.1.2.2.1.6.86'),
             OctetString('a8:0c:0d:6d:bd:7b')),
            (ObjectName('1.3.6.1.2.1.2.2.1.7.86'), OctetString('up')),
            (ObjectName('1.3.6.1.2.1.2.2.1.8.86'), OctetString('up')),
            (ObjectName('1.3.6.1.2.1.2.2.1.9.86'), TimeTicks(845466098)),
            (ObjectName('1.3.6.1.2.1.2.2.1.10.86'), Counter32(2876455120)),
            (ObjectName('1.3.6.1.2.1.2.2.1.11.86'), Counter32(3400599021)),
            (ObjectName('1.3.6.1.2.1.2.2.1.12.86'), NoSuchInstance()),
            (ObjectName('1.3.6.1.2.1.2.2.1.13.86'), Counter32(0)),
            (ObjectName('1.3.6.1.2.1.2.2.1.14.86'), Counter32(0)),
            (ObjectName('1.3.6.1.2.1.2.2.1.15.86'), Counter32(17)),
            (ObjectName('1.3.6.1.2.1.2.2.1.16.86'), Counter32(3388716632)),
            (ObjectName('1.3.6.1.2.1.2.2.1.17.86'), Counter32(910069109)),
            (ObjectName('1.3.6.1.2.1.2.2.1.18.86'), NoSuchInstance()),
            (ObjectName('1.3.6.1.2.1.2.2.1.19.86'), Counter32(0)),
            (ObjectName('1.3.6.1.2.1.2.2.1.20.86'), Counter32(0)),
            (ObjectName('1.3.6.1.2.1.2.2.1.21.86'), NoSuchInstance()),
            (ObjectName('1.3.6.1.2.1.2.2.1.22.86'), NoSuchInstance()),
            (ObjectName('1.3.6.1.2.1.31.1.1.1.6.86'),
             Counter64(10834783975632)),
            (ObjectName('1.3.6.1.2.1.31.1.1.1.7.86'), Counter64(7695566317)),
            (ObjectName('1.3.6.1.2.1.31.1.1.1.10.86'),
             Counter64(2889606739544)),
            (ObjectName('1.3.6.1.2.1.31.1.1.1.11.86'), Counter64(9500003701))
        ]
        expected = 'ifIndex=86 ifDescr="Bundle-Ether1" ifType=ieee8023adLag ifMtu=1514 ifSpeed=4294967295 ifPhysAddress="a8:0c:0d:6d:bd:7b" ifAdminStatus=up ifOperStatus=up ifLastChange=845466098 ifInOctets=2876455120 ifInUcastPkts=3400599021 ifInDiscards=0 ifInErrors=0 ifInUnknownProtos=17 ifOutOctets=3388716632 ifOutUcastPkts=910069109 ifOutDiscards=0 ifOutErrors=0 ifHCInOctets=10834783975632 ifHCInUcastPkts=7695566317 ifHCOutOctets=2889606739544 ifHCOutUcastPkts=9500003701'
        actual = snmpif.create_snmpif_splunk_event(var_binds)

        assert_that(actual, ends_with(expected))
Esempio n. 15
0
 def mynextcmd(*junk, **lookupMib):
     return None, None, None, [[[ObjectName('1.1'), OctetString('b')]]]
Esempio n. 16
0
def sysobject(monkeypatch):
    data = [[ObjectName('.1.3.6.1.2.1.1.2.0'), ObjectIdentifier('1.3.6.1.4.1.9.1')]]
    return GetCmd(monkeypatch, return_value=data)
Esempio n. 17
0
 def createOidObject(self, name):
     oid = self.mapping[name]
     return ObjectName(oid)
Esempio n. 18
0
from nelsnmp.snmp import SnmpHandler
from pysnmp.proto.rfc1902 import (
    Counter32,
    Counter64,
    Gauge32,
    Integer,
    Integer32,
    IpAddress,
    ObjectName,
    OctetString,
    TimeTicks,
    Unsigned32,
)

data = []
data.append([ObjectName('.1.'), Counter32('100'), 100])
data.append([ObjectName('.1.'), Counter64('100'), 100])
data.append([ObjectName('.1.'), Gauge32('100'), 100])
data.append([ObjectName('.1.'), Integer('100'), 100])
data.append([ObjectName('.1.'), Integer32('100'), 100])
data.append([ObjectName('.1.'), IpAddress('192.168.1.1'), '192.168.1.1'])
data.append([ObjectName('.1.'), ObjectIdentifier('1'), '1'])
data.append([ObjectName('.1.'), OctetString('my_string'), 'my_string'])
data.append([ObjectName('.1.'), Unsigned32('100'), 100])


@pytest.fixture(scope='function', params=data)
def query_data(monkeypatch, request):
    snmp_data = [[request.param[0], request.param[1]]]
    return GetCmdValues(monkeypatch,
                        return_value=snmp_data,
Esempio n. 19
0
                           backupCount=10)

hdlr.setFormatter(fmt)
logger.addHandler(hdlr)

#===============================================================================
#  Configure
# Usage:
#  add  a rule in Rules
#  add  a dispatch in Dispatchers
#===============================================================================

Rules = [
    {
        'host': '10.137.130.129',
        'trap_oid': ObjectName('1.3.6.1.4.1.2011.5.25.191.3.1')
    },
]
Dispatchers = [
    {
        'target': 'http://10.135.34.246:9000/channels/2/data'
    },
]

#Current ��SNMP�Ŀɿ��Ժ�HTTP POST�ɿ���δ���ǣ�������


#===============================================================================
#  Match Rules:which data to which ...
#===============================================================================
class Rules(object):
Esempio n. 20
0
import copy
from oslo_config import cfg

from pysnmp.proto.rfc1902 import Integer
from pysnmp.proto.rfc1902 import ObjectIdentifier
from pysnmp.proto.rfc1902 import ObjectName
from pysnmp.proto.rfc1902 import OctetString
from pysnmp.proto.rfc1902 import TimeTicks

from vitrage.snmp_parsing.service import SnmpParsingService
from vitrage.tests import base


BINDS_REPORTED = [
    (ObjectName('1.3.6.1.2.1.1.3.0'), TimeTicks(1491462248)),
    (ObjectName('1.3.6.1.6.3.1.1.4.1.0'),
     ObjectIdentifier('1.3.6.1.4.1.3902.4101.1.4.1.2')),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.3'),
     OctetString(hexValue='07e10406070408002b0800')),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.1.2'), Integer(0)),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.1.4'), Integer(0)),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.1.3'), OctetString('')),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.11'), OctetString('3305115653')),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.2'), OctetString('host')),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.4'), Integer(1)),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.5'), Integer(14)),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.6'), Integer(0)),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.7'), OctetString('')),
    (ObjectName('1.3.6.1.4.1.3902.4101.1.3.1.8'),
     OctetString('vimid=,hid=controller_controller,'
Esempio n. 21
0
def declared_hostinfo_unknown_vendor(monkeypatch):
    data = [
        [ObjectName('.1.3.6.1.2.1.1.2.0'),
         ObjectIdentifier('1.3.6.1.4.1.1234567.1.2114')]
    ]
    return GetCmd(monkeypatch, return_value=data)