コード例 #1
0
                    help='Graphite host')
args = parser.parse_args()

bulk_oids = [
    'CISCO-CLASS-BASED-QOS-MIB::cbQosCMName',
    'CISCO-CLASS-BASED-QOS-MIB::cbQosPolicyMapName',
    'CISCO-CLASS-BASED-QOS-MIB::cbQosIfIndex',
    'CISCO-CLASS-BASED-QOS-MIB::cbQosCMDropByte',
    'CISCO-CLASS-BASED-QOS-MIB::cbQosCMPrePolicyByte',
    'CISCO-CLASS-BASED-QOS-MIB::cbQosCMPostPolicyByte'
]
QOS_IFTYPE_OID = 'CISCO-CLASS-BASED-QOS-MIB::cbQosIfType'
QOS_CONFIG_INDEX_OID = 'CISCO-CLASS-BASED-QOS-MIB::cbQosConfigIndex'


rawdata = my_snmp_walk(args, bulk_oids)
policy_maps = dict()  # policy-map index -> policy-map name
class_maps = dict()  # class-map index -> class-map name
qos_interfaces = list()  # qos ifIndex -> IF-MIB ifIndex
cmstats = dict()  # <interface>: {<qos_ifindex>: {<statsname>: <value>} }
qos_config_index_mapping = dict()

# Parse the first bulkwalk into the above datastructures
for snmpobj in rawdata:
    if snmpobj.oid == 'cbQosCMName':
        class_maps[snmpobj.oid_index] = snmpobj.value
    elif snmpobj.oid == 'cbQosPolicyMapName':
        policy_maps[snmpobj.oid_index] = snmpobj.value
    elif snmpobj.oid == 'cbQosIfIndex':
        iftype = my_snmp_get(args, "{}.{}".format(QOS_IFTYPE_OID, snmpobj.oid_index))
        if iftype.value != '5':  # control-plane auto-copp
コード例 #2
0
ファイル: check_ibgp.py プロジェクト: 4383/network_monitoring
                    help='Host to check')
args = parser.parse_args()


# Get local AS number
local_as = my_snmp_get(args, 'BGP4-MIB::bgpLocalAs.0').value


# Get all BGP peers
oids = [
    'CISCO-BGP4-MIB::cbgpPeer2RemoteAs',
    'CISCO-BGP4-MIB::cbgpPeer2AdminStatus',
    'CISCO-BGP4-MIB::cbgpPeer2LastErrorTxt',
    'CISCO-BGP4-MIB::cbgpPeer2State'
]
rawdata = my_snmp_walk(args, oids)
data = snmpresult_to_dict(rawdata)


# Now loop over data, and for _iBGP_ check the states
status = STATE_OK
statusstr = ""
num_ibgp = 0
for index, peer in data.iteritems():
    if local_as not in peer['cbgpPeer2RemoteAs'].value:
        continue
    num_ibgp += 1
    peer_ip = snmp_oid_decode_ip(index)
    admin_state = int(peer['cbgpPeer2AdminStatus'].value)
    bgp_state = int(peer['cbgpPeer2State'].value)
    last_error = peer['cbgpPeer2LastErrorTxt'].value.strip()
コード例 #3
0
# Checking system firmware type
device_type = my_snmp_get(args, oid_device_type)
if device_type.value == u'NOSUCHOBJECT' or device_type.value == u'NOSUCHINSTANCE':
    f10 = True
    oid_stack_num_units = f10_oid_stack_num_units
    oids_stack_status = f10_oids_stack_status
    oid_num_psus = f10_oid_num_psus
    oid_num_fans = f10_oid_num_fans
    oid_psu_oper = f10_oid_psu_oper
    oid_fans_oper = f10_oid_fans_oper
    oid_mgmt_status = f10_oid_mgmt_status
else:
    f10 = False

num_stackunits = my_snmp_get(args, oid_stack_num_units)
raw_stackunit_status = my_snmp_walk(args, oids_stack_status)

status = STATE_OK
statusstr = ""
stackunit_status = snmpresult_to_dict(raw_stackunit_status)
num_mgmt_units = 0
for index, su in stackunit_status.iteritems():

    mgmt_status = my_snmp_get(args, oid_mgmt_status.format(index))
    if mgmt_status.value == u'1':
        num_mgmt_units += 1

    if f10:
        unit_status_label = 'chStackUnitStatus'
    else:
        unit_status_label = 'dellNetStackUnitStatus'
コード例 #4
0
    'CISCO-VIRTUAL-SWITCH-MIB::cvsVSLConfiguredPortCount',
    'CISCO-VIRTUAL-SWITCH-MIB::cvsVSLOperationalPortCount'
]
oids_switch = [
    'CISCO-VIRTUAL-SWITCH-MIB::cvsSwitchCapability.0',  # 0=standalone, 1=core(part of vss cluster)
    'CISCO-VIRTUAL-SWITCH-MIB::cvsSwitchMode.0'  # 1=standalone, 2=multiNode(VSS)
]
cvsSwitchCapability = my_snmp_get(args, oids_switch[0])
cvsSwitchMode = my_snmp_get(args, oids_switch[1])
if cvsSwitchCapability.value != u'\xc0' and cvsSwitchCapability.value != u'\x80':
    print "UNKNOWN: Switch is not VSS capable!"
    sys.exit(STATE_UNKNOWN)
if cvsSwitchMode.value != u'2':
    print "OK: Switch is VSS capable, but isn't running in VSS mode"
    sys.exit(STATE_OK)
rawdata_chassis = my_snmp_walk(args, oids_chassis)
rawdata_VSL = my_snmp_walk(args, oids_VSL)

# Sort the walked data into a nicer format
chassis = snmpresult_to_dict(rawdata_chassis)
VSL = snmpresult_to_dict(rawdata_VSL)

# A valid and healthy VSS cluster is always 2 members
if len(chassis) < 2:
    print "CRITICAL: Only one chassis found, possible cluster member outage!"
    sys.exit(STATE_CRIT)

chassis1 = chassis[list(chassis.keys())[0]]
chassis2 = chassis[list(chassis.keys())[1]]

# We want to catch: standby/standby active/active and whether either are in standalone
コード例 #5
0
ファイル: cisco_vpc.py プロジェクト: 4383/network_monitoring
    'CISCO-VPC-MIB::cVpcDualActiveDetectionStatus'
]
# These are for host-link status
oids_host_link_status = [
    'CISCO-VPC-MIB::cVpcStatusHostLinkIfIndex',
    'CISCO-VPC-MIB::cVpcStatusHostLinkStatus',
    'CISCO-VPC-MIB::cVpcStatusHostLinkConsistencyStatus',
    'CISCO-VPC-MIB::cVpcStatusHostLinkConsistencyDetail'
]
oid_t_ifmib_ifname = 'IF-MIB::ifName.{}'

status = STATE_OK
statusstr = ""

# Check VPC general status and the status of peer-links
rawdata = my_snmp_walk(args, oids)
if not rawdata:
    print "OK: Switch does not implement Cisco VPC, or does not have it enabled."
    sys.exit(STATE_OK)
data = snmpresult_to_dict(rawdata)
vpc_domain_ids = []
for vpc_domain in data:
    vpc_domain_ids.append(vpc_domain)
    vpc_data = data[vpc_domain]

    # 1 = primarySecondary, 2 = primary, 3 = secondaryPrimary, 4 = secondary, 5 = noneEstablished
    if int(vpc_data['cVpcRoleStatus'].value) == 5:
        status, statusstr = trigger_not_ok(
            status, statusstr, STATE_CRIT,
            'VPC Domain {} no peerlinks established'.format(vpc_domain))
        continue  # No point in checking further
コード例 #6
0
# Argument parsing
parser = argparse.ArgumentParser(
    description='Check environment of Cisco devices')
parser.add_argument('-C',
                    metavar='<community>',
                    required=True,
                    help='SNMP Community')
parser.add_argument('-H',
                    metavar='<host>',
                    required=True,
                    help='Host to check')
args = parser.parse_args()

# Get all environmental modules and put in a nicely ordered dict
rawdata = my_snmp_walk(args, 'ENTITY-MIB::entPhysicalTable')
data = snmpresult_to_dict(rawdata)

# Now we loop over the data and perform poweradmin/poweroper/sensorstatus checks
status = STATE_OK
statusstr = ''
for index in data:
    descr = data[index]['entPhysicalDescr'].value

    # First off we'll try getting some Power status for those that support it
    # 1/on - Admin power on
    # 2/off - Admin power off
    # 3/inlineAuto,4/inlineOn,5/powerCycle - PoE stuff, irrelevant for us so not much caring here
    # cefcFRUPowerAdminStatus - 1=on, 2=off, 3=inlineAuto, 4=inlineOn, 5=powerCycle
    pwr_adminstatus = my_snmp_get(
        args,
コード例 #7
0
parser.add_argument('-H',
                    metavar='<host>',
                    required=True,
                    help='Host to check')
args = parser.parse_args()

vlt_detection_oid = 'DELL-NETWORKING-VIRTUAL-LINK-TRUNK-MIB::dellNetVLTDomainId'
oids = [
    'DELL-NETWORKING-VIRTUAL-LINK-TRUNK-MIB::dellNetVLTPeerStatus',
    'DELL-NETWORKING-VIRTUAL-LINK-TRUNK-MIB::dellNetVLTIclStatus',
    'DELL-NETWORKING-VIRTUAL-LINK-TRUNK-MIB::dellNetVLTHBeatStatus',
    'DELL-NETWORKING-VIRTUAL-LINK-TRUNK-MIB::dellNetVLTIclBwStatus'
]

# Check if we can do anything useful against this switch
res = my_snmp_walk(args, vlt_detection_oid)
if not res or not res[0] or res[0].value in [
        u'NOSUCHOBJECT', u'NOSUCHINSTANCE'
]:
    print "OK: Either switch doesn't support the VLT MIB, or it doesn't run VLT."
    sys.exit(STATE_OK)

# Check VLT status
rawdata = my_snmp_walk(args, oids)
data = snmpresult_to_dict(rawdata)
status = STATE_OK
statusstr = ""
for index, vltdomain in data.iteritems():
    vlt_domain_id = int(str(index))
    peer_status = int(str(vltdomain['dellNetVLTPeerStatus'].value))
    if peer_status == 0:
コード例 #8
0
ospfv3_ok_states = [4, 8]


# Argument parsing
parser = argparse.ArgumentParser(description='Check OSPFv3 session status for interface')
parser.add_argument('-C', metavar='<community>', required=True,
                    help='SNMP Community')
parser.add_argument('-H', metavar='<host>', required=True,
                    help='Host to check')
parser.add_argument('-i', metavar='<interface>', required=True,
                    help='Interface to check')
args = parser.parse_args()


# Get all interfaces, and then get OSPFv3 data for that interface
rawdata = my_snmp_walk(args, 'IF-MIB::ifDescr')
interface = None
for obj in rawdata:
    if str(obj.value) == args.i:
        interface = obj
if not interface:
    print "CRITICAL: Interface {} not found!".format(args.i)
    sys.exit(STATE_CRIT)
rawdata = my_snmp_walk(args, 'OSPFV3-MIB::ospfv3NbrState.{}'.format(interface.oid_index))


# Check for neighbours and their states
status = STATE_OK
statusstr = ""
num_neis = 0
コード例 #9
0
ファイル: arp_vlans.py プロジェクト: 4383/network_monitoring
    description='Output per-vlan ARP table size in graphite format')
parser.add_argument('-C',
                    metavar='<community>',
                    required=True,
                    help='SNMP Community')
parser.add_argument('-H',
                    metavar='<host>',
                    required=True,
                    help='Host to check')
parser.add_argument('-g',
                    metavar='<host>',
                    required=True,
                    help='Graphite host')
args = parser.parse_args()

rawdata = my_snmp_walk(args, 'IF-MIB::ifDescr')
data = snmpresult_to_dict(rawdata)

for if_index, if_data in data.iteritems():
    if if_data['ifDescr'].value.lower().startswith('vlan'):
        vlan_rawdata = my_snmp_walk(
            args, 'IP-MIB::ipNetToPhysicalType.{}.1'.format(if_index), True)
        vlan_data = snmpresult_to_dict(vlan_rawdata)
        cnt = 0
        for vl_index, vl_data in vlan_data.iteritems():
            if vl_data['ipNetToPhysicalType'].value == 'dynamic':
                cnt += 1
        send_metrics(
            "arp.{}.vlan.{}".format(args.H,
                                    if_data['ifDescr'].value.split(" ")[1]),
            cnt)