diff --git a/cisco_flash-0.3.0-20230607.mkp b/cisco_flash-0.3.0-20230607.mkp new file mode 100644 index 0000000000000000000000000000000000000000..d842984de3d12e8f7651a36e5955affd846147c2 Binary files /dev/null and b/cisco_flash-0.3.0-20230607.mkp differ diff --git a/cisco_flash.mkp b/cisco_flash.mkp index c58ccffc851df84dee657aa49cac59cfe71066bb..d842984de3d12e8f7651a36e5955affd846147c2 100644 Binary files a/cisco_flash.mkp and b/cisco_flash.mkp differ diff --git a/gui/metrics/cisco_flash.py b/gui/metrics/cisco_flash.py new file mode 100644 index 0000000000000000000000000000000000000000..d56c94d5f0739b5b1a874ba94b345a638592fa35 --- /dev/null +++ b/gui/metrics/cisco_flash.py @@ -0,0 +1,86 @@ +#!/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 : 2019-10-28 +# +# Cisco flash metrics plugin +# +# change log +# 2019-10-28: initial release +# 2021-07-31: rewritten for CMK 2.0 +# + +from cmk.gui.i18n import _ + +from cmk.gui.plugins.metrics.utils import ( + metric_info, + graph_info, + perfometer_info + +) + +metric_info['cisco_flash_partusedspace'] = { + 'title': _('Sapce used'), + 'unit': 'bytes', + 'color': '36/a', +} + +metric_info['cisco_flash_percent_used'] = { + 'title': _('Percent used'), + 'unit': '%', + 'color': '26/a', +} + +metric_info['cisco_flash_partfilecount'] = { + 'title': _('# of files'), + 'unit': 'count', + 'color': '21/a', +} + +graph_info['cisco_flash_space_used'] = { + 'title': _('Space used'), + 'metrics': [ + ('cisco_flash_partusedspace', 'area'), + ], + 'scalars': [ + ('cisco_flash_partusedspace:crit', _('crit')), + ('cisco_flash_partusedspace:warn', _('warn')), + ], + "range": (0, "cisco_flash_partusedspace:max"), +} + +graph_info['cisco_flash_percent_used'] = { + 'title': _('Percent used'), + 'metrics': [ + ('cisco_flash_percent_used', 'area'), + ], + 'scalars': [ + ('cisco_flash_percent_used:crit', _('crit')), + ('cisco_flash_percent_used:warn', _('warn')), + ], + "range": (0, 100), +} + +graph_info['cisco_flash_files_on_partition'] = { + 'title': _('# of files on partition'), + 'metrics': [ + ('cisco_flash_partfilecount', 'area'), + ], +} + +perfometer_info.append(('stacked', [ + { + 'type': 'linear', + 'segments': ['cisco_flash_percent_used'], + 'total': 100, + }, + { + 'type': 'linear', + 'segments': ['cisco_flash_partfilecount'], + 'total': 100000, + } +])) diff --git a/gui/views/inv_cisco_flash.py b/gui/views/inv_cisco_flash.py new file mode 100644 index 0000000000000000000000000000000000000000..fad000b22a949fc3fb20fa2e037ce0ae14824740 --- /dev/null +++ b/gui/views/inv_cisco_flash.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +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.components.flash.devices:': { + 'title': _('Flash devices'), + 'keyorder': ['index', 'name', 'description', 'size', ], + 'view': 'invflashdevices_of_host', + }, + + '.hardware.components.flash.devices:*.index': {'title': _('Index'), }, + '.hardware.components.flash.devices:*.size': {'title': _('Size (MB)'), }, + '.hardware.components.flash.devices:*.minpartitionsize': {'title': _('min. partition size (MB)'), }, + '.hardware.components.flash.devices:*.maxprtitions': {'title': _('max. partitions'), }, + '.hardware.components.flash.devices:*.chipcount': {'title': _('Chip count'), }, + '.hardware.components.flash.devices:*.name': {'title': _('Name'), }, + '.hardware.components.flash.devices:*.description': {'title': _('Description'), }, + '.hardware.components.flash.devices:*.controller': {'title': _('Controller'), }, + '.hardware.components.flash.devices:*.programmingjumper': {'title': _('Programming jumper'), }, + '.hardware.components.flash.devices:*.inittime': {'title': _('Init time'), }, + '.hardware.components.flash.devices:*.removable': {'title': _('Removable'), }, + '.hardware.components.flash.devices:*.physentindex': {'title': _('Phys entity index'), }, + '.hardware.components.flash.devices:*.nameextended': {'title': _('Name extended'), }, + + '.hardware.components.flash.chips:': { + 'title': _('Flash chips'), + 'keyorder': ['flashindex', 'index', 'description', ], + 'view': 'invflashchips_of_host', + }, + + '.hardware.components.flash.chips:*.index': {'title': _('Chip index'), }, + '.hardware.components.flash.chips:*.flashindex': {'title': _('Device index'), }, + '.hardware.components.flash.chips:*.code': {'title': _('Code'), }, + '.hardware.components.flash.chips:*.description': {'title': _('Description'), }, + '.hardware.components.flash.chips:*.writeretries': {'title': _('Write retries'), }, + '.hardware.components.flash.chips:*.eraseretries': {'title': _('Erase retries'), }, + '.hardware.components.flash.chips:*.maxwriteretries': {'title': _('max. write retries'), }, + '.hardware.components.flash.chips:*.maxeraseretries': {'title': _('max. erasure retries'), }, + + '.hardware.components.flash.partitions:': { + 'title': _('Flash partitions'), + 'keyorder': ['flashindex', 'index', 'name', 'size', 'freespace', 'filecount', ], + 'view': 'invflashpartitions_of_host', + }, + + '.hardware.components.flash.partitions:*.index': {'title': _('Partition index'), }, + '.hardware.components.flash.partitions:*.flashindex': {'title': _('Device index'), }, + '.hardware.components.flash.partitions:*.startchip': {'title': _('Start chip'), }, + '.hardware.components.flash.partitions:*.endchip': {'title': _('End chip'), }, + '.hardware.components.flash.partitions:*.size': {'title': _('Size (MB)'), }, + '.hardware.components.flash.partitions:*.freespace': {'title': _('Free space (MB)'), }, + '.hardware.components.flash.partitions:*.filecount': {'title': _('File count'), }, + '.hardware.components.flash.partitions:*.crcsumalgo': {'title': _('Checksumm algorithm'), }, + '.hardware.components.flash.partitions:*.status': {'title': _('Status'), }, + '.hardware.components.flash.partitions:*.upgrademethod': {'title': _('Upgrade method'), }, + '.hardware.components.flash.partitions:*.name': {'title': _('Name'), }, + '.hardware.components.flash.partitions:*.neederasure': {'title': _('Need erasure'), }, + '.hardware.components.flash.partitions:*.filenamelength': {'title': _('File name length'), }, + '.hardware.components.flash.partitions:*.lowspacenotifythreshold': {'title': _('Low space notify threshold (%)'), }, +}) + +declare_invtable_view('invflashdevices', '.hardware.components.flash.devices:', _('Flash devices'), _('Flash devices')) +declare_invtable_view('invflashchips', '.hardware.components.flash.chips:', _('Flash chips'), _('Flash chips')) +declare_invtable_view('invflashpartitions', '.hardware.components.flash.partitions:', _('Flash partitions'), + _('Flash partitions')) diff --git a/gui/wato/cisco_flash.py b/gui/wato/cisco_flash.py new file mode 100644 index 0000000000000000000000000000000000000000..d34daffd5465e537ed1dca14f6bb3d8c06975764 --- /dev/null +++ b/gui/wato/cisco_flash.py @@ -0,0 +1,56 @@ +#!/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 : 2019-11-04 +# +# +# Check_MK cisco_flash WATO plugin +# +# 2019-11-04: initial release +# 2021-07-31: rewritten for CMK 2.0 +# +# +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Integer, + TextAscii, + Tuple, +) + +from cmk.gui.plugins.wato.utils import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersNetworking, +) + + +def _parameter_valuespec_cisco_flash(): + return Dictionary( + elements=[ + ('levels_upper_percent', + Tuple( + title=_('Levels for usage in %'), + elements=[ + Integer(title=_('Warning at'), unit='%', default_value=85, minvalue=0, maxvalue=100), + Integer(title=_('Critical at'), unit='%', default_value=90, minvalue=0, maxvalue=100) + ], + + )), + ], + ) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name='cisco_flash', + group=RulespecGroupCheckParametersNetworking, + item_spec=lambda: TextAscii(title=_('Partition specific configuration'), ), + match_type='dict', + parameter_valuespec=_parameter_valuespec_cisco_flash, + title=lambda: _('Cisco flash'), + )) diff --git a/gui/wato/inv_cisco_flash.py b/gui/wato/inv_cisco_flash.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf40a5284baae72dfbfc73db030ddbebff25fee --- /dev/null +++ b/gui/wato/inv_cisco_flash.py @@ -0,0 +1,130 @@ +#!/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 : 2019-10-28 +# +# Cisco flash metrics plugin +# +# change log +# 2019-10-28: initial release +# 2021-07-31: rewritten for CMK 2.0 + + +from cmk.gui.i18n import _ +from cmk.gui.plugins.wato.utils import ( + HostRulespec, + rulespec_registry, +) +from cmk.gui.valuespec import ( + Dictionary, + FixedValue, + ListChoice, +) + +from cmk.gui.plugins.wato.inventory import ( + RulespecGroupInventory, +) + +_inv_cisco_flash_cflDeviceRemovecolumns = [ + ('minpartitionsize', 'min. partition size (MB)'), + ('maxprtitions', 'max. partitions'), + ('chipcount', 'Chip count'), + ('controller', 'Controller'), + ('programmingjumper', 'Programming jumper'), + ('inittime', 'Init time'), + ('removable', 'Removable'), + ('physentindex', 'Phys entity index'), + ('nameextended', 'Name extended'), +] + +_inv_cisco_flash_cflPartitionRemovecolumns = [ + ('startchip', 'Start chip'), + ('endchip', 'End chip'), + ('crcsumalgo', 'Checksumm algorithm'), + ('status', 'Status'), + ('upgrademethod', 'Upgrade method'), + ('neederasure', 'Need erasure'), + ('filenamelength', 'File name length'), + ('lowspacenotifythreshold', 'Low space notify threshold (%)'), +] + +_inv_cisco_flash_cflChipRemovecolumns = [ + ('code', 'Code'), + ('writeretries', 'Write retries'), + ('eraseretries', 'Erase retries'), + ('maxwriteretries', 'max. write retries'), + ('maxeraseretries', 'max. erasure retries'), +] + + +def _valuespec_inv_cisco_flash(): + return Dictionary( + title=_('Cisco flash inventory'), + elements=[ + ('cflDeviceDisable', + FixedValue( + True, + title=_('disable Flash device inventory'), + )), + ('cflPartitionDisable', + FixedValue( + True, + title=_('disable Flash partition inventory'), + )), + ('cflChipDisable', + FixedValue( + True, + title=_('disable Flash chips inventory'), + )), + ('cflDeviceRemovecolumns', + ListChoice( + title=_('list of columns to remove from flash devices'), + help=_('information to remove from inventory'), + choices=_inv_cisco_flash_cflDeviceRemovecolumns, + default_value=[ + 'chipcount', + 'controller', + 'programmingjumper', + 'inittime', + 'physentindex', + 'nameextended', + ], + )), + ('cflPartitionRemovecolumns', + ListChoice( + title=_('list of columns to remove from flash partitions'), + help=_('information to remove from inventory'), + choices=_inv_cisco_flash_cflPartitionRemovecolumns, + default_value=[ + 'startchip', + 'endchip', + ], + )), + ('cflChipRemovecolumns', + ListChoice( + title=_('list of columns to remove from flash chips'), + help=_('information to remove from inventory'), + choices=_inv_cisco_flash_cflChipRemovecolumns, + default_value=[ + 'code', + 'writeretries', + 'eraseretries', + 'maxwriteretries', + 'maxeraseretries' + ], + )), + ], + ) + + +rulespec_registry.register( + HostRulespec( + group=RulespecGroupInventory, + match_type='dict', + name='inv_parameters:inv_cisco_flash', + valuespec=_valuespec_inv_cisco_flash, + )) diff --git a/packages/cisco_flash b/packages/cisco_flash index c84022bac00428de1f0d36e7fff1c4fba54e7f21..111fccd96487d78b1a6b8b9dd46cf2e14e86728d 100644 --- a/packages/cisco_flash +++ b/packages/cisco_flash @@ -7,15 +7,13 @@ '- 2021-07-31: rewritten for CMK 2.0\n', 'download_url': 'https://thl-cmk.hopto.org', 'files': {'agent_based': ['cisco_flash.py', 'inv_cisco_flash.py'], - 'checkman': ['cisco_flash'], - 'web': ['plugins/metrics/cisco_flash.py', - 'plugins/views/inv_cisco_flash.py', - 'plugins/wato/cisco_flash.py', - 'plugins/wato/inv_cisco_flash.py']}, + 'gui': ['metrics/cisco_flash.py', + 'views/inv_cisco_flash.py', + 'wato/cisco_flash.py', + 'wato/inv_cisco_flash.py']}, 'name': 'cisco_flash', - 'num_files': 7, 'title': 'Cisco flash plugins', - 'version': '20210731.v.0.3', - 'version.min_required': '2.0.0', - 'version.packaged': '2021.09.20', + 'version': '0.3.0-20230607', + 'version.min_required': '2.1.0b1', + 'version.packaged': '2.1.0p21', 'version.usable_until': None} \ No newline at end of file