@@ -141,6 +141,47 @@ def __init__(self,dotprefix=False):
141141 self .ipAdEntIfIndex = dp + "1.3.6.1.2.1.4.20.1.2"
142142 self .ipAdEntNetMask = dp + "1.3.6.1.2.1.4.20.1.3"
143143
144+ # From LLDP-MIB: lldpLocalSystemData
145+ self .lldpLocChassisIdSubtype = dp + "1.0.8802.1.1.2.1.3.1"
146+ self .lldpLocChassisId = dp + "1.0.8802.1.1.2.1.3.2"
147+ self .lldpLocSysName = dp + "1.0.8802.1.1.2.1.3.3"
148+ self .lldpLocSysDesc = dp + "1.0.8802.1.1.2.1.3.4"
149+
150+ # From LLDP-MIB: lldpLocPortTable
151+ self .lldpLocPortNum = dp + "1.0.8802.1.1.2.1.3.7.1.1" # + .ifindex
152+ self .lldpLocPortIdSubtype = dp + "1.0.8802.1.1.2.1.3.7.1.2" # + .ifindex
153+ self .lldpLocPortId = dp + "1.0.8802.1.1.2.1.3.7.1.3" # + .ifindex
154+ self .lldpLocPortDesc = dp + "1.0.8802.1.1.2.1.3.7.1.4" # + .ifindex
155+
156+ # From LLDP-MIB: lldpLocManAddrTables
157+ self .lldpLocManAddrSubtype = dp + "1.0.8802.1.1.2.1.3.8.1.1" # + .subtype + .man addr
158+ self .lldpLocManAddr = dp + "1.0.8802.1.1.2.1.3.8.1.2" # + .subtype + .man addr
159+ self .lldpLocManAddrLen = dp + "1.0.8802.1.1.2.1.3.8.1.3" # + .subtype + .man addr
160+ self .lldpLocManAddrIfSubtype = dp + "1.0.8802.1.1.2.1.3.8.1.4" # + .subtype + .man addr
161+ self .lldpLocManAddrIfId = dp + "1.0.8802.1.1.2.1.3.8.1.5" # + .subtype + .man addr
162+ self .lldpLocManAddrOID = dp + "1.0.8802.1.1.2.1.3.8.1.6" # + .subtype + .man addr
163+
164+ # From LLDP-MIB: lldpRemTable
165+ self .lldpRemTimeMark = dp + "1.0.8802.1.1.2.1.4.1.1.1" # + .time mark + .ifindex + .rem index
166+ self .lldpRemLocalPortNum = dp + "1.0.8802.1.1.2.1.4.1.1.2" # + .time mark + .ifindex + .rem index
167+ self .lldpRemIndex = dp + "1.0.8802.1.1.2.1.4.1.1.3" # + .time mark + .ifindex + .rem index
168+ self .lldpRemChassisIdSubtype = dp + "1.0.8802.1.1.2.1.4.1.1.4" # + .time mark + .ifindex + .rem index
169+ self .lldpRemChassisId = dp + "1.0.8802.1.1.2.1.4.1.1.5" # + .time mark + .ifindex + .rem index
170+ self .lldpRemPortIdSubtype = dp + "1.0.8802.1.1.2.1.4.1.1.6" # + .time mark + .ifindex + .rem index
171+ self .lldpRemPortId = dp + "1.0.8802.1.1.2.1.4.1.1.7" # + .time mark + .ifindex + .rem index
172+ self .lldpRemPortDesc = dp + "1.0.8802.1.1.2.1.4.1.1.8" # + .time mark + .ifindex + .rem index
173+ self .lldpRemSysName = dp + "1.0.8802.1.1.2.1.4.1.1.9" # + .time mark + .ifindex + .rem index
174+ self .lldpRemSysDesc = dp + "1.0.8802.1.1.2.1.4.1.1.10" # + .time mark + .ifindex + .rem index
175+ self .lldpRemSysCapSupported = dp + "1.0.8802.1.1.2.1.4.1.1.11" # + .time mark + .ifindex + .rem index
176+ self .lldpRemSysCapEnabled = dp + "1.0.8802.1.1.2.1.4.1.1.12" # + .time mark + .ifindex + .rem index
177+
178+ # From LLDP-MIB: lldpRemManAddrTable
179+ self .lldpRemManAddrSubtype = dp + "1.0.8802.1.1.2.1.4.2.1.1" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
180+ self .lldpRemManAddr = dp + "1.0.8802.1.1.2.1.4.2.1.2" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
181+ self .lldpRemManAddrIfSubtype = dp + "1.0.8802.1.1.2.1.4.2.1.3" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
182+ self .lldpRemManAddrIfId = dp + "1.0.8802.1.1.2.1.4.2.1.4" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
183+ self .lldpRemManAddrOID = dp + "1.0.8802.1.1.2.1.4.2.1.5" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
184+
144185 # From Dell Private MIB
145186 self .ChStackUnitCpuUtil5sec = dp + "1.3.6.1.4.1.6027.3.10.1.2.9.1.2.1"
146187
@@ -480,6 +521,195 @@ def main():
480521 if current_oid == v .ChStackUnitCpuUtil5sec :
481522 results ['ansible_ChStackUnitCpuUtil5sec' ] = decode_type (module , current_oid , val )
482523
524+ errorIndication , errorStatus , errorIndex , varBinds = cmdGen .getCmd (
525+ snmp_auth ,
526+ cmdgen .UdpTransportTarget ((m_args ['host' ], 161 )),
527+ cmdgen .MibVariable (p .lldpLocChassisIdSubtype ,),
528+ cmdgen .MibVariable (p .lldpLocChassisId ,),
529+ cmdgen .MibVariable (p .lldpLocSysName ,),
530+ cmdgen .MibVariable (p .lldpLocSysDesc ,),
531+ )
532+
533+ if errorIndication :
534+ module .fail_json (msg = str (errorIndication ) + ' querying lldp local system infomation.' )
535+
536+ for oid , val in varBinds :
537+ current_oid = oid .prettyPrint ()
538+ current_val = val .prettyPrint ()
539+ if current_oid == v .lldpLocChassisIdSubtype :
540+ results ['snmp_lldp' ]['lldpLocChassisIdSubtype' ] = current_val
541+ elif current_oid == v .lldpLocChassisId :
542+ results ['snmp_lldp' ]['lldpLocChassisId' ] = current_val
543+ elif current_oid == v .lldpLocSysName :
544+ results ['snmp_lldp' ]['lldpLocSysName' ] = current_val
545+ elif current_oid == v .lldpLocSysDesc :
546+ results ['snmp_lldp' ]['lldpLocSysDesc' ] = current_val
547+
548+ errorIndication , errorStatus , errorIndex , varTable = cmdGen .nextCmd (
549+ snmp_auth ,
550+ cmdgen .UdpTransportTarget ((m_args ['host' ], 161 )),
551+ cmdgen .MibVariable (p .lldpLocPortNum ,),
552+ cmdgen .MibVariable (p .lldpLocPortIdSubtype ,),
553+ cmdgen .MibVariable (p .lldpLocPortId ,),
554+ cmdgen .MibVariable (p .lldpLocPortDesc ,),
555+ )
556+
557+ if errorIndication :
558+ module .fail_json (msg = str (errorIndication ) + ' querying lldpLocPortTable counters' )
559+
560+ for varBinds in varTable :
561+ for oid , val in varBinds :
562+ current_oid = oid .prettyPrint ()
563+ current_val = val .prettyPrint ()
564+ if v .lldpLocPortNum in current_oid :
565+ ifIndex = int (current_oid .rsplit ('.' , 1 )[- 1 ])
566+ results ['snmp_interfaces' ][ifIndex ]['lldpLocPortNum' ] = current_val
567+ if v .lldpLocPortIdSubtype in current_oid :
568+ ifIndex = int (current_oid .rsplit ('.' , 1 )[- 1 ])
569+ results ['snmp_interfaces' ][ifIndex ]['lldpLocPortIdSubtype' ] = current_val
570+ if v .lldpLocPortId in current_oid :
571+ ifIndex = int (current_oid .rsplit ('.' , 1 )[- 1 ])
572+ results ['snmp_interfaces' ][ifIndex ]['lldpLocPortId' ] = current_val
573+ if v .lldpLocPortDesc in current_oid :
574+ ifIndex = int (current_oid .rsplit ('.' , 1 )[- 1 ])
575+ results ['snmp_interfaces' ][ifIndex ]['lldpLocPortDesc' ] = current_val
576+
577+ errorIndication , errorStatus , errorIndex , varTable = cmdGen .nextCmd (
578+ snmp_auth ,
579+ cmdgen .UdpTransportTarget ((m_args ['host' ], 161 )),
580+ cmdgen .MibVariable (p .lldpLocManAddrSubtype ,),
581+ cmdgen .MibVariable (p .lldpLocManAddr ,),
582+ cmdgen .MibVariable (p .lldpLocManAddrLen ,),
583+ cmdgen .MibVariable (p .lldpLocManAddrIfSubtype ,),
584+ cmdgen .MibVariable (p .lldpLocManAddrIfId ,),
585+ cmdgen .MibVariable (p .lldpLocManAddrOID ,),
586+ )
587+
588+ if errorIndication :
589+ module .fail_json (msg = str (errorIndication ) + ' querying lldpLocPortTable counters' )
590+
591+ for varBinds in varTable :
592+ for oid , val in varBinds :
593+ current_oid = oid .prettyPrint ()
594+ current_val = val .prettyPrint ()
595+ if v .lldpLocManAddrSubtype in current_oid :
596+ address = '.' .join (current_oid .split ('.' )[13 :])
597+ results ['snmp_lldp' ]['lldpLocManAddrSubtype' ] = current_val
598+ if v .lldpLocManAddr in current_oid :
599+ address = '.' .join (current_oid .split ('.' )[13 :])
600+ results ['snmp_lldp' ]['lldpLocManAddr' ] = current_val
601+ if v .lldpLocManAddrLen in current_oid :
602+ address = '.' .join (current_oid .split ('.' )[13 :])
603+ results ['snmp_lldp' ]['lldpLocManAddrLen' ] = current_val
604+ if v .lldpLocManAddrIfSubtype in current_oid :
605+ address = '.' .join (current_oid .split ('.' )[13 :])
606+ results ['snmp_lldp' ]['lldpLocManAddrIfSubtype' ] = current_val
607+ if v .lldpLocManAddrIfId in current_oid :
608+ address = '.' .join (current_oid .split ('.' )[13 :])
609+ results ['snmp_lldp' ]['lldpLocManAddrIfId' ] = current_val
610+ if v .lldpLocManAddrOID in current_oid :
611+ address = '.' .join (current_oid .split ('.' )[13 :])
612+ results ['snmp_lldp' ]['lldpLocManAddrOID' ] = current_val
613+
614+ errorIndication , errorStatus , errorIndex , varTable = cmdGen .nextCmd (
615+ snmp_auth ,
616+ cmdgen .UdpTransportTarget ((m_args ['host' ], 161 )),
617+ cmdgen .MibVariable (p .lldpRemTimeMark ,),
618+ cmdgen .MibVariable (p .lldpRemLocalPortNum ,),
619+ cmdgen .MibVariable (p .lldpRemIndex ,),
620+ cmdgen .MibVariable (p .lldpRemChassisIdSubtype ,),
621+ cmdgen .MibVariable (p .lldpRemChassisId ,),
622+ cmdgen .MibVariable (p .lldpRemPortIdSubtype ,),
623+ cmdgen .MibVariable (p .lldpRemPortId ,),
624+ cmdgen .MibVariable (p .lldpRemPortDesc ,),
625+ cmdgen .MibVariable (p .lldpRemSysName ,),
626+ cmdgen .MibVariable (p .lldpRemSysDesc ,),
627+ cmdgen .MibVariable (p .lldpRemSysCapSupported ,),
628+ cmdgen .MibVariable (p .lldpRemSysCapEnabled ,),
629+ )
630+
631+ if errorIndication :
632+ module .fail_json (msg = str (errorIndication ) + ' querying lldpLocPortTable counters' )
633+
634+ for varBinds in varTable :
635+ for oid , val in varBinds :
636+ current_oid = oid .prettyPrint ()
637+ current_val = val .prettyPrint ()
638+ if v .lldpRemTimeMark in current_oid :
639+ ifIndex = int (current_oid .split ('.' )[12 ])
640+ results ['snmp_interfaces' ][ifIndex ]['lldpRemTimeMark' ] = current_val
641+ if v .lldpRemLocalPortNum in current_oid :
642+ ifIndex = int (current_oid .split ('.' )[12 ])
643+ results ['snmp_interfaces' ][ifIndex ]['lldpRemLocalPortNum' ] = current_val
644+ if v .lldpRemIndex in current_oid :
645+ ifIndex = int (current_oid .split ('.' )[12 ])
646+ results ['snmp_interfaces' ][ifIndex ]['lldpRemIndex' ] = current_val
647+ if v .lldpRemChassisIdSubtype in current_oid :
648+ ifIndex = int (current_oid .split ('.' )[12 ])
649+ results ['snmp_interfaces' ][ifIndex ]['lldpRemChassisIdSubtype' ] = current_val
650+ if v .lldpRemChassisId in current_oid :
651+ ifIndex = int (current_oid .split ('.' )[12 ])
652+ results ['snmp_interfaces' ][ifIndex ]['lldpRemChassisId' ] = current_val
653+ if v .lldpRemPortIdSubtype in current_oid :
654+ ifIndex = int (current_oid .split ('.' )[12 ])
655+ results ['snmp_interfaces' ][ifIndex ]['lldpRemPortIdSubtype' ] = current_val
656+ if v .lldpRemPortId in current_oid :
657+ ifIndex = int (current_oid .split ('.' )[12 ])
658+ results ['snmp_interfaces' ][ifIndex ]['lldpRemPortId' ] = current_val
659+ if v .lldpRemPortDesc in current_oid :
660+ ifIndex = int (current_oid .split ('.' )[12 ])
661+ results ['snmp_interfaces' ][ifIndex ]['lldpRemPortDesc' ] = current_val
662+ if v .lldpRemSysName in current_oid :
663+ ifIndex = int (current_oid .split ('.' )[12 ])
664+ results ['snmp_interfaces' ][ifIndex ]['lldpRemSysName' ] = current_val
665+ if v .lldpRemSysDesc in current_oid :
666+ ifIndex = int (current_oid .split ('.' )[12 ])
667+ results ['snmp_interfaces' ][ifIndex ]['lldpRemSysDesc' ] = current_val
668+ if v .lldpRemSysCapSupported in current_oid :
669+ ifIndex = int (current_oid .split ('.' )[12 ])
670+ results ['snmp_interfaces' ][ifIndex ]['lldpRemSysCapSupported' ] = current_val
671+ if v .lldpRemSysCapEnabled in current_oid :
672+ ifIndex = int (current_oid .split ('.' )[12 ])
673+ results ['snmp_interfaces' ][ifIndex ]['lldpRemSysCapEnabled' ] = current_val
674+
675+ errorIndication , errorStatus , errorIndex , varTable = cmdGen .nextCmd (
676+ snmp_auth ,
677+ cmdgen .UdpTransportTarget ((m_args ['host' ], 161 )),
678+ cmdgen .MibVariable (p .lldpRemManAddrSubtype ,),
679+ cmdgen .MibVariable (p .lldpRemManAddr ,),
680+ cmdgen .MibVariable (p .lldpRemManAddrIfSubtype ,),
681+ cmdgen .MibVariable (p .lldpRemManAddrIfId ,),
682+ cmdgen .MibVariable (p .lldpRemManAddrOID ,),
683+ )
684+
685+ if errorIndication :
686+ module .fail_json (msg = str (errorIndication ) + ' querying lldpLocPortTable counters' )
687+
688+ for varBinds in varTable :
689+ for oid , val in varBinds :
690+ current_oid = oid .prettyPrint ()
691+ current_val = val .prettyPrint ()
692+ if v .lldpRemManAddrSubtype in current_oid :
693+ ifIndex = int (current_oid .split ('.' )[12 ])
694+ address = '.' .join (current_oid .split ('.' )[16 :])
695+ results ['snmp_interfaces' ][ifIndex ]['lldpRemManAddrSubtype' ] = current_val
696+ if v .lldpRemManAddr in current_oid :
697+ ifIndex = int (current_oid .split ('.' )[12 ])
698+ address = '.' .join (current_oid .split ('.' )[16 :])
699+ results ['snmp_interfaces' ][ifIndex ]['lldpRemManAddr' ] = current_val
700+ if v .lldpRemManAddrIfSubtype in current_oid :
701+ ifIndex = int (current_oid .split ('.' )[12 ])
702+ address = '.' .join (current_oid .split ('.' )[16 :])
703+ results ['snmp_interfaces' ][ifIndex ]['lldpRemManAddrIfSubtype' ] = current_val
704+ if v .lldpRemManAddrIfId in current_oid :
705+ ifIndex = int (current_oid .split ('.' )[12 ])
706+ address = '.' .join (current_oid .split ('.' )[16 :])
707+ results ['snmp_interfaces' ][ifIndex ]['lldpRemManAddrIfId' ] = current_val
708+ if v .lldpRemManAddrOID in current_oid :
709+ ifIndex = int (current_oid .split ('.' )[12 ])
710+ address = '.' .join (current_oid .split ('.' )[16 :])
711+ results ['snmp_interfaces' ][ifIndex ]['lldpRemManAddrOID' ] = current_val
712+
483713 errorIndication , errorStatus , errorIndex , varTable = cmdGen .nextCmd (
484714 snmp_auth ,
485715 cmdgen .UdpTransportTarget ((m_args ['host' ], 161 )),
0 commit comments