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 a2e419b2 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 8c68ce8b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 20212-07-08
# File : inv_opengear_serial_line
#
# inventory of opengear console servers serial lines
#
#
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
SNMPTree,
TableRow,
startswith,
OIDEnd,
)
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
StringTable,
InventoryResult,
)
_opengear_state = {
'1': 'on',
'2': 'off',
}
_opengear_log_level = {
'1': 'disabled',
'2': 'connect',
'3': 'inputAndOutput',
'4': 'inputOnly',
'5': 'outputOnly',
}
_opengear_mode = {
'1': 'none',
'2': 'console',
'3': 'sdt',
'4': 'terminal',
'5': 'bridge',
}
_opengear_flow_control = {
'1': 'none',
'2': 'hardware',
'3': 'software',
}
_opengear_stop_bits = {
'1': 'one',
'2': 'two',
'3': 'oneAndAHalf',
}
_opengear_parity = {
'1': 'none',
'2': 'odd',
'3': 'even',
'4': 'mark',
'5': 'space',
}
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:
entry = {
'key_columns': {
'index': index
},
'inventory_columns': {
'label': label,
'speed': speed,
'databits': databits,
'parity': _opengear_parity.get(parity, parity),
'stopbits': _opengear_stop_bits.get(stopbits, stopbits),
'flowcontrol': _opengear_flow_control.get(flowcontrol, flowcontrol),
'mode': _opengear_mode.get(mode, mode),
'loglevel': _opengear_log_level.get(loglevel, loglevel),
'cts': _opengear_state[cts],
'dcd': _opengear_state[dcd],
'dtr': _opengear_state[dtr],
'rts': _opengear_state[rts],
},
'status_columns': {
}
}
section.append(entry)
return section
def inventory_bgp_peers(params, section) -> InventoryResult:
path = ['hardware', 'serial_lines']
for entry in section:
yield TableRow(
path=path,
key_columns=entry['key_columns'],
inventory_columns=entry['inventory_columns'],
status_columns=entry['status_columns']
)
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
)
register.inventory_plugin(
name='inv_opengear_serial_lines',
inventory_function=inventory_bgp_peers,
inventory_default_parameters={
},
inventory_ruleset_name='inv_opengear_serial_lines',
)
File added
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Inventory for opengear KVM devices serial lines\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_opengear_serial_lines.py'],
'web': ['plugins/views/inv_opengear_serial_lines.py']},
'name': 'inv_opengear_serial_line',
'num_files': 2,
'title': 'opengear serial line inventory',
'version': '20220708.v.0.0.1',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2022-07-08
# File : view/inv_opengear_serial_lines
#
from cmk.gui.i18n import _
from cmk.gui.plugins.views import (
inventory_displayhints,
)
from cmk.gui.plugins.views.inventory import declare_invtable_view
inventory_displayhints.update({
'.hardware.serial_lines:': {
'title': _('Serial lines'),
'keyorder': [
'index',
'label',
'speed', 'databits', 'parity', 'stopbits', 'flowcontrol'
],
'view': 'invseriallines_of_host',
},
'.hardware.serial_lines:*.index': {'title': _('Index'), },
'.hardware.serial_lines:*.label': {'title': _('Label'), },
'.hardware.serial_lines:*.speed': {'title': _('Speed'), },
'.hardware.serial_lines:*.databits': {'title': _('Data bits'), },
'.hardware.serial_lines:*.parity': {'title': _('Parity'), },
'.hardware.serial_lines:*.stopbits': {'title': _('Stop bits'), },
'.hardware.serial_lines:*.flowcontrol': {'title': _('Flow control'), },
'.hardware.serial_lines:*.cts': {'title': _('CTS'), },
'.hardware.serial_lines:*.dcd': {'title': _('DCD'), },
'.hardware.serial_lines:*.dtr': {'title': _('DTR'), },
'.hardware.serial_lines:*.rts': {'title': _('RTS'), },
})
declare_invtable_view('invseriallines', '.hardware.serial_lines:', _('Serial lines'), _('Serial lines'))
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