-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from infrasonar/lldp
New LLDP check
- Loading branch information
Showing
6 changed files
with
954 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from asyncsnmplib.mib.mib_index import MIB_INDEX | ||
from libprobe.asset import Asset | ||
from ..snmpclient import get_snmp_client | ||
from ..snmpquery import snmpquery | ||
from ..utils import InterfaceLookup | ||
|
||
|
||
QUERIES = ( | ||
MIB_INDEX['IF-MIB']['ifEntry'], | ||
MIB_INDEX['BRIDGE-MIB']['dot1dStpPortEntry'], | ||
MIB_INDEX['BRIDGE-MIB']['dot1dBasePortEntry'] | ||
) | ||
|
||
|
||
async def check_lldp( | ||
asset: Asset, | ||
asset_config: dict, | ||
check_config: dict): | ||
|
||
snmp = get_snmp_client(asset, asset_config, check_config) | ||
|
||
if_entry = InterfaceLookup.get(asset.id) | ||
if if_entry is None: | ||
state_data = await snmpquery(snmp, QUERIES, True) | ||
if_entry = InterfaceLookup.set(asset.id, state_data.get('if', [])) | ||
else: | ||
state_data = await snmpquery(snmp, QUERIES[1:], True) | ||
|
||
itms = state_data.get('dot1dStpPort', []) | ||
base_port_entry = { | ||
i.pop('name'): i | ||
for i in state_data.get('dot1dBasePort', [])} | ||
for item in itms: | ||
key = item['name'] | ||
|
||
try: | ||
base_port_item = base_port_entry[key] | ||
if_item = if_entry[base_port_item['IfIndex']] | ||
item['Interface'] = if_item['Descr'] | ||
except Exception: | ||
continue | ||
|
||
return { | ||
'lldp': itms | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Version string. Examples: | ||
# '3.0.0' | ||
# '3.0.0-alpha9' | ||
__version__ = '3.1.1' | ||
__version__ = '3.1.2-alpha0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.