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

update project

parent a8a8ec98
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-11-27
#
# inventory of ePowerSwitch
# https://www.neol.com/en/products/epowerswitch/
# sample snmpwalk
# eps8XM-private::version.0 = STRING: "v 3.1.2.2"
# eps8XM-private::DeviceId."" = STRING: "M0"
# eps8XM-private::DeviceId.1 = STRING: "S1"
# eps8XM-private::DeviceId.17 = STRING: "TH1"
# eps8XM-private::DeviceName."" = STRING: "F_Master"
# eps8XM-private::DeviceName.1 = STRING: "F_Satellit"
# eps8XM-private::DeviceName.17 = STRING: "SEN-1"
# eps8XM-private::DeviceActivated."" = Wrong Type (should be INTEGER): STRING: "1"
# eps8XM-private::DeviceActivated.1 = Wrong Type (should be INTEGER): STRING: "1"
# eps8XM-private::DeviceActivated.17 = Wrong Type (should be INTEGER): STRING: "1"
# eps8XM-private::DeviceDetected."" = Wrong Type (should be INTEGER): STRING: "1"
# eps8XM-private::DeviceDetected.1 = Wrong Type (should be INTEGER): STRING: "1"
# eps8XM-private::DeviceDetected.17 = Wrong Type (should be INTEGER): STRING: "1"
# eps8XM-private::DeviceType."" = STRING: "PowerSwitch"
# eps8XM-private::DeviceType.1 = STRING: "Power Switch 8-Port"
# eps8XM-private::DeviceType.17 = STRING: "TH Sensor"
# eps8XM-private::DeviceVersion."" = STRING: "v 3.3.0.0"
# eps8XM-private::DeviceVersion.1 = STRING: "v 4.0.0.5"
# eps8XM-private::DeviceVersion.17 = STRING: "v 7.10.0.0"
#
# .1.3.6.1.4.1.24734.13.1.1.0 = STRING: "v 3.1.2.2"
# .1.3.6.1.4.1.24734.13.2.1.1.1.0 = STRING: "M0"
# .1.3.6.1.4.1.24734.13.2.1.1.1.1 = STRING: "S1"
# .1.3.6.1.4.1.24734.13.2.1.1.1.17 = STRING: "TH1"
# .1.3.6.1.4.1.24734.13.2.1.1.2.0 = STRING: "F_Master"
# .1.3.6.1.4.1.24734.13.2.1.1.2.1 = STRING: "F_Satellit"
# .1.3.6.1.4.1.24734.13.2.1.1.2.17 = STRING: "SEN-1"
# .1.3.6.1.4.1.24734.13.2.1.1.3.0 = Wrong Type (should be INTEGER): STRING: "1"
# .1.3.6.1.4.1.24734.13.2.1.1.3.1 = Wrong Type (should be INTEGER): STRING: "1"
# .1.3.6.1.4.1.24734.13.2.1.1.3.17 = Wrong Type (should be INTEGER): STRING: "1"
# .1.3.6.1.4.1.24734.13.2.1.1.4.0 = Wrong Type (should be INTEGER): STRING: "1"
# .1.3.6.1.4.1.24734.13.2.1.1.4.1 = Wrong Type (should be INTEGER): STRING: "1"
# .1.3.6.1.4.1.24734.13.2.1.1.4.17 = Wrong Type (should be INTEGER): STRING: "1"
# .1.3.6.1.4.1.24734.13.2.1.1.5.0 = STRING: "PowerSwitch"
# .1.3.6.1.4.1.24734.13.2.1.1.5.1 = STRING: "Power Switch 8-Port"
# .1.3.6.1.4.1.24734.13.2.1.1.5.17 = STRING: "TH Sensor"
# .1.3.6.1.4.1.24734.13.2.1.1.6.0 = STRING: "v 3.3.0.0"
# .1.3.6.1.4.1.24734.13.2.1.1.6.1 = STRING: "v 4.0.0.5"
# .1.3.6.1.4.1.24734.13.2.1.1.6.17 = STRING: "v 7.10.0.0"
#
# sample string_table
# [
# [
# ['v 3.1.2.2']
# ],
# [
# ['M0', 'F_Master', '1', '1', 'PowerSwitch', 'v 3.3.0.0'],
# ['S1', 'F_Satellit', '1', '1', 'Power Switch 8-Port', 'v 4.0.0.5'],
# ['TH1', 'SEN-1', '1', '1', 'TH Sensor', 'v 7.10.0.0']
# ]
# ]
#
# sample section
# {
# 'devices':
# [
# {'id': 'M0', 'name': 'F_Master', 'type': 'PowerSwitch', 'version': 'v 3.3.0.0',
# 'status_columns': {'activated': '1', 'detected': '1'}},
# {'id': 'S1', 'name': 'F_Satellit', 'type': 'Power Switch 8-Port', 'version': 'v 4.0.0.5',
# 'status_columns': {'activated': '1', 'detected': '1'}},
# {'id': 'TH1', 'name': 'SEN-1', 'type': 'TH Sensor', 'version': 'v 7.10.0.0',
# 'status_columns': {'activated': '1', 'detected': '1'}}
# ],
# 'version': 'v 3.1.2.2'
# }
from typing import List, NamedTuple, Optional, Dict, Any
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 (
register,
SNMPTree,
TableRow,
Attributes,
startswith,
)
def parse_inv_espm(string_table: List[StringTable]) -> Dict[str, Any]: # Dict[str, str, List[Dict[str, str]]:
version, devices = string_table
section = {}
section['devices'] = []
section['version'] = version[0][0]
for deviceid, devicename, deviceactivated, devicedetected, devicetype, deviceversion in devices:
section['devices'].append({
'id': deviceid,
'name': devicename,
'type': devicetype,
'version': deviceversion,
'status_columns': {
'activated': deviceactivated,
'detected': devicedetected,
},
})
return section
def inventory_hw_modules(params, section: Dict[str, Any]) -> InventoryResult:
path = ['hardware', 'system']
yield Attributes(
path=path,
inventory_attributes={'version': section['version']}
)
path = ['hardware', 'devices']
for device in section['devices']:
key_columns = {'id': device['id']}
for key in key_columns.keys():
device.pop(key)
status_columns = device['status_columns']
device.pop('status_columns')
yield TableRow(
path=path,
key_columns=key_columns,
inventory_columns=device,
status_columns=status_columns,
)
register.snmp_section(
name='inv_espm',
parse_function=parse_inv_espm,
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.24734.13.1', # eps8XM-private::System
oids=[
'1', # version
]
),
SNMPTree(
base='.1.3.6.1.4.1.24734.13.2.1.1', # eps8XM-private::Devices
oids=[
'1', # DeviceId
'2', # DeviceName
'3', # DeviceActivated
'4', # DeviceDetected
'5', # DeviceType
'6', # DeviceVersion
]
),
],
detect=startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.24734.'),
)
register.inventory_plugin(
name='inv_espm',
inventory_function=inventory_hw_modules,
inventory_default_parameters={},
inventory_ruleset_name='inv_espm',
)
File added
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Inventory Neols ePowerSwitch ',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['inv_epsm.py']},
'name': 'inv_epsm',
'num_files': 1,
'title': 'Neol ePowerswitch inventory',
'version': '20211127.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
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