Ejemplo n.º 1
0
 def handle(self):
     """Collects sysObjectID and looks for type changes."""
     self._logger.debug("Collecting sysObjectId")
     self.snmpv2_mib = Snmpv2Mib(self.agent)
     df = self.snmpv2_mib.get_sysObjectID()
     df.addCallback(self._response_handler)
     return df
Ejemplo n.º 2
0
def get_dot1d_instances(agentproxy):
    """
    Gets a list of alternative BRIDGE-MIB instances from a Cisco or Aruba
    agent.

    First

    :returns: A list of [(description, community), ...] for each alternate
              BRIDGE-MIB instance.

    """
    from nav.mibs.snmpv2_mib import Snmpv2Mib
    from nav.mibs.cisco_vtp_mib import CiscoVTPMib
    from nav.mibs.entity_mib import EntityMib

    enterprise_id = yield (Snmpv2Mib(agentproxy).get_sysObjectID().
                           addCallback(get_enterprise_id))
    if enterprise_id == VENDOR_ID_CISCOSYSTEMS:
        mibclasses = [EntityMib, CiscoVTPMib]
        modifier = lambda x: x
    elif enterprise_id == VENDOR_ID_ARUBA_NETWORKS_INC:
        mibclasses = [EntityMib]
        modifier = _workaround_broken_aruba_alternate_communities
    else:
        mibclasses = []

    for mibclass in mibclasses:
        mib = mibclass(agentproxy)
        instances = yield mib.retrieve_alternate_bridge_mibs()
        if instances:
            defer.returnValue(modifier(instances))

    defer.returnValue([])
Ejemplo n.º 3
0
 def __init__(self, agent, containers, var_name):
     # pylint: disable=W0104
     self._logger
     self.agent = agent
     self.snmpv2mib = Snmpv2Mib(agent)
     self.containers = containers
     self.var_name = var_name
     self.collected_times = None
     self.loaded_times = None
Ejemplo n.º 4
0
 def handle(self):
     snmpv2_mib = Snmpv2Mib(self.agent)
     sysdescr = yield snmpv2_mib.get_sysDescr()
     if sysdescr:
         self._logger.debug("sysDescr: %r", sysdescr)
         version = parse_version(sysdescr)
         self._logger.debug("Parsed version: %s", version)
         if version:
             self._set_device_version(version)
Ejemplo n.º 5
0
    def _collect_sysuptime(self):
        mib = Snmpv2Mib(self.agent)
        uptime = yield mib.get_sysUpTime()
        timestamp = time.time()

        if uptime:
            path = metric_path_for_sysuptime(self.netbox)
            defer.returnValue([(path, (timestamp, uptime))])
        else:
            defer.returnValue([])
Ejemplo n.º 6
0
    def _collect_sysuptime(self, netboxes):
        mib = Snmpv2Mib(self.agent)
        uptime = yield mib.get_sysUpTime()
        timestamp = time.time()

        if uptime:
            metrics = []
            for netbox in netboxes:
                path = metric_path_for_sysuptime(netbox)
                metrics.append((path, (timestamp, uptime)))
            defer.returnValue(metrics)
        else:
            defer.returnValue([])
Ejemplo n.º 7
0
    def mibfactory(self):
        """
        Returns a list of MibRetriever instances, as configured in
        ipdevpoll.conf, to use for retrieving sensors from this netbox.

        """
        vendor_id = None

        snmpv2_mib = Snmpv2Mib(self.agent)
        sysobjectid = yield snmpv2_mib.get_sysObjectID()
        if sysobjectid:
            vendor_id = get_enterprise_id(sysobjectid)
        elif self.netbox.type:
            vendor_id = self.netbox.type.get_enterprise_id()

        classes = self.mib_map.get(vendor_id, ()) or self.mib_map.get('*', ())
        mibs = [cls(self.agent) for cls in classes]
        defer.returnValue(mibs)
Ejemplo n.º 8
0
def get_dot1d_instances(agentproxy):
    """Gets a list of alternative BRIDGE-MIB instances from a Cisco agent.

    First

    :returns: A list of [(description, community), ...] for each alternate
              BRIDGE-MIB instance.

    """
    from nav.mibs.snmpv2_mib import Snmpv2Mib
    from nav.mibs.cisco_vtp_mib import CiscoVTPMib
    from nav.mibs.entity_mib import EntityMib

    cisco = 9
    enterprise_id = yield (
        Snmpv2Mib(agentproxy).get_sysObjectID().addCallback(get_enterprise_id))
    if enterprise_id == cisco:
        for mibclass in (EntityMib, CiscoVTPMib):
            mib = mibclass(agentproxy)
            instances = yield mib.retrieve_alternate_bridge_mibs()
            if instances:
                defer.returnValue(instances)
    defer.returnValue([])
Ejemplo n.º 9
0
 def test_none_uptime_should_not_crash(self):
     uptime1 = (0, None)
     uptime2 = (10, 10)
     dev = Snmpv2Mib.get_uptime_deviation(uptime1, uptime2)
     self.assertIsNone(dev)
Ejemplo n.º 10
0
 def test_wrapped_uptime_deviation_should_be_correct(self):
     first_uptime =  (1338372778.0, 4294967196L)
     second_uptime = (1338372900.0, 12100L)
     dev = Snmpv2Mib.get_uptime_deviation(first_uptime, second_uptime)
     self.assertTrue(abs(dev) < 0.5,
                     msg="deviation is higher than 0.5: %r" % dev)
Ejemplo n.º 11
0
 def test_simple_uptime_deviation_should_be_correct(self):
     first_uptime = (1338372778.0, 10000)
     second_uptime = (1338372900.0, 22200)
     dev = Snmpv2Mib.get_uptime_deviation(first_uptime, second_uptime)
     assert abs(dev) < 0.5, "deviation is higher than 0.5: %r" % dev
Ejemplo n.º 12
0
 def test_wrapped_uptime_deviation_should_be_correct(self):
     first_uptime =  (1338372778.0, 4294967196L)
     second_uptime = (1338372900.0, 12100L)
     dev = Snmpv2Mib.get_uptime_deviation(first_uptime, second_uptime)
     self.assertTrue(abs(dev) < 0.5,
                     msg="deviation is higher than 0.5: %r" % dev)
Ejemplo n.º 13
0
 def __init__(self, *args, **kwargs):
     super(TypeOid, self).__init__(*args, **kwargs)
     self.snmpv2_mib = Snmpv2Mib(self.agent)
     self.sysobjectid = None