Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
noc
noc
Commits
f73fd834
Commit
f73fd834
authored
Jun 25, 2022
by
Andrey Vertiprahov
Browse files
Merge branch 'cherry-pick-
d8494591
' into 'release-22.1'
release-22.1:Backport!6410 See merge request
!6411
parents
9dd1f98a
14e0f5fe
Changes
10
Hide whitespace changes
Inline
Side-by-side
sa/profiles/ElectronR/KO01M/get_chassis_id.py
View file @
f73fd834
...
...
@@ -6,7 +6,7 @@
# ---------------------------------------------------------------------
# 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
...
...
@@ -15,8 +15,4 @@ class Script(BaseScript):
cache
=
True
interface
=
IGetChassisID
def
execute_snmp
(
self
):
# Try SNMP first
base
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.1.1.6.0"
)
if
base
:
return
[{
"first_chassis_mac"
:
base
,
"last_chassis_mac"
:
base
}]
SNMP_GET_OIDS
=
{
"SNMP"
:
[
"1.3.6.1.4.1.35419.1.1.6.0"
]}
sa/profiles/ElectronR/KO01M/get_interface_status_ex.py
View file @
f73fd834
...
...
@@ -16,26 +16,8 @@ class Script(BaseScript):
requires
=
[]
def
execute_snmp
(
self
,
interfaces
=
None
):
index
=
[
1
,
2
,
3
,
4
,
5
]
result
=
[]
temp
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.140.0"
,
cached
=
True
)
t_st
=
False
if
temp
!=
-
104
:
t_st
=
True
result
+=
[{
"interface"
:
"Temperature"
,
"admin_status"
:
t_st
,
"oper_status"
:
t_st
}]
impulse
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.160.0"
,
cached
=
True
)
i_st
=
False
if
impulse
!=
0
:
i_st
=
True
result
+=
[{
"interface"
:
"Pulse"
,
"admin_status"
:
i_st
,
"oper_status"
:
i_st
}]
for
ifindex
in
index
:
status
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.10%s.0"
%
ifindex
)
if
status
==
0
:
s_status
=
False
else
:
s_status
=
True
result
+=
[{
"interface"
:
ifindex
,
"admin_status"
:
s_status
,
"oper_status"
:
s_status
}]
result
+=
[
return
[
{
"interface"
:
"eth0"
,
"admin_status"
:
True
,
...
...
@@ -45,4 +27,3 @@ class Script(BaseScript):
"out_speed"
:
10000
,
}
]
return
result
sa/profiles/ElectronR/KO01M/get_interfaces.py
View file @
f73fd834
...
...
@@ -16,15 +16,18 @@ class Script(BaseScript):
def
execute_snmp
(
self
):
interfaces
=
[
return
[
{
"type"
:
"physical"
,
"name"
:
"eth0"
,
"admin_status"
:
True
,
"oper_status"
:
True
,
"mac"
:
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.1.1.6.0"
),
"snmp_ifindex"
:
100
,
"subinterfaces"
:
[],
"interfaces"
:
[
{
"type"
:
"physical"
,
"name"
:
"eth0"
,
"admin_status"
:
True
,
"oper_status"
:
True
,
"mac"
:
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.1.1.6.0"
),
"snmp_ifindex"
:
100
,
"subinterfaces"
:
[],
}
]
}
]
return
[{
"interfaces"
:
interfaces
}]
sa/profiles/ElectronR/KO01M/get_inventory.py
View file @
f73fd834
...
...
@@ -30,6 +30,7 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
"Датчик числа импульсов"
,
"measurement"
:
"Scalar"
,
"labels"
:
[
"noc::sensor::placement::external"
,
"noc::sensor::mode::counter"
],
"snmp_oid"
:
"1.3.6.1.4.1.35419.20.1.160.0"
,
},
]
...
...
@@ -43,14 +44,8 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
f
"Цифровой вход номер
{
i
}
"
,
"measurement"
:
"Scalar"
,
"labels"
:
[
"noc::sensor::placement::external"
],
"snmp_oid"
:
f
"1.3.6.1.4.1.35419.20.1.
{
100
+
i
}
.0"
,
}
]
return
r
def
execute_snmp
(
self
):
r
=
self
.
get_inv_from_version
()
sensors
=
self
.
get_chassis_sensors
()
if
sensors
:
r
[
0
][
"sensors"
]
=
sensors
return
r
sa/profiles/ElectronR/KO01M/get_metrics.py
View file @
f73fd834
...
...
@@ -6,81 +6,8 @@
# ---------------------------------------------------------------------
# NOC modules
from
noc.sa.profiles.Generic.get_metrics
import
Script
as
GetMetricsScript
,
metrics
from
noc.sa.profiles.Generic.get_metrics
import
Script
as
GetMetricsScript
class
Script
(
GetMetricsScript
):
name
=
"ElectronR.KO01M.get_metrics"
@
metrics
([
"Environment | Sensor Status"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_sensor_status
(
self
,
metrics
):
for
metric
in
metrics
:
value
=
1
if
metric
.
ifindex
==
100
:
continue
elif
metric
.
ifindex
==
140
:
temp
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.140.0"
,
cached
=
True
)
if
-
55
<
temp
<
600
:
value
=
0
elif
metric
.
ifindex
==
160
:
impulse
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.160.0"
,
cached
=
True
)
if
impulse
!=
0
:
value
=
0
else
:
res
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.10%s.0"
%
metric
.
ifindex
)
if
res
==
1
:
value
=
0
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
self
.
set_metric
(
id
=
(
"Environment | Sensor Status"
,
metric
.
labels
),
labels
=
[
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
)
@
metrics
([
"Environment | Temperature"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_temperature
(
self
,
metrics
):
for
metric
in
metrics
:
if
metric
.
ifindex
==
140
:
value
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.%s.0"
%
metric
.
ifindex
,
cached
=
True
)
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
self
.
set_metric
(
id
=
(
"Environment | Temperature"
,
metric
.
labels
),
labels
=
[
f
"noc::module::
{
port
}
"
,
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
multi
=
True
,
)
@
metrics
([
"Environment | Voltage"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_voltage
(
self
,
metrics
):
for
metric
in
metrics
:
value
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.%s.0"
%
metric
.
ifindex
)
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
self
.
set_metric
(
id
=
(
"Environment | Voltage"
,
metric
.
labels
),
labels
=
[
f
"noc::module::
{
port
}
"
,
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
multi
=
True
,
)
@
metrics
([
"Environment | Pulse"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_pulse
(
self
,
metrics
):
for
metric
in
metrics
:
if
metric
.
ifindex
==
160
:
value
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.%s.0"
%
metric
.
ifindex
,
cached
=
True
)
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
self
.
set_metric
(
id
=
(
"Environment | Pulse"
,
metric
.
labels
),
labels
=
[
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
)
@
metrics
([
"Environment | Power | Input | Status"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_power_input_status
(
self
,
metrics
):
for
metric
in
metrics
:
value
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.35419.20.1.10%s.0"
%
metric
.
ifindex
,
cached
=
True
)
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
self
.
set_metric
(
id
=
(
"Environment | Power | Input | Status"
,
metric
.
labels
),
labels
=
[
f
"noc::sensor::
{
port
}
"
],
value
=
0
if
value
==
1
else
1
,
)
sa/profiles/Generic/get_inventory.py
View file @
f73fd834
# ---------------------------------------------------------------------
# Generic.get_inventory
# ---------------------------------------------------------------------
# Copyright (C) 2007-20
19
The NOC Project
# Copyright (C) 2007-20
22
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python Modules
from
typing
import
Dict
,
List
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetinventory
import
IGetInventory
...
...
@@ -14,6 +17,21 @@ class Script(BaseScript):
name
=
"Generic.get_inventory"
interface
=
IGetInventory
def
get_sensor_labels
(
self
)
->
Dict
[
str
,
List
[
str
]]:
"""
For customizing. Return map sensor_name -> label.
For sensor classification
:return:
"""
return
{}
def
get_chassis_sensors
(
self
):
"""
Return sensors on device chassis
:return:
"""
return
[]
def
get_inv_from_version
(
self
):
v
=
self
.
scripts
.
get_version
()
serial
=
None
...
...
@@ -33,8 +51,24 @@ class Script(BaseScript):
}
]
def
processed_inventory
(
self
):
chassis
=
self
.
get_inv_from_version
()
sensors
=
self
.
get_chassis_sensors
()
if
not
sensors
or
not
chassis
:
return
chassis
chassis
[
0
][
"sensors"
]
=
sensors
sensor_labels
=
self
.
get_sensor_labels
()
if
not
sensor_labels
:
return
chassis
for
ss
in
sensors
:
if
ss
[
"name"
]
in
sensor_labels
and
"labels"
in
ss
:
ss
[
"labels"
]
+=
sensor_labels
[
ss
[
"name"
]]
elif
ss
[
"name"
]
in
sensor_labels
and
"labels"
not
in
ss
:
ss
[
"labels"
]
=
sensor_labels
[
ss
[
"name"
]]
return
chassis
def
execute_snmp
(
self
):
return
self
.
get_inv_from_version
()
return
self
.
processed_inventory
()
def
execute_cli
(
self
):
return
self
.
get_inv_from_version
()
return
self
.
processed_inventory
()
sa/profiles/Rotek/BT/get_interface_status_ex.py
View file @
f73fd834
# ---------------------------------------------------------------------
# Rotek.BT.get_interface_status_ex
# ---------------------------------------------------------------------
# Copyright (C) 2007-202
0
The NOC Project
# Copyright (C) 2007-202
2
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -9,7 +9,6 @@
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetinterfacestatusex
import
IGetInterfaceStatusEx
from
noc.core.validators
import
is_float
from
noc.core.mib
import
mib
...
...
@@ -28,26 +27,5 @@ class Script(BaseScript):
result
+=
[{
"interface"
:
name
,
"admin_status"
:
a_status
,
"oper_status"
:
o_status
}]
except
Exception
:
result
+=
[{
"interface"
:
"st"
,
"admin_status"
:
True
,
"oper_status"
:
True
}]
for
index
in
self
.
profile
.
PORT_TYPE
.
keys
():
s_status
=
0
status
=
self
.
snmp
.
get
(
f
"1.3.6.1.4.1.41752.5.15.1.
{
index
}
.0"
)
if
status
is
None
:
continue
if
index
==
1
and
int
(
status
)
==
0
:
s_status
=
1
elif
index
==
2
:
if
is_float
(
status
)
and
(
-
55
<
float
(
status
)
<
600
):
s_status
=
1
elif
index
in
[
4
,
6
]
and
float
(
status
)
>
0
:
s_status
=
1
elif
index
==
9
and
int
(
status
)
!=
2
:
s_status
=
1
result
+=
[
{
"interface"
:
self
.
profile
.
IFACE_NAME
.
get
(
index
),
"admin_status"
:
s_status
,
"oper_status"
:
s_status
,
}
]
return
result
sa/profiles/Rotek/BT/get_interfaces.py
View file @
f73fd834
# ----------------------------------------------------------------------
# Rotek.BT.get_interfaces
# ----------------------------------------------------------------------
# Copyright (C) 2007-202
0
The NOC Project
# Copyright (C) 2007-202
2
The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetinterfaces
import
IGetInterfaces
from
noc.core.validators
import
is_float
from
noc.core.mib
import
mib
...
...
@@ -34,14 +33,13 @@ class Script(BaseScript):
raise
NotImplementedError
def
execute_snmp
(
self
):
interfaces
=
[]
try
:
ifindex
=
self
.
snmp
.
get
(
"1.3.6.1.2.1.2.2.1.1.1"
)
name
=
self
.
snmp
.
get
(
mib
[
"IF-MIB::ifDescr"
,
ifindex
])
mac
=
self
.
snmp
.
get
(
mib
[
"IF-MIB::ifPhysAddress"
,
ifindex
])
a_status
=
self
.
snmp
.
get
(
mib
[
"IF-MIB::ifAdminStatus"
,
ifindex
])
o_status
=
self
.
snmp
.
get
(
mib
[
"IF-MIB::ifOperStatus"
,
ifindex
])
interfaces
+
=
[
interfaces
=
[
{
"type"
:
"physical"
,
"name"
:
name
,
...
...
@@ -53,7 +51,7 @@ class Script(BaseScript):
]
except
Exception
:
mac
=
self
.
scripts
.
get_chassis_id
()[
0
].
get
(
"first_chassis_mac"
)
interfaces
+
=
[
interfaces
=
[
{
"type"
:
"physical"
,
"name"
:
"st"
,
...
...
@@ -63,30 +61,5 @@ class Script(BaseScript):
"subinterfaces"
:
[],
}
]
if
self
.
is_4250lsr
:
return
[{
"interfaces"
:
interfaces
}]
for
index
in
self
.
profile
.
PORT_TYPE
.
keys
():
s_status
=
0
status
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.41752.5.15.1.%s.0"
%
index
)
if
index
==
1
and
int
(
status
)
==
0
:
s_status
=
1
elif
index
==
2
:
if
is_float
(
status
)
and
(
-
55
<
float
(
status
)
<
600
):
s_status
=
1
elif
index
in
[
4
,
6
]
and
float
(
status
)
>
0
:
s_status
=
1
elif
index
==
9
and
int
(
status
)
!=
2
:
s_status
=
1
interfaces
+=
[
{
"type"
:
"physical"
,
"name"
:
self
.
profile
.
IFACE_NAME
.
get
(
index
),
"admin_status"
:
s_status
,
"oper_status"
:
s_status
,
"snmp_ifindex"
:
index
,
"description"
:
self
.
profile
.
PORT_TYPE
.
get
(
index
),
"subinterfaces"
:
[],
}
]
return
[{
"interfaces"
:
interfaces
}]
sa/profiles/Rotek/BT/get_inventory.py
View file @
f73fd834
# ---------------------------------------------------------------------
# Rotek.BT.get_inventory
# ---------------------------------------------------------------------
# Copyright (C) 2007-20
19
The NOC Project
# Copyright (C) 2007-20
22
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -14,8 +14,7 @@ class Script(BaseScript):
name
=
"Rotek.BT.get_inventory"
interface
=
IGetInventory
@
staticmethod
def
get_chassis_sensors
():
def
get_chassis_sensors_default
(
self
):
r
=
[
# In
{
...
...
@@ -80,7 +79,11 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
"Дверь"
,
"measurement"
:
"StatusEnum"
,
"labels"
:
[
"noc::sensor::placement::external"
],
"labels"
:
[
"noc::sensor::placement::external"
,
"noc::sensor::mode::flag"
,
"noc::sensor::target::door"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.1.0"
,
},
# v230
...
...
@@ -89,6 +92,11 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
"Флаг наличия сетевого напряжения AC 230В"
,
"measurement"
:
"StatusEnum"
,
"labels"
:
[
"noc::sensor::placement::external"
,
"noc::sensor::mode::flag"
,
"noc::sensor::target::supply"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.9.0"
,
},
]
...
...
@@ -114,7 +122,11 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
"Ток потребления нагрузки"
,
"measurement"
:
"Ampere"
,
"labels"
:
[
"noc::sensor::placement::external"
,
"noc::sensor::mode::current"
],
"labels"
:
[
"noc::sensor::placement::ups"
,
"noc::sensor::mode::voltage"
,
"noc::sensor::target::power_load"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.3.0"
,
},
{
...
...
@@ -122,7 +134,11 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
"ИБП. Напряжение на АКБ"
,
"measurement"
:
"Volt AC"
,
"labels"
:
[
"noc::sensor::placement::external"
,
"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.41752.911.10.1.6.0"
,
},
{
...
...
@@ -130,7 +146,11 @@ class Script(BaseScript):
"status"
:
True
,
"description"
:
"Ток заряда АКБ"
,
"measurement"
:
"Ampere"
,
"labels"
:
[
"noc::sensor::placement::external"
,
"noc::sensor::mode::current"
],
"labels"
:
[
"noc::sensor::placement::ups"
,
"noc::sensor::mode::current"
,
"noc::sensor::target::power_cell"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.5.0"
,
},
]
...
...
@@ -144,6 +164,11 @@ class Script(BaseScript):
"status"
:
bool
(
v
),
"description"
:
"Электросчётчик. Значение напряжения сети"
,
"measurement"
:
"Volt AC"
,
"labels"
:
[
"noc::sensor::placement::elmeter"
,
"noc::sensor::mode::voltage"
,
"noc::sensor::target::supply"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.13.2.0"
,
},
{
...
...
@@ -151,6 +176,11 @@ class Script(BaseScript):
"status"
:
bool
(
v
),
"description"
:
"Электросчётчик. Значение потребляемого тока"
,
"measurement"
:
"Ampere"
,
"labels"
:
[
"noc::sensor::placement::elmeter"
,
"noc::sensor::mode::current"
,
"noc::sensor::target::power_load"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.13.3.0"
,
},
{
...
...
@@ -158,6 +188,11 @@ class Script(BaseScript):
"status"
:
bool
(
v
),
"description"
:
"Электросчётчик. Значение потребляемой мощности"
,
"measurement"
:
"Watt"
,
"labels"
:
[
"noc::sensor::placement::elmeter"
,
"noc::sensor::mode::watt"
,
"noc::sensor::target::power_load"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.13.10.0"
,
},
{
...
...
@@ -165,6 +200,11 @@ class Script(BaseScript):
"status"
:
bool
(
v
),
"description"
:
"Электросчётчик. значение частоты сети"
,
"measurement"
:
"Hertz"
,
"labels"
:
[
"noc::sensor::placement::elmeter"
,
"noc::sensor::mode::freq"
,
"noc::sensor::target::power_load"
,
],
"snmp_oid"
:
"1.3.6.1.4.1.41752.911.10.1.13.9.0"
,
},
]
...
...
@@ -177,17 +217,18 @@ class Script(BaseScript):
"status"
:
bool
(
v
),
"description"
:
f
"Электросчётчик. Суммарное значение потреблённой мощности по тарифу
{
num
}
"
,
"measurement"
:
"Kilowatt-hour"
,
"labels"
:
[
"noc::sensor::placement::elmeter"
,
"noc::sensor::mode::kwh"
,
"noc::sensor::target::power_load"
,
],
"snmp_oid"
:
f
"1.3.6.1.4.1.41752.911.10.1.13.
{
4
+
num
}
.0"
,
}
]
return
r
def
execute_snmp
(
self
):
r
=
self
.
get_inv_from_version
()
def
get_chassis_sensors
(
self
):
if
self
.
is_4250lsr
:
sensors
=
self
.
get_chassis_sensors_4250lsr
()
return
self
.
get_chassis_sensors_4250lsr
()
else
:
sensors
=
self
.
get_chassis_sensors
()
if
sensors
:
r
[
0
][
"sensors"
]
=
sensors
return
r
return
self
.
get_chassis_sensors_default
()
sa/profiles/Rotek/BT/get_metrics.py
View file @
f73fd834
# ---------------------------------------------------------------------
# Rotek.BT.get_metrics
# ---------------------------------------------------------------------
# Copyright (C) 2007-202
0
The NOC Project
# Copyright (C) 2007-202
2
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from
noc.sa.profiles.Generic.get_metrics
import
Script
as
GetMetricsScript
,
metrics
from
noc.core.validators
import
is_float
from
noc.sa.profiles.Generic.get_metrics
import
Script
as
GetMetricsScript
from
noc.core.script.metrics
import
scale
...
...
@@ -31,75 +30,3 @@ class Script(GetMetricsScript):
"1.3.6.1.4.1.41752.911.10.1.13.10.0"
:
scale
(
0.000001
,
2
),
"1.3.6.1.4.1.41752.911.10.1.13.13.0"
:
scale
(
0.001
,
2
),
}
@
metrics
([
"Environment | Sensor Status"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_sensor_status
(
self
,
metrics
):
for
metric
in
metrics
:
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
if
"st"
in
port
:
continue
value
=
1
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
status
=
self
.
snmp
.
get
(
f
"1.3.6.1.4.1.41752.5.15.1.
{
metric
.
ifindex
}
.0"
)
if
status
is
None
:
continue
if
metric
.
ifindex
==
1
and
int
(
status
)
==
0
:
value
=
0
elif
metric
.
ifindex
==
2
:
if
is_float
(
status
)
and
(
-
55
<
float
(
status
)
<
600
):
value
=
0
elif
metric
.
ifindex
in
[
4
,
6
]
and
float
(
status
)
>
0
:
value
=
0
elif
metric
.
ifindex
==
9
and
int
(
status
)
!=
2
:
value
=
0
self
.
set_metric
(
id
=
(
"Environment | Sensor Status"
,
metric
.
labels
),
labels
=
[
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
)
@
metrics
([
"Environment | Temperature"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_temperature
(
self
,
metrics
):
for
metric
in
metrics
:
if
not
metric
.
labels
:
continue
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
if
"temp"
in
port
:
value
=
self
.
snmp
.
get
(
f
"1.3.6.1.4.1.41752.5.15.1.
{
metric
.
ifindex
}
.0"
)
if
value
is
None
:
continue
if
is_float
(
value
):
self
.
set_metric
(
id
=
(
"Environment | Temperature"
,
metric
.
labels
),
labels
=
[
f
"noc::module::
{
port
}
"
,
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
multi
=
True
,
)
@
metrics
([
"Environment | Voltage"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_voltage
(
self
,
metrics
):
for
metric
in
metrics
:
value
=
self
.
snmp
.
get
(
f
"1.3.6.1.4.1.41752.5.15.1.
{
metric
.
ifindex
}
.0"
)
if
value
is
None
:
continue
port
=
metric
.
labels
[
0
].
rsplit
(
"::"
,
1
)[
-
1
]
self
.
set_metric
(
id
=
(
"Environment | Voltage"
,
metric
.
labels
),
labels
=
[
"noc::module::battery"
,
f
"noc::sensor::
{
port
}
"
],
value
=
value
,
multi
=
True
,
)
@
metrics
([
"Environment | Power | Input | Status"
],
volatile
=
False
,
access
=
"S"
)
# SNMP version
def
get_power_input_status
(
self
,
metrics
):
for
metric
in
metrics
:
value
=
1
res
=
self
.
snmp
.
get
(
"1.3.6.1.4.1.41752.5.15.1.9.0"
)