...
 
Commits (6)
......@@ -6,11 +6,80 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import re
# NOC modules
from noc.sa.profiles.Generic.get_lldp_neighbors import Script as BaseScript
from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors
from noc.core.lldp import (
LLDP_CAP_OTHER,
LLDP_CAP_REPEATER,
LLDP_CAP_BRIDGE,
LLDP_CAP_WLAN_ACCESS_POINT,
LLDP_CAP_ROUTER,
LLDP_CAP_TELEPHONE,
LLDP_CAP_DOCSIS_CABLE_DEVICE,
LLDP_CAP_STATION_ONLY,
lldp_caps_to_bits,
)
class Script(BaseScript):
name = "AlliedTelesis.AT9900.get_lldp_neighbors"
interface = IGetLLDPNeighbors
rx_lldp = re.compile(
r"^\s+lldpRemLocalPortNum \S+ (?P<local_port_num>\S+)\n"
r"^\s+lldpRemIndex \S+ (?P<index>\S+)\n"
r"^\s+lldpRemTimeMark.+\n"
r"^\s+lldpRemChassisIdSubtype \S+ (?P<chassis_id_subtype>\S+)\n"
r"^\s+lldpRemChassisId \S+ (?P<chassis_id>\S+)\n"
r"^\s+lldpRemPortIdSubtype \S+ (?P<port_id_subtype>\S+)\n"
r"^\s+lldpRemPortId \S+ (?P<port_id>\S+)\n"
r"^\s+lldpRemPortDesc \S+ (?P<port_description>((.+\n)?^\s+\d.+)|.+)\n"
r"^\s+lldpRemSysName \S+ (?P<system_name>\S+)\n"
r"^\s+lldpRemSysDesc \S+ (?P<system_description>((.+\n)?^\s+\d.+)|.+)\n"
r"^\s+lldpRemSysCapSupported \S+ (?P<cap_support>.+)\n"
r"^\s+lldpRemSysCapEnabled \S+ (?P<caps>.+)\n",
re.MULTILINE | re.IGNORECASE,
)
def execute_cli(self):
r = []
v = self.cli("show lldp neighbour detail")
for match in self.rx_lldp.finditer(v):
local_port = "port" + match.group("local_port_num").strip()
iface = {"local_interface": local_port, "neighbors": []}
cap = lldp_caps_to_bits(
match.group("caps").strip().split(","),
{
"Other": LLDP_CAP_OTHER,
"Repeater": LLDP_CAP_REPEATER,
"Bridge": LLDP_CAP_BRIDGE,
"Access Point": LLDP_CAP_WLAN_ACCESS_POINT,
"Router": LLDP_CAP_ROUTER,
"Telephone": LLDP_CAP_TELEPHONE,
"D": LLDP_CAP_DOCSIS_CABLE_DEVICE,
"Station only": LLDP_CAP_STATION_ONLY,
},
)
n = {
"remote_chassis_id": match.group("chassis_id").strip(),
"remote_chassis_id_subtype": match.group("chassis_id_subtype").strip(),
"remote_port": match.group("port_id").strip(),
"remote_port_subtype": match.group("port_id_subtype").strip(),
"remote_capabilities": cap,
}
system_name = match.group("system_name").strip()
if system_name and system_name != "-":
n["remote_system_name"] = system_name
system_description = match.group("system_description").strip()
if system_description and system_description != "-":
n["remote_system_description"] = re.sub(r"\s+", " ", system_description)
port_description = match.group("port_description").strip()
if port_description and port_description != "-":
n["remote_port_description"] = re.sub(r"\s+", " ", port_description)
iface["neighbors"] += [n]
r += [iface]
return r
{
"$metric": "Environment | Temperature",
"$metric": "Environment | Sensor Status",
"$type": "match",
"$matchers": {
"is_MES31": {
......@@ -16,36 +16,101 @@
"$match": [{
"$match": "is_MES31",
"$type": "oids",
"oids": [{
"oid": "1.3.6.1.4.1.89.53.15.1.9.1",
"path": ["","","", "Temperature_Sensor1"],
"oids": [
{
"oid": "1.3.6.1.4.1.89.53.15.1.2.1",
"path": ["","","", "State_MainPS"],
"$type": "oid",
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.12.1",
"path": ["","","", "Temperature_Sensor2"],
"oid": "1.3.6.1.4.1.89.53.15.1.3.1",
"path": ["","","", "State_RedundantPS"],
"type": "gauge",
"scale": 1
},{
"oid": "1.3.6.1.4.1.89.53.15.1.4.1",
"path": ["","","", "State_Fan1"],
"$type": "oid",
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.5.1",
"path": ["","","", "State_Fan2"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.6.1",
"path": ["","","", "State_Fan3"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.7.1",
"path": ["","","", "State_Fan4"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.14.1",
"path": ["","","", "Temperature_Sensor3"],
"oid": "1.3.6.1.4.1.89.53.15.1.10.1",
"path": ["","","", "State_TempSensor"],
"type": "gauge",
"scale": 1
}]
},{
"$match": "is_MES23",
"$type": "oids",
"oids": [
{
"oid": "1.3.6.1.4.1.89.53.15.1.2.1",
"path": ["", "", "", "State_MainPS"],
"$type": "oid",
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.3.1",
"path": ["", "", "", "State_RedundantPS"],
"type": "gauge",
"scale": 1
},{
"oid": "1.3.6.1.4.1.89.53.15.1.4.1",
"path": ["", "", "", "State_Fan1"],
"$type": "oid",
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.5.1",
"path": ["", "", "", "State_Fan2"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.6.1",
"path": ["", "", "", "State_Fan3"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.7.1",
"path": ["", "", "", "State_Fan4"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.11.1",
"path": ["", "", "", "State_TempSensor"],
"type": "gauge",
"scale": 1
}]
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.10.1",
"path": ["","","", "Temperature"],
"type": "gauge",
"scale": 1
},{
"$type": "oid",
"oid": "1.3.6.1.4.1.89.53.15.1.9.1",
"path": ["","","", "Temperature"],
"oid": "1.3.6.1.4.1.89.53.15.1.11.1",
"path": ["","","", "State_TempSensor"],
"type": "gauge",
"scale": 1
}]
......
......@@ -2,7 +2,7 @@
# ----------------------------------------------------------------------
# Eltex.MES24xx.get_chassis_id
# ----------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
......@@ -19,8 +19,9 @@ class Script(BaseScript):
interface = IGetChassisID
cache = True
rx_mac = re.compile(r"^\s+Address\s+(?P<mac>\S+)\s*\n", re.MULTILINE)
rx_mac = re.compile(r"^Chassis Id\s+:\s+(?P<mac>\S+)", re.MULTILINE)
def execute_cli(self, **kwargs):
match = self.rx_mac.search(self.cli("show spanning-tree switch default"))
match = self.rx_mac.search(self.cli("show lldp local"))
# do not use show spanning-tree switch default - if stp disabled output 00:00:00:00:00:00 mac
return {"first_chassis_mac": match.group("mac"), "last_chassis_mac": match.group("mac")}
......@@ -49,7 +49,7 @@ class Script(BaseScript):
r"^Local Intf\s+: (?P<local_port>.*?)\n"
r"^Time Remaining.*?\n"
r"(^System Capabilities Supported\s+:.*?\n)?"
r"^System Capabilities (?:Enabled|Tlv)\s+:(?P<caps>.*?)\n",
r"^System Capabilities (?:Enabled|Tlv)\s+:\s*(?P<caps>.*?)\n",
re.MULTILINE | re.DOTALL,
)
......