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 # Hardware inventory
### Plugin Info ### Plugin Info
......
File moved
File moved
File deleted
File added
...@@ -12,20 +12,26 @@ ...@@ -12,20 +12,26 @@
# #
# 2023-02-20: moved gui files from ~/local/share/check_mk/... to ~/local/lib/check_mk... # 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 # 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 ( from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register, OIDEnd,
SNMPTree, SNMPTree,
TableRow, TableRow,
register,
startswith, startswith,
OIDEnd,
) )
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
StringTable,
InventoryResult, InventoryResult,
StringTable,
) )
_opengear_state = { _opengear_state = {
'0': 'off',
'1': 'on', '1': 'on',
'2': 'off', '2': 'off',
} }
...@@ -66,12 +72,26 @@ _opengear_parity = { ...@@ -66,12 +72,26 @@ _opengear_parity = {
'5': 'space', '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 = [] section = []
for index, label, speed, databits, parity, stopbits, flowcontrol, mode, loglevel, \ for line in raw_data:
dcd, dtr, dsr, cts, rts in string_table: try:
index, label, speed, databits, parity, stopbits, flowcontrol, mode, loglevel, dcd, dtr, dsr, cts, rts = line
except ValueError:
return
entry = { entry = {
'key_columns': { 'key_columns': {
'index': f'{int(index):02}' 'index': f'{int(index):02}'
...@@ -92,7 +112,6 @@ def parse_inv_opengear_serial_lines(string_table: StringTable): ...@@ -92,7 +112,6 @@ def parse_inv_opengear_serial_lines(string_table: StringTable):
'rts': _opengear_state[rts], 'rts': _opengear_state[rts],
}, },
'status_columns': { 'status_columns': {
} }
} }
...@@ -101,7 +120,7 @@ def parse_inv_opengear_serial_lines(string_table: StringTable): ...@@ -101,7 +120,7 @@ def parse_inv_opengear_serial_lines(string_table: StringTable):
return section return section
def inventory_bgp_peers(section) -> InventoryResult: def inv_opengear_serial_lines(section: SECTION) -> InventoryResult:
path = ['hardware', 'serial_lines'] path = ['hardware', 'serial_lines']
for entry in section: for entry in section:
...@@ -116,35 +135,63 @@ def inventory_bgp_peers(section) -> InventoryResult: ...@@ -116,35 +135,63 @@ def inventory_bgp_peers(section) -> InventoryResult:
register.snmp_section( register.snmp_section(
name='inv_opengear_serial_lines', name='inv_opengear_serial_lines',
parse_function=parse_inv_opengear_serial_lines, parse_function=parse_inv_opengear_serial_lines,
fetch=SNMPTree( fetch=[
base='.1.3.6.1.4.1.25049.17.2.1', # OG-STATUSv2-MIB:orgSerialPortEntry SNMPTree(
oids=[ base='.1.3.6.1.4.1.25049.17.2.1', # OG-STATUSv2-MIB:orgSerialPortEntry
OIDEnd(), # line index oids=[
'2', # ogSerialPortLabel OIDEnd(), # line index
'3', # ogSerialPortSpeed '2', # ogSerialPortLabel
'4', # ogSerialPortDataBits '3', # ogSerialPortSpeed
'5', # ogSerialPortParity '4', # ogSerialPortDataBits
'6', # ogSerialPortStopBits '5', # ogSerialPortParity
'7', # ogSerialPortFlowControl '6', # ogSerialPortStopBits
'8', # ogSerialPortMode '7', # ogSerialPortFlowControl
'9', # ogSerialPortLogLevel '8', # ogSerialPortMode
# '10', # ogSerialPortRxBytes '9', # ogSerialPortLogLevel
# '11', # ogSerialPortTxBytes # '10', # ogSerialPortRxBytes
# '12', # ogSerialPortFramingErrors # '11', # ogSerialPortTxBytes
# '13', # ogSerialPortParityErrors # '12', # ogSerialPortFramingErrors
# '14', # ogSerialPortOverrunErrors # '13', # ogSerialPortParityErrors
# '15', # ogSerialPortBreaks # '14', # ogSerialPortOverrunErrors
'16', # ogSerialPortDCD # '15', # ogSerialPortBreaks
'17', # ogSerialPortDTR '16', # ogSerialPortDCD
'18', # ogSerialPortDSR '17', # ogSerialPortDTR
'19', # ogSerialPortCTS '18', # ogSerialPortDSR
'20', # ogSerialPortRTS '19', # ogSerialPortCTS
] '20', # ogSerialPortRTS
), ]
detect=startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.25049'), # sysObjectID == opengear ),
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( register.inventory_plugin(
name='inv_opengear_serial_lines', name='inv_opengear_serial_lines',
inventory_function=inventory_bgp_peers, inventory_function=inv_opengear_serial_lines,
) )
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
'description': 'Inventory for opengear KVM devices serial lines\n', 'description': 'Inventory for opengear KVM devices serial lines\n',
'download_url': 'https://thl-cmk.hopto.org', 'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_opengear_serial_lines.py'], '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', 'name': 'inv_opengear_serial_line',
'title': 'opengear serial line inventory', 'title': 'opengear serial line inventory',
'version': '0.1.1-20230614', 'version': '0.1.2-20240510',
'version.min_required': '2.2.0b1', 'version.min_required': '2.2.0b1',
'version.packaged': '2.2.0p2', 'version.packaged': '2.2.0p24',
'version.usable_until': None} 'version.usable_until': None}
...@@ -11,18 +11,17 @@ ...@@ -11,18 +11,17 @@
# 2023-02-20: moved from ~/local/share/check_mk/... to ~/local/lib/check_mk... # 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) # 2023-06-14: removed declare_invtable_view from view definition on cmk 2.2 (see werk 15493)
# changed inventory_displayhints import (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.i18n import _
from cmk.gui.views.inventory.registry import inventory_displayhints from cmk.gui.views.inventory.registry import inventory_displayhints
inventory_displayhints.update({ inventory_displayhints.update({
'.hardware.serial_lines:': { '.hardware.serial_lines:': {
'title': _('Serial lines'), 'title': _('Serial lines'),
'keyorder': [ 'keyorder': [
'index', 'index',
'label', 'label',
'speed', 'databits', 'parity', 'stopbits', 'flowcontrol' 'speed', 'databits', 'parity', 'stopbits', 'flowcontrol'
], ],
'view': 'invseriallines_of_host', '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