Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit e8e2b94f authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 1d5b54ec
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/inv_opengear_serial_line-0.1.2-20240510.mkp "inv_opengear_serial_line-0.1.2-20240510.mkp"
# Hardware inventory
### Plugin Info
......
File moved
File moved
File deleted
File added
......@@ -12,20 +12,26 @@
#
# 2023-02-20: moved gui files from ~/local/share/check_mk/... to ~/local/lib/check_mk...
# 2023-06-16: removed unused inventory_ruleset_name and params
# 2024-05-10: fixed wrong inventory function name
# integrated .1.3.6.1.4.1.25049.17.2.1 and .1.3.6.1.4.1.25049.10.19.2.2.1
from collections.abc import Mapping, Sequence
from typing import List
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
OIDEnd,
SNMPTree,
TableRow,
register,
startswith,
OIDEnd,
)
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
StringTable,
InventoryResult,
StringTable,
)
_opengear_state = {
'0': 'off',
'1': 'on',
'2': 'off',
}
......@@ -66,12 +72,26 @@ _opengear_parity = {
'5': 'space',
}
SECTION = Sequence[Mapping[str, Mapping[str, str]]]
def parse_inv_opengear_serial_lines(string_table: List[StringTable]) -> SECTION | None:
try:
raw_data, raw_data_v2 = string_table
except ValueError:
return
if not raw_data:
raw_data = raw_data_v2
def parse_inv_opengear_serial_lines(string_table: StringTable):
section = []
for index, label, speed, databits, parity, stopbits, flowcontrol, mode, loglevel, \
dcd, dtr, dsr, cts, rts in string_table:
for line in raw_data:
try:
index, label, speed, databits, parity, stopbits, flowcontrol, mode, loglevel, dcd, dtr, dsr, cts, rts = line
except ValueError:
return
entry = {
'key_columns': {
'index': f'{int(index):02}'
......@@ -92,7 +112,6 @@ def parse_inv_opengear_serial_lines(string_table: StringTable):
'rts': _opengear_state[rts],
},
'status_columns': {
}
}
......@@ -101,7 +120,7 @@ def parse_inv_opengear_serial_lines(string_table: StringTable):
return section
def inventory_bgp_peers(section) -> InventoryResult:
def inv_opengear_serial_lines(section: SECTION) -> InventoryResult:
path = ['hardware', 'serial_lines']
for entry in section:
......@@ -116,35 +135,63 @@ def inventory_bgp_peers(section) -> InventoryResult:
register.snmp_section(
name='inv_opengear_serial_lines',
parse_function=parse_inv_opengear_serial_lines,
fetch=SNMPTree(
base='.1.3.6.1.4.1.25049.17.2.1', # OG-STATUSv2-MIB:orgSerialPortEntry
oids=[
OIDEnd(), # line index
'2', # ogSerialPortLabel
'3', # ogSerialPortSpeed
'4', # ogSerialPortDataBits
'5', # ogSerialPortParity
'6', # ogSerialPortStopBits
'7', # ogSerialPortFlowControl
'8', # ogSerialPortMode
'9', # ogSerialPortLogLevel
# '10', # ogSerialPortRxBytes
# '11', # ogSerialPortTxBytes
# '12', # ogSerialPortFramingErrors
# '13', # ogSerialPortParityErrors
# '14', # ogSerialPortOverrunErrors
# '15', # ogSerialPortBreaks
'16', # ogSerialPortDCD
'17', # ogSerialPortDTR
'18', # ogSerialPortDSR
'19', # ogSerialPortCTS
'20', # ogSerialPortRTS
]
),
detect=startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.25049'), # sysObjectID == opengear
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.25049.17.2.1', # OG-STATUSv2-MIB:orgSerialPortEntry
oids=[
OIDEnd(), # line index
'2', # ogSerialPortLabel
'3', # ogSerialPortSpeed
'4', # ogSerialPortDataBits
'5', # ogSerialPortParity
'6', # ogSerialPortStopBits
'7', # ogSerialPortFlowControl
'8', # ogSerialPortMode
'9', # ogSerialPortLogLevel
# '10', # ogSerialPortRxBytes
# '11', # ogSerialPortTxBytes
# '12', # ogSerialPortFramingErrors
# '13', # ogSerialPortParityErrors
# '14', # ogSerialPortOverrunErrors
# '15', # ogSerialPortBreaks
'16', # ogSerialPortDCD
'17', # ogSerialPortDTR
'18', # ogSerialPortDSR
'19', # ogSerialPortCTS
'20', # ogSerialPortRTS
]
),
SNMPTree(
base='.1.3.6.1.4.1.25049.10.19.2.2.1', #
oids=[
OIDEnd(), # line index
'2', # ogSerialPortLabel
'3', # ogSerialPortSpeed
'4', # ogSerialPortDataBits
'5', # ogSerialPortParity
'6', # ogSerialPortStopBits
'7', # ogSerialPortFlowControl
'8', # ogSerialPortMode
'9', # ogSerialPortLogLevel
# '10', # ogSerialPortRxBytes
# '11', # ogSerialPortTxBytes
# '12', # ogSerialPortFramingErrors
# '13', # ogSerialPortParityErrors
# '14', # ogSerialPortOverrunErrors
# '15', # ogSerialPortBreaks
'16', # ogSerialPortDCD
'17', # ogSerialPortDTR
'18', # ogSerialPortDSR
'19', # ogSerialPortCTS
'20', # ogSerialPortRTS
]
),
],
detect=startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.25049'),
)
register.inventory_plugin(
name='inv_opengear_serial_lines',
inventory_function=inventory_bgp_peers,
inventory_function=inv_opengear_serial_lines,
)
......@@ -2,10 +2,10 @@
'description': 'Inventory for opengear KVM devices serial lines\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_opengear_serial_lines.py'],
'gui': ['views/inv_opengear_serial_lines.py']},
'web': ['plugins/views/inv_opengear_serial_lines.py']},
'name': 'inv_opengear_serial_line',
'title': 'opengear serial line inventory',
'version': '0.1.1-20230614',
'version': '0.1.2-20240510',
'version.min_required': '2.2.0b1',
'version.packaged': '2.2.0p2',
'version.packaged': '2.2.0p24',
'version.usable_until': None}
......@@ -11,18 +11,17 @@
# 2023-02-20: moved from ~/local/share/check_mk/... to ~/local/lib/check_mk...
# 2023-06-14: removed declare_invtable_view from view definition on cmk 2.2 (see werk 15493)
# changed inventory_displayhints import (see werk 15493)
# 2024-05-10: moved back to ~/local/share/check_mk/... from ~/local/lib/check_mk... fixed crash in web.log
from cmk.gui.i18n import _
from cmk.gui.views.inventory.registry import inventory_displayhints
inventory_displayhints.update({
'.hardware.serial_lines:': {
'title': _('Serial lines'),
'keyorder': [
'index',
'label',
'label',
'speed', 'databits', 'parity', 'stopbits', 'flowcontrol'
],
'view': 'invseriallines_of_host',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment