diff --git a/CHANGELOG b/CHANGELOG index 2c7296e5aa829a87cedd577ad66115b9534ef2ae..027262816e9f3f414ba6eec99f1578fb2957bf18 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1 +1,2 @@ 2021-11-27: initial release +2023-04-22: moved inventory view to ~/local/lib/check_mk/gui/plugins/views diff --git a/agent_based/inv_epsm.py b/agent_based/inv_epsm.py index 48d8022f17593d645152f17ab5ff6db6abf2529f..8609df27f20eecc43a36351c9c58f82e94b3ec76 100644 --- a/agent_based/inv_epsm.py +++ b/agent_based/inv_epsm.py @@ -51,31 +51,7 @@ # .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, Dict, Any @@ -104,6 +80,36 @@ _device_detected = { def parse_inv_espm(string_table: List[StringTable]) -> Dict[str, Any]: + """ + >>> from pprint import pp + >>> modules = [] + >>> modules.append(['M0', 'F_Master', '1', '1', 'PowerSwitch', 'v 3.3.0.0']) + >>> modules.append(['S1', 'F_Satellit', '1', '1', 'Power Switch 8-Port', 'v 4.0.0.5']) + >>> modules.append(['TH1', 'SEN-1', '1', '1', 'TH Sensor', 'v 7.10.0.0']) + >>> string_table = [[['v 3.1.2.2']], modules] + >>> pp(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']]] + >>> pp(parse_inv_espm(string_table)) + {'devices': [{'id': 'M0', + 'name': 'F_Master', + 'type': 'PowerSwitch', + 'version': 'v 3.3.0.0', + 'status_columns': {'activated': 'True', 'detected': 'True'}}, + {'id': 'S1', + 'name': 'F_Satellit', + 'type': 'Power Switch 8-Port', + 'version': 'v 4.0.0.5', + 'status_columns': {'activated': 'True', 'detected': 'True'}}, + {'id': 'TH1', + 'name': 'SEN-1', + 'type': 'TH Sensor', + 'version': 'v 7.10.0.0', + 'status_columns': {'activated': 'True', 'detected': 'True'}}], + 'version': 'v 3.1.2.2'} + """ version, devices = string_table section = { diff --git a/gui/views/inv_epsm.py b/gui/views/inv_epsm.py new file mode 100644 index 0000000000000000000000000000000000000000..8a7bc4abcdd2e52598646c165d40840239f013bd --- /dev/null +++ b/gui/views/inv_epsm.py @@ -0,0 +1,34 @@ +#!/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 view for Noel epower switch +# +# 2023-04-22: moved to ~/local/lib/check_mk/gui/plugins/views +# + +from cmk.gui.plugins.views.utils import ( + inventory_displayhints, +) +from cmk.gui.i18n import _ +from cmk.gui.plugins.views.inventory import declare_invtable_view + +inventory_displayhints.update({ + '.hardware.devices:': {'title': _('Devices'), + 'keyorder': ['id', 'name', 'type', 'version', 'detected', 'activated', ], + 'view': 'invdevices_of_host', + }, + '.hardware.devices:*.id': {'title': _('ID'), }, + '.hardware.devices:*.name': {'title': _('Name')}, + '.hardware.devices:*.type': {'title': _('Type'), }, + '.hardware.devices:*.version': {'title': _('Version')}, + '.hardware.devices:*.detected': {'title': _('Detected'), }, + '.hardware.devices:*.activated': {'title': _('Activated'), }, +}) + +declare_invtable_view('invdevices', '.hardware.devices:', _('Devices'), _('Devices')) diff --git a/inv_epsm.mkp b/inv_epsm.mkp index c2b348ebeb990ca2c4bc44e346c5934953bc581b..1a4e4fd32c6cf71a6a46f3c6aeeafead3013a8d6 100644 Binary files a/inv_epsm.mkp and b/inv_epsm.mkp differ diff --git a/packages/inv_epsm b/packages/inv_epsm index 17d37806cfab8f1e5f40af8e482c76a831bd9e3e..409cafeb8e8d655cc1315e7a46e8cf715b042586 100644 --- a/packages/inv_epsm +++ b/packages/inv_epsm @@ -1,12 +1,10 @@ {'author': 'Th.L. (thl-cmk[at]outlook[dot]com)', 'description': 'Inventory Neols ePowerSwitch \n', 'download_url': 'https://thl-cmk.hopto.org', - 'files': {'agent_based': ['inv_epsm.py'], - 'web': ['plugins/views/inv_epsm.py']}, + 'files': {'agent_based': ['inv_epsm.py'], 'gui': ['views/inv_epsm.py']}, 'name': 'inv_epsm', - 'num_files': 2, 'title': 'Neol ePowerswitch inventory', - 'version': '20211127.v.0.0.1', - 'version.min_required': '2.0.0', - 'version.packaged': '2021.09.20', + 'version': '0.0.2-20230422', + 'version.min_required': '2.1.0b1', + 'version.packaged': '2.1.0p21', 'version.usable_until': None} \ No newline at end of file