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

update project

parent 40878a9f
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 : 2021-12-25
#
# opengear base inventory
#
# sample string_table
# [
# [
# ['4.1.1u2 594cb83d ()', 'N/A']
# ],
# [
# ['1'], ['1'], ['1'], ['1'], ['1'], ['1'], ['1'], ['1'], ['1'], ['1'], ['2'], ['2'], ['2'], ['2'], ['2'], ['2']
# ],
# [
# ['.1.3.6.1.4.1.25049.1.60']
# ]
# ]
#
from typing import List, Optional
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
StringTable,
InventoryResult,
)
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
Attributes,
register,
SNMPTree,
startswith,
)
_opengear_models = {
('.1.3.6.1.4.1.25049.1.11', 18): 'CM7116', # 16 serial + 2 usb lines
('.1.3.6.1.4.1.25049.1.11', 34): 'CM7132', # 32 serial + 2 usb lines
('.1.3.6.1.4.1.25049.1.11', 48): 'CM7148', # 48 serial + 2 usb lines
('.1.3.6.1.4.1.25049.1.60', 16): 'IM4216', # 16 serial lines
}
def parse_inv_opengear_base(string_table: List[StringTable]) -> Optional[List]:
inv_data, ogSerialPortCTS, sysObjectID = string_table
firmware_version, serial_number = inv_data[0]
if serial_number == 'N/A':
serial_number = ''
number_of_lines = len(ogSerialPortCTS)
sysObjectID = sysObjectID[0][0]
model_name = _opengear_models.get((sysObjectID, number_of_lines), '')
section = []
invPath = ['hardware', 'system']
for key, value in [
('serial', serial_number),
('manufacturer', 'opengear'),
('model', model_name),
]:
if not value == '':
section.append((invPath, key, value))
invPath = ['software', 'firmware']
for key, value in [
('vendor', 'opengear'),
('version', firmware_version),
]:
if not value == '':
section.append((invPath, key, value))
return section
def inventory_opengear_base(section: List) -> InventoryResult:
for invPath, key, value in section:
yield Attributes(
path=invPath,
inventory_attributes={key: value})
register.snmp_section(
name='inv_opengear_base',
parse_function=parse_inv_opengear_base,
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.25049.17.1', # OG-STATUSv2-MIB
oids=[
'1', # ogFirmwareVersion
'2', # ogSerialNumber
]
),
SNMPTree(
base='.1.3.6.1.4.1.25049.17.2.1', # OG-STATUSv2-MIB
oids=[
'19', # ogSerialPortCTS. ogSerialPortIndex don't exist so we use CTS to get the number of lines
]
),
SNMPTree(
base='.1.3.6.1.2.1.1', # SNMPv2-MIB
oids=[
'2', # sysObjectID
]
),
],
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_base',
inventory_function=inventory_opengear_base,
)
File added
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'base inventory for opengear console servers.\n'
'\n'
'Adds the serial number, model, manufacturer and firmware '
'version to the inventory.\n'
'\n'
'Supported models:\n'
'- IM4216\n'
'- CM7116\n'
'- CM7132\n'
'- CM7148\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_opengear_base.py']},
'name': 'inv_opengear_base',
'num_files': 1,
'title': 'opengear base inventory',
'version': '20220628.v.0.01',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
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