Commit 10fcc89b authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

release-22.1:Backport!6416

parent ce1f30d4
...@@ -62,7 +62,7 @@ class Script(BaseScript): ...@@ -62,7 +62,7 @@ class Script(BaseScript):
return chassis return chassis
for ss in sensors: for ss in sensors:
if ss["name"] in sensor_labels and "labels" in ss: if ss["name"] in sensor_labels and "labels" in ss:
ss["labels"] += sensor_labels[ss["name"]] ss["labels"] = ss["labels"][:] + sensor_labels[ss["name"]]
elif ss["name"] in sensor_labels and "labels" not in ss: elif ss["name"] in sensor_labels and "labels" not in ss:
ss["labels"] = sensor_labels[ss["name"]] ss["labels"] = sensor_labels[ss["name"]]
return chassis return chassis
......
...@@ -370,12 +370,13 @@ class Script(BaseScript): ...@@ -370,12 +370,13 @@ class Script(BaseScript):
"snmp_oid": "1.3.6.1.4.1.27514.103.0.24.0", "snmp_oid": "1.3.6.1.4.1.27514.103.0.24.0",
}, },
{ {
"name": "ups_battery_capasity", "name": "ups_battery_state_of_charge",
"status": bool(v), "status": bool(v),
"description": "ИБП. Ёмкость батареи в %.", "description": "ИБП. Ёмкость батареи в %.",
"measurement": "Percent", "measurement": "Percent",
"labels": [ "labels": [
"noc::sensor::placement::ups", "noc::sensor::placement::ups",
"noc::sensor::mode::soc",
"noc::sensor::target::power_cell", "noc::sensor::target::power_cell",
], ],
"snmp_oid": "1.3.6.1.4.1.27514.103.0.25.0", "snmp_oid": "1.3.6.1.4.1.27514.103.0.25.0",
......
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Ttronics.KUB.get_chassis_id # Ttronics.KUB.get_chassis_id
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project # Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details # See LICENSE for details
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# NOC modules # NOC modules
from noc.core.script.base import BaseScript from noc.sa.profiles.Generic.get_chassis_id import Script as BaseScript
from noc.sa.interfaces.igetchassisid import IGetChassisID from noc.sa.interfaces.igetchassisid import IGetChassisID
...@@ -15,7 +15,4 @@ class Script(BaseScript): ...@@ -15,7 +15,4 @@ class Script(BaseScript):
cache = True cache = True
interface = IGetChassisID interface = IGetChassisID
def execute_snmp(self): SNMP_GET_OIDS = {"SNMP": ["1.3.6.1.4.1.51315.1.20.0"]}
base = self.snmp.get("1.3.6.1.4.1.51315.1.20.0")
if base:
return [{"first_chassis_mac": base, "last_chassis_mac": base}]
...@@ -17,39 +17,7 @@ class Script(BaseScript): ...@@ -17,39 +17,7 @@ class Script(BaseScript):
requires = [] requires = []
def execute_snmp(self, interfaces=None): def execute_snmp(self, interfaces=None):
result = [] return [
for sensor in self.profile.SENSORS_TYPE.keys():
status = self.snmp.get("1.3.6.1.4.1.51315.1.%s.0" % sensor, cached=True)
s_type = self.snmp.get(
"1.3.6.1.4.1.51315.1.%s.0" % self.profile.SENSORS_TYPE.get(sensor), cached=True
)
s_status = False
if status == 0:
s_status = True
result += [
{
"interface": "%s/%s" % (s_type, sensor - 2) if s_type in [0, 1, 2] else s_type,
"admin_status": s_status,
"oper_status": s_status,
}
]
for sensor2 in self.profile.SENSORS_TYPE2.keys():
status2 = self.snmp.get("1.3.6.1.4.1.51315.1.%s.0" % sensor2, cached=True)
s2_status = False
if sensor2 == 1:
if status2 != -128:
s2_status = True
else:
if status2 == 0:
s2_status = True
result += [
{
"interface": self.profile.SENSORS_TYPE2.get(sensor2),
"admin_status": s2_status,
"oper_status": s2_status,
}
]
result += [
{ {
"interface": "eth0", "interface": "eth0",
"admin_status": True, "admin_status": True,
...@@ -59,4 +27,3 @@ class Script(BaseScript): ...@@ -59,4 +27,3 @@ class Script(BaseScript):
"out_speed": 10000, "out_speed": 10000,
} }
] ]
return result
...@@ -13,68 +13,21 @@ from noc.sa.interfaces.igetinterfaces import IGetInterfaces ...@@ -13,68 +13,21 @@ from noc.sa.interfaces.igetinterfaces import IGetInterfaces
class Script(BaseScript): class Script(BaseScript):
name = "Ttronics.KUB.get_interfaces" name = "Ttronics.KUB.get_interfaces"
interface = IGetInterfaces interface = IGetInterfaces
cache = True
def status(self, index):
return self.snmp.get("1.3.6.1.4.1.51315.1.%s.0" % index, cached=True)
def execute_snmp(self): def execute_snmp(self):
interfaces = []
for sensor in self.profile.SENSORS_TYPE.keys():
status = self.status(sensor)
s_type = self.snmp.get(
"1.3.6.1.4.1.51315.1.%s.0" % self.profile.SENSORS_TYPE.get(sensor), cached=True
)
s_status = False
if status == 0:
s_status = True
print(sensor)
interfaces += [
{
"type": "physical",
"name": "%s/%s" % (s_type, sensor - 2) if s_type in [0, 1, 2] else s_type,
"admin_status": s_status,
"oper_status": s_status,
"snmp_ifindex": sensor,
"description": "%s %s" % (self.profile.PORT_TYPE.get(s_type), sensor - 2)
if s_type in [0, 1, 2]
else self.profile.PORT_TYPE.get(s_type),
"subinterfaces": [],
}
]
for sensor2 in self.profile.SENSORS_TYPE2.keys():
status2 = self.status(sensor)
s2_status = False
if sensor2 == 1:
if status2 != -128:
s2_status = True
else:
if status2 == 0:
s2_status = True
interfaces += [
{
"type": "physical",
"name": self.profile.SENSORS_TYPE2.get(sensor2),
"admin_status": s2_status,
"oper_status": s2_status,
"snmp_ifindex": sensor2,
"description": "Вход датчика температуры"
if sensor2 == 1
else self.profile.PORT_TYPE.get(sensor2),
"subinterfaces": [],
}
]
mac = self.snmp.get("1.3.6.1.4.1.51315.1.20.0") mac = self.snmp.get("1.3.6.1.4.1.51315.1.20.0")
interfaces += [ return [
{ {
"type": "physical", "interfaces": [
"name": "eth0", {
"admin_status": True, "type": "physical",
"oper_status": True, "name": "eth0",
"mac": mac, "admin_status": True,
"snmp_ifindex": 100, "oper_status": True,
"subinterfaces": [], "mac": mac,
"snmp_ifindex": 100,
"subinterfaces": [],
}
]
} }
] ]
return [{"interfaces": interfaces}]
...@@ -20,14 +20,26 @@ class Script(BaseScript): ...@@ -20,14 +20,26 @@ class Script(BaseScript):
"units": "Volt AC", "units": "Volt AC",
"labels": ["noc::sensor::placement::external", "noc::sensor::mode::voltage"], "labels": ["noc::sensor::placement::external", "noc::sensor::mode::voltage"],
}, },
1: {"type": "in", "units": "StatusEnum", "labels": ["noc::sensor::placement::external"]}, 1: {
2: {"type": "relay", "units": "StatusEnum", "labels": ["noc::sensor::placement::external"]}, "type": "in",
"units": "StatusEnum",
"labels": [
"noc::sensor::placement::external",
"noc::sensor::mode::flag",
"noc::sensor::target::door",
],
},
2: {
"type": "relay",
"units": "StatusEnum",
"labels": ["noc::sensor::placement::external", "noc::sensor::mode::relay"],
},
3: { 3: {
"type": "counter", "type": "counter",
"units": "Scalar", "units": "Scalar",
"labels": ["noc::sensor::placement::external", "noc::sensor::mode::counter"], "labels": ["noc::sensor::placement::external", "noc::sensor::mode::counter"],
}, },
4: {"type": "vibration", "units": "Scalar", "labels": ["noc::sensor::placement::external"]}, 4: {"type": "vibration", "units": "Scalar", "labels": ["noc::sensor::placement::internal"]},
} }
def get_oid(self, p_type, num): def get_oid(self, p_type, num):
...@@ -59,7 +71,11 @@ class Script(BaseScript): ...@@ -59,7 +71,11 @@ class Script(BaseScript):
"status": 1, "status": 1,
"description": "Напряжение питания устройства", "description": "Напряжение питания устройства",
"measurement": "Volt AC", "measurement": "Volt AC",
"labels": ["noc::sensor::placement::internal", "noc::sensor::mode::voltage"], "labels": [
"noc::sensor::placement::internal",
"noc::sensor::mode::voltage",
"noc::sensor::target::supply",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.14.0", "snmp_oid": "1.3.6.1.4.1.51315.1.14.0",
}, },
] ]
...@@ -108,7 +124,11 @@ class Script(BaseScript): ...@@ -108,7 +124,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "Электросчётчик. Значение напряжения сети", "description": "Электросчётчик. Значение напряжения сети",
"measurement": "Volt AC", "measurement": "Volt AC",
"labels": ["noc::sensor::placement::elmeter", "noc::sensor::mode::voltage"], "labels": [
"noc::sensor::placement::elmeter",
"noc::sensor::mode::voltage",
"noc::sensor::target::supply",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.21.0", "snmp_oid": "1.3.6.1.4.1.51315.1.21.0",
}, },
{ {
...@@ -116,7 +136,11 @@ class Script(BaseScript): ...@@ -116,7 +136,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "Электросчётчик. Значение потребляемого тока", "description": "Электросчётчик. Значение потребляемого тока",
"measurement": "Ampere", "measurement": "Ampere",
"labels": ["noc::sensor::placement::elmeter", "noc::sensor::mode::current"], "labels": [
"noc::sensor::placement::elmeter",
"noc::sensor::mode::current",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.22.0", "snmp_oid": "1.3.6.1.4.1.51315.1.22.0",
}, },
{ {
...@@ -124,7 +148,11 @@ class Script(BaseScript): ...@@ -124,7 +148,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "Электросчётчик. Суммарное значение потреблённой мощности по тарифу 1", "description": "Электросчётчик. Суммарное значение потреблённой мощности по тарифу 1",
"measurement": "Kilowatt-hour", "measurement": "Kilowatt-hour",
"labels": ["noc::sensor::placement::elmeter", "noc::sensor::mode::kwh"], "labels": [
"noc::sensor::placement::elmeter",
"noc::sensor::mode::counter",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.23.0", "snmp_oid": "1.3.6.1.4.1.51315.1.23.0",
}, },
{ {
...@@ -132,7 +160,11 @@ class Script(BaseScript): ...@@ -132,7 +160,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "Электросчётчик. Суммарное значение потреблённой мощности по тарифу 2", "description": "Электросчётчик. Суммарное значение потреблённой мощности по тарифу 2",
"measurement": "Kilowatt-hour", "measurement": "Kilowatt-hour",
"labels": ["noc::sensor::placement::elmeter", "noc::sensor::mode::kwh"], "labels": [
"noc::sensor::placement::elmeter",
"noc::sensor::mode::counter",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.24.0", "snmp_oid": "1.3.6.1.4.1.51315.1.24.0",
}, },
{ {
...@@ -140,7 +172,11 @@ class Script(BaseScript): ...@@ -140,7 +172,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "Электросчётчик. Суммарное значение потреблённой мощности", "description": "Электросчётчик. Суммарное значение потреблённой мощности",
"measurement": "Kilowatt-hour", "measurement": "Kilowatt-hour",
"labels": ["noc::sensor::placement::elmeter", "noc::sensor::mode::kwh"], "labels": [
"noc::sensor::placement::elmeter",
"noc::sensor::mode::counter",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.25.0", "snmp_oid": "1.3.6.1.4.1.51315.1.25.0",
}, },
] ]
...@@ -152,7 +188,7 @@ class Script(BaseScript): ...@@ -152,7 +188,7 @@ class Script(BaseScript):
"status": v != 0, "status": v != 0,
"description": "Флаг наличия связи с ИБП по порту RS-232", "description": "Флаг наличия связи с ИБП по порту RS-232",
"measurement": "StatusEnum", "measurement": "StatusEnum",
"labels": ["noc::sensor::placement::internal"], "labels": ["noc::sensor::placement::internal", "noc::sensor::mode::flag"],
"snmp_oid": "1.3.6.1.4.1.51315.1.29.0", "snmp_oid": "1.3.6.1.4.1.51315.1.29.0",
}, },
] ]
...@@ -163,7 +199,7 @@ class Script(BaseScript): ...@@ -163,7 +199,7 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Текущее состояние ИБП", "description": "ИБП. Текущее состояние ИБП",
"measurement": "StatusEnum", "measurement": "StatusEnum",
"labels": ["noc::sensor::placement::ups"], "labels": ["noc::sensor::placement::ups", "noc::sensor::mode::flag"],
"snmp_oid": "1.3.6.1.4.1.51315.1.27.0", "snmp_oid": "1.3.6.1.4.1.51315.1.27.0",
}, },
{ {
...@@ -171,7 +207,11 @@ class Script(BaseScript): ...@@ -171,7 +207,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Текущее состояние батареи ИБП", "description": "ИБП. Текущее состояние батареи ИБП",
"measurement": "StatusEnum", "measurement": "StatusEnum",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::flag",
"noc::sensor::target::power_cell",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.38.0", "snmp_oid": "1.3.6.1.4.1.51315.1.38.0",
}, },
{ {
...@@ -179,7 +219,11 @@ class Script(BaseScript): ...@@ -179,7 +219,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Текущий статус bypass", "description": "ИБП. Текущий статус bypass",
"measurement": "StatusEnum", "measurement": "StatusEnum",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::flag",
"noc::sensor::target::bypass",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.31.0", "snmp_oid": "1.3.6.1.4.1.51315.1.31.0",
}, },
{ {
...@@ -187,7 +231,11 @@ class Script(BaseScript): ...@@ -187,7 +231,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Текущий режим работы ИБП", "description": "ИБП. Текущий режим работы ИБП",
"measurement": "StatusEnum", "measurement": "StatusEnum",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::target::supply",
"noc::sensor::mode::flag",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.32.0", "snmp_oid": "1.3.6.1.4.1.51315.1.32.0",
}, },
{ {
...@@ -195,7 +243,11 @@ class Script(BaseScript): ...@@ -195,7 +243,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Входное напряжение.", "description": "ИБП. Входное напряжение.",
"measurement": "Volt AC", "measurement": "Volt AC",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::voltage",
"noc::sensor::target::supply",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.33.0", "snmp_oid": "1.3.6.1.4.1.51315.1.33.0",
}, },
{ {
...@@ -203,7 +255,7 @@ class Script(BaseScript): ...@@ -203,7 +255,7 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Значение частоты сети", "description": "ИБП. Значение частоты сети",
"measurement": "Hertz", "measurement": "Hertz",
"labels": ["noc::sensor::placement::ups"], "labels": ["noc::sensor::placement::ups", "noc::sensor::target::supply"],
"snmp_oid": "1.3.6.1.4.1.51315.1.34.0", "snmp_oid": "1.3.6.1.4.1.51315.1.34.0",
}, },
{ {
...@@ -211,7 +263,11 @@ class Script(BaseScript): ...@@ -211,7 +263,11 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Выходное напряжение.", "description": "ИБП. Выходное напряжение.",
"measurement": "Volt AC", "measurement": "Volt AC",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::voltage",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.35.0", "snmp_oid": "1.3.6.1.4.1.51315.1.35.0",
}, },
{ {
...@@ -219,15 +275,21 @@ class Script(BaseScript): ...@@ -219,15 +275,21 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Нагрузка ИБП в %.", "description": "ИБП. Нагрузка ИБП в %.",
"measurement": "Percent", "measurement": "Percent",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.37.0", "snmp_oid": "1.3.6.1.4.1.51315.1.37.0",
}, },
{ {
"name": "ups_load_P", "name": "ups_load_W",
"status": bool(v), "status": bool(v),
"description": "ИБП. Нагрузка ИБП в W.", "description": "ИБП. Нагрузка ИБП в W.",
"measurement": "Watt", "measurement": "Watt",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::target::power_load",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.36.0", "snmp_oid": "1.3.6.1.4.1.51315.1.36.0",
}, },
{ {
...@@ -235,15 +297,23 @@ class Script(BaseScript): ...@@ -235,15 +297,23 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Напряжение батареи ИБП.", "description": "ИБП. Напряжение батареи ИБП.",
"measurement": "Volt AC", "measurement": "Volt AC",
"labels": ["noc::sensor::placement::ups", "noc::sensor::mode::voltage"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::voltage",
"noc::sensor::target::power_cell",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.40.0", "snmp_oid": "1.3.6.1.4.1.51315.1.40.0",
}, },
{ {
"name": "ups_battery_capasity", "name": "ups_battery_state_of_charge",
"status": bool(v), "status": bool(v),
"description": "ИБП. Ёмкость батареи в %.", "description": "ИБП. Ёмкость батареи в %.",
"measurement": "Percent", "measurement": "Percent",
"labels": ["noc::sensor::placement::ups"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::soc",
"noc::sensor::target::power_cell",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.41.0", "snmp_oid": "1.3.6.1.4.1.51315.1.41.0",
}, },
{ {
...@@ -251,14 +321,26 @@ class Script(BaseScript): ...@@ -251,14 +321,26 @@ class Script(BaseScript):
"status": bool(v), "status": bool(v),
"description": "ИБП. Температура батареи", "description": "ИБП. Температура батареи",
"measurement": "Celsius", "measurement": "Celsius",
"labels": ["noc::sensor::placement::ups", "noc::sensor::mode::temperature"], "labels": [
"noc::sensor::placement::ups",
"noc::sensor::mode::temperature",
"noc::sensor::target::power_cell",
],
"snmp_oid": "1.3.6.1.4.1.51315.1.39.0", "snmp_oid": "1.3.6.1.4.1.51315.1.39.0",
}, },
] ]
return r return r
femto_input_config_map = { femto_input_config_map = {
0: {"type": "in", "units": "StatusEnum", "labels": ["noc::sensor::placement::external"]}, 0: {
"type": "in",
"units": "StatusEnum",
"labels": [
"noc::sensor::placement::external",
"noc::sensor::mode::flag",
"noc::sensor::target::door",
],
},
1: { 1: {
"type": "volt", "type": "volt",
"units": "Volt AC", "units": "Volt AC",
...@@ -269,7 +351,7 @@ class Script(BaseScript): ...@@ -269,7 +351,7 @@ class Script(BaseScript):
"units": "Scalar", "units": "Scalar",
"labels": ["noc::sensor::placement::external", "noc::sensor::mode::counter"], "labels": ["noc::sensor::placement::external", "noc::sensor::mode::counter"],
}, },
3: {"type": "vibration", "units": "Scalar", "labels": []}, 3: {"type": "vibration", "units": "Scalar", "labels": ["noc::sensor::placement::internal"]},
4: { 4: {
"type": "impedance", "type": "impedance",
"units": "Scalar", "units": "Scalar",
...@@ -323,10 +405,3 @@ class Script(BaseScript): ...@@ -323,10 +405,3 @@ class Script(BaseScript):
return self.get_femto_sensors() return self.get_femto_sensors()
else: