From 37f5b6f93dca4292ee67965bc0e7387027020ef5 Mon Sep 17 00:00:00 2001 From: "th.l" <thl-cmk@outlook.com> Date: Sun, 7 Apr 2024 23:01:31 +0200 Subject: [PATCH] update project --- README.md | 2 +- mkp/cisco_flash-0.4.0-20240407.mkp | Bin 0 -> 7179 bytes source/agent_based/cisco_flash.py | 119 +++++----- source/agent_based/inv_cisco_flash.py | 210 ++++++++++-------- source/gui/views/inv_cisco_flash.py | 72 ------ .../{ => check_parameters}/cisco_flash.py | 2 +- .../{ => check_parameters}/inv_cisco_flash.py | 12 +- source/packages/cisco_flash | 13 +- source/web/plugins/views/inv_cisco_flash.py | 77 +++++++ 9 files changed, 269 insertions(+), 238 deletions(-) create mode 100644 mkp/cisco_flash-0.4.0-20240407.mkp delete mode 100644 source/gui/views/inv_cisco_flash.py rename source/gui/wato/{ => check_parameters}/cisco_flash.py (100%) rename source/gui/wato/{ => check_parameters}/inv_cisco_flash.py (91%) create mode 100644 source/web/plugins/views/inv_cisco_flash.py diff --git a/README.md b/README.md index c817dd2..8222bf2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/cisco_flash-0.3.0-20230607.mkp "cisco_flash-0.3.0-20230607.mkp" +[PACKAGE]: ../../raw/master/mkp/cisco_flash-0.4.0-20240407.mkp "cisco_flash-0.4.0-20240407.mkp" # Cisco flash Collection of plugins for Cisco flash diff --git a/mkp/cisco_flash-0.4.0-20240407.mkp b/mkp/cisco_flash-0.4.0-20240407.mkp new file mode 100644 index 0000000000000000000000000000000000000000..f67933f2a2022ba07f868a584b683daf3cbd1eb5 GIT binary patch literal 7179 zcmai&Ra6v!!i4FiyFt1|q?d*Tq*FSTPU()NLAs^8q@<fA1q4>QyFt2}-Fwgf{-66c z=gd5RXJ%+)(Gh-P5LqL^&%_<vSLIS*&@Vi!dYG1K#ZQFnO)*9%f4p|$YuhcY-1Q7e zuo&bS7MS`_rIZZ|U@xAN*xc$#bRXE4O;o6J$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wk_k5X?rIQ!(K8g)()a`upFA`g)uKVHP!|mnI zhH}%|a^ReKt>xpgktdawtd+siatrfGWzu5n$Ke;1i((%o3)1d%QRq;f>TrD0GLF1G z6WKjsWCW<%z(iJOczWIk?F8pz-Q#n1&?Z!^9$vNZlIODE?D+JcstZJZOKm*U3=MBd zHcxs9&f#!d^*1^`j*L~L2ppi*>6OO_onf}pu*l&bF;6W=p%+|1!&w8cN7YUcg#B^Y z*XdwUq|IJt@ieMLVP2iL#@B8ufTetsOsC8BKd7msEZyT|TXk^58ZRtyvPrkAI0o?N zd|x$ner#PN%`NrCc{dx{oxEx>l>7H0X_+oLLDf5jE3rBDrPO1lY(~WHH;1M!=@liJ z0>iKtl_(Em(fX)aJ<94en`*RhHK%Fj3~&49L>2|}-(;(#ofo@`C%FYV^X#^9x?%72 zRyu3HW#drK6UuBZVKPnEqgK#@s$R#L6|zi#$8(Re>!<RjCVYguG0+*!m?t))gW(T{ zv{sV(gt<&A8;IQLYL)^c>$|J+^ggeH#HRy)VZ*HPja<mKhp31s)dxTMea3G|1IUXQ z@K9^f&?iS8j2$ny+_-c}SvZeALwXc{lAe;R%)f@;+yH+%-%A-`20zDe(EHfb$D|>} zw33ck_A(-k9c~p7^3*Gq#8EcMG^Ib04q{nqK?M=cX^ck1>t<6U3V0H5HJ{RvEP{U_ bW$Sui*#GPz|9_y@=s9SEs;>y)5&_{q2o@<| literal 0 HcmV?d00001 diff --git a/source/agent_based/cisco_flash.py b/source/agent_based/cisco_flash.py index 9f6e0eb..3b5d1cb 100644 --- a/source/agent_based/cisco_flash.py +++ b/source/agent_based/cisco_flash.py @@ -12,7 +12,9 @@ # 2019-10-28: initial release # 2019-11-04: added wato for cisco_flash # 2021-07-31: rewritten for CMK 2.0 +# 2024-04-07: some code cleanup # + # snmpwalk sample # # .1.3.6.1.4.1.9.9.10.1.1.4.1.1.2.1.1 = INTEGER: 1 @@ -54,42 +56,42 @@ # from dataclasses import dataclass -from typing import Optional, Dict +from typing import Dict from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( - DiscoveryResult, CheckResult, + DiscoveryResult, StringTable, ) from cmk.base.plugins.agent_based.agent_based_api.v1 import ( - register, - Service, - SNMPTree, - contains, - check_levels, + Metric, OIDEnd, Result, - render, + SNMPTree, + Service, State, - Metric, all_of, + check_levels, + contains, exists, + register, + render, ) -@dataclass +@dataclass(frozen=True) class Partition: - size: Optional[int] = None - freespace: Optional[int] = None - usedspace: Optional[int] = None - index: Optional[int] = None - flashindex: Optional[int] = None - neederasure: Optional[bool] = None - lowspacenotifythreshold: Optional[int] = None - filecount: Optional[int] = None + size: int | None + free_space: int | None + used_space: int | None + index: int | None + flash_index: int | None + need_erasure: bool | None + low_space_notify_threshold: int | None + file_count: int | None -_partneederasure = { +_part_need_erasure = { '1': True, '2': False, } @@ -105,32 +107,39 @@ _partneederasure = { def parse_cisco_flash(string_table: StringTable) -> Dict[str, Partition]: partitions: Dict[str, Partition] = {} - for cflPartition in string_table: - cflpartOID_END, cflpartSize, cflpartFreeSpace, cflpartFileCount, cflpartName, cflpartNeedErasure, \ - cflpartSizeExtended, cflpartFreeSpaceExtended, cflpartLowSpaceNotifThreshold = cflPartition + for partition in string_table: + try: + part_oid_end, part_size, part_free_pace, part_file_count, part_name, part_need_erasure, \ + part_size_extended, part_free_space_extended, part_low_space_notif_threshold = partition + except ValueError: + continue - cflDevIndex, cflPartIndex = cflpartOID_END.split('.') + try: + dev_index, part_index = part_oid_end.split('.') + except ValueError: + continue - cflpartFreeSpace = int(cflpartFreeSpace) if cflpartFreeSpace.isdigit() else None - cflpartFreeSpaceExtended = int(cflpartFreeSpaceExtended) if cflpartFreeSpaceExtended.isdigit() else None - cflpartSize = int(cflpartSize) if cflpartSize.isdigit() else None - cflpartSizeExtended = int(cflpartSizeExtended) if cflpartSizeExtended.isdigit() else None + part_free_pace = int(part_free_pace) if part_free_pace.isdigit() else None + part_free_space_extended = int(part_free_space_extended) if part_free_space_extended.isdigit() else None + part_size = int(part_size) if part_size.isdigit() else None + part_size_extended = int(part_size_extended) if part_size_extended.isdigit() else None - freespace = cflpartFreeSpaceExtended if cflpartFreeSpaceExtended else cflpartFreeSpace - size = cflpartSizeExtended if cflpartSizeExtended else cflpartSize + free_space = part_free_space_extended if part_free_space_extended else part_free_pace + size = part_size_extended if part_size_extended else part_size if size > 0: partitions.update({ - cflpartName: Partition( - index=int(cflPartIndex) if cflPartIndex.isdigit() else None, - flashindex=int(cflDevIndex) if cflDevIndex.isdigit() else None, + part_name: Partition( + index=int(part_index) if part_index.isdigit() else None, + flash_index=int(dev_index) if dev_index.isdigit() else None, size=size, - freespace=freespace, - usedspace=size - freespace, - filecount=int(cflpartFileCount) if cflpartFileCount.isdigit() else None, - neederasure=_partneederasure.get(cflpartNeedErasure, None), - lowspacenotifythreshold=int( - cflpartLowSpaceNotifThreshold) if cflpartLowSpaceNotifThreshold.isdigit() else None + free_space=free_space, + used_space=size - free_space, + file_count=int(part_file_count) if part_file_count.isdigit() else None, + need_erasure=_part_need_erasure.get(part_need_erasure, None), + low_space_notify_threshold=int( + part_low_space_notif_threshold + ) if part_low_space_notif_threshold.isdigit() else None )}) return partitions @@ -161,24 +170,24 @@ def check_cisco_flash(item, params, section: Dict[str, Partition]) -> CheckResul except KeyError: return - if partition.lowspacenotifythreshold: - spacewarn = partition.size - ((partition.size / 100) * partition.lowspacenotifythreshold) + if partition.low_space_notify_threshold: + space_warn = partition.size - ((partition.size / 100) * partition.low_space_notify_threshold) else: - spacewarn = partition.size + space_warn = partition.size yield from check_levels( - value=partition.usedspace, + value=partition.used_space, label='Space used', metric_name='cisco_flash_partusedspace', render_func=render.disksize, - levels_upper=(spacewarn, partition.size - 10), + levels_upper=(space_warn, partition.size - 10), boundaries=(0, partition.size), ) - percentused = 100 * partition.usedspace / partition.size + percent_used = 100 * partition.used_space / partition.size yield from check_levels( - value=percentused, + value=percent_used, label='Percent', levels_upper=params['levels_upper_percent'], render_func=render.percent, @@ -186,33 +195,33 @@ def check_cisco_flash(item, params, section: Dict[str, Partition]) -> CheckResul metric_name='cisco_flash_percent_used' ) - if partition.neederasure: + if partition.need_erasure: yield Result(state=State.WARN, notice='Partition needs erasure') yield Metric( - value=partition.filecount, + value=partition.file_count, name='cisco_flash_partfilecount', boundaries=(0, None) ) for key, value in [ - ('Device index', partition.flashindex), + ('Device index', partition.flash_index), ('Partition index', partition.index), - ('Partition need erasure', partition.neederasure), - ('Partition low space notify threshold', partition.lowspacenotifythreshold), + ('Partition need erasure', partition.need_erasure), + ('Partition low space notify threshold', partition.low_space_notify_threshold), ]: if value: yield Result(state=State.OK, notice=f'{key}: {value}') size = max(partition.size, 1) # for size = 0 --> div/0 size = size / 1000 / 1000 - usedspace = partition.usedspace / 1000 / 1000 - freespace = partition.freespace / 1000 / 1000 + used_space = partition.used_space / 1000 / 1000 + free_space = partition.free_space / 1000 / 1000 - yield Result(state=State.OK, notice=f'Used: {usedspace:.2f} of {size:.2f} MB, {freespace:.2f} MB free') + yield Result(state=State.OK, notice=f'Used: {used_space:.2f} of {size:.2f} MB, {free_space:.2f} MB free') - if partition.filecount: - yield Result(state=State.OK, summary=f'File count: {partition.filecount}') + if partition.file_count: + yield Result(state=State.OK, summary=f'File count: {partition.file_count}') ########################################################################### diff --git a/source/agent_based/inv_cisco_flash.py b/source/agent_based/inv_cisco_flash.py index 2a23f76..113f6e7 100644 --- a/source/agent_based/inv_cisco_flash.py +++ b/source/agent_based/inv_cisco_flash.py @@ -9,29 +9,29 @@ # # invetory of cisco flash devices # -# 2019-10-22 : initial release +# 2019-10-22: initial release # 2021-07-31: rewritten for CMK 2.0 -# +# 2023-04-07: some code cleanup +# moved the Flash inventory from 'hardware.components.flash' to 'hardware.flash' # -from typing import List, Dict, Any from dataclasses import dataclass +from typing import List, Dict, Any + from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( - StringTable, InventoryResult, + StringTable, ) - from cmk.base.plugins.agent_based.agent_based_api.v1 import ( OIDEnd, ) - from cmk.base.plugins.agent_based.agent_based_api.v1 import ( - register, SNMPTree, TableRow, - exists, all_of, contains, + exists, + register, ) @@ -42,13 +42,13 @@ class Section: flash_partitions: List[Dict[str, Any]] -_DevProgrammingJumper = { +_dev_programming_jumper = { '1': 'installed', '2': 'not installed', '3': 'unknown', } -_DevRemovable = { +_dev_removable = { '1': True, '2': False, } @@ -59,62 +59,68 @@ _PartStatus = { '3': 'Read Write', } -_PartChecksumAlgorithm = { +_part_checksum_algorithm = { '1': 'simple Checksum', '2': 'undefined', '3': 'simple CRC', } -_PartUpgradeMethod = { - '1': 'unkown', +_part_upgrade_method = { + '1': 'unknown', '2': 'rxboot Flash Load Helper', '3': 'direct', } -_PartNeedErasure = { +_part_need_erasure = { '1': True, '2': False, } -def parse_inv_cisco_flash(string_table: List[StringTable]) -> Section: - cflDevices, cflChips, cflPartitions = string_table +def parse_inv_cisco_flash(string_table: List[StringTable]) -> Section | None: + try: + devices, chips, partitions = string_table + except ValueError: + return flash_devices = [] - for cflDevice in cflDevices: - clfOID_END, cflDevSize, cflDevMinPartitionSize, cflDevMaxPartitions, cflDevPartitions, cflDevChipCount, \ - cflDevName, cflDevDescr, cflDevController, cflDevProgrammingJumper, cflDevInitTime, cflDevRemovable, \ - cflDevPhyEntIndex, cflDevNameExtended, cflDevSizeExtended, cflDevMinPartitionSizeExtended = cflDevice - - cflDevSize = int(cflDevSize) if cflDevSize.isdigit() else None - cflDevSizeExtended = int(cflDevSizeExtended) if cflDevSizeExtended.isdigit() else None - cflDevMinPartitionSize = int(cflDevMinPartitionSize) if cflDevMinPartitionSize.isdigit() else None - cflDevMinPartitionSizeExtended = int( - cflDevMinPartitionSizeExtended) if cflDevMinPartitionSizeExtended.isdigit() else None + for cflDevice in devices: + try: + oid_end, dev_size, dev_min_partition_size, dev_max_partitions, dev_partitions, dev_chip_count, \ + dev_name, dev_descr, dev_controller, dev_programming_jumper, dev_init_time, dev_removable, \ + dev_phy_ent_index, dev_name_extended, dev_size_extended, dev_min_partition_size_extended = cflDevice + except ValueError: + continue + + dev_size = int(dev_size) if dev_size.isdigit() else None + dev_size_extended = int(dev_size_extended) if dev_size_extended.isdigit() else None + dev_min_partition_size = int(dev_min_partition_size) if dev_min_partition_size.isdigit() else None + dev_min_partition_size_extended = int( + dev_min_partition_size_extended) if dev_min_partition_size_extended.isdigit() else None # change sizes to MB - size = cflDevSizeExtended if cflDevSizeExtended else cflDevSize + size = dev_size_extended if dev_size_extended else dev_size size = size / 1024 / 1024 if size else None - minpartitionsize = cflDevMinPartitionSizeExtended if cflDevMinPartitionSizeExtended else cflDevMinPartitionSize - minpartitionsize = minpartitionsize / 1024 / 1024 if minpartitionsize else None + min_partition_size = dev_min_partition_size_extended if dev_min_partition_size_extended else dev_min_partition_size + min_partition_size = min_partition_size / 1024 / 1024 if min_partition_size else None flash_device = {} for key, value in [ - ('index', clfOID_END), - ('name', cflDevName), - ('description', cflDevDescr), - ('controller', cflDevController), - ('programmingjumper', _DevProgrammingJumper.get(cflDevProgrammingJumper)), - ('inittime', cflDevInitTime), - ('removable', _DevRemovable.get(cflDevRemovable)), - ('nameextended', cflDevNameExtended), - ('physentindex', cflDevPhyEntIndex), + ('index', oid_end), + ('name', dev_name), + ('description', dev_descr), + ('controller', dev_controller), + ('programmingjumper', _dev_programming_jumper.get(dev_programming_jumper)), + ('inittime', dev_init_time), + ('removable', _dev_removable.get(dev_removable)), + ('nameextended', dev_name_extended), + ('physentindex', dev_phy_ent_index), ('size', size), - ('minpartitionsize', minpartitionsize), - ('maxprtitions', cflDevMaxPartitions), - ('partitions', cflDevPartitions), - ('chipcount', cflDevChipCount), + ('minpartitionsize', min_partition_size), + ('maxprtitions', dev_max_partitions), + ('partitions', dev_partitions), + ('chipcount', dev_chip_count), ]: if value: flash_device.update({key: value}) @@ -122,22 +128,28 @@ def parse_inv_cisco_flash(string_table: List[StringTable]) -> Section: flash_chips = [] - for cflChip in cflChips: - cflOID_END, cflChipCode, cflChipDescr, cflChipWriteRetries, cflChipEraseRetries, cflChipMaxWriteRetries, \ - cflChipMaxEraseRetries = cflChip + for chip in chips: + try: + oid_end, chip_code, chip_descr, chip_write_retries, chip_erase_retries, chip_max_write_retries, \ + chip_max_erase_retries = chip + except ValueError: + continue - cflDevIndex, cflChipIndex = cflOID_END.split('.') + try: + dev_index, chip_index = oid_end.split('.') + except ValueError: + continue flash_chip = {} for key, value in [ - ('index', cflChipIndex), - ('flashindex', cflDevIndex), - ('code', cflChipCode), - ('description', cflChipDescr), - ('writeretries', cflChipWriteRetries), - ('eraseretries', cflChipEraseRetries), - ('maxwriteretries', cflChipMaxWriteRetries), - ('maxeraseretries', cflChipMaxEraseRetries), + ('index', chip_index), + ('flashindex', dev_index), + ('code', chip_code), + ('description', chip_descr), + ('writeretries', chip_write_retries), + ('eraseretries', chip_erase_retries), + ('maxwriteretries', chip_max_write_retries), + ('maxeraseretries', chip_max_erase_retries), ]: if value: flash_chip.update({key: value}) @@ -145,42 +157,48 @@ def parse_inv_cisco_flash(string_table: List[StringTable]) -> Section: flash_chips.append(flash_chip) flash_partitions = [] - for cflPartition in cflPartitions: - cflpartOID_END, cflpartStartChip, cflpartEndChip, cflpartSize, cflpartFreeSpace, cflpartFileCount, \ - cflpartChecksumAlgorithm, cflpartStatus, cflpartUpgradeMethod, cflpartName, cflpartNeedErasure, \ - cflpartFileNameLength, cflpartSizeExtended, cflpartFreeSpaceExtended, \ - cflpartLowSpaceNotifThreshold = cflPartition - - cflDevIndex, cflPartIndex = cflpartOID_END.split('.') - - cflpartSize = int(cflpartSize) if cflpartSize.isdigit() else None - cflpartFreeSpace = int(cflpartFreeSpace) if cflpartFreeSpace.isdigit() else None - cflpartSizeExtended = int(cflpartSizeExtended) if cflpartSizeExtended.isdigit() else None - cflpartFreeSpaceExtended = int(cflpartFreeSpaceExtended) if cflpartFreeSpaceExtended.isdigit() else None + for partition in partitions: + try: + part_oid_end, part_start_chip, part_end_chip, part_size, part_free_space, part_file_count, \ + part_checksum_algorithm, part_status, part_upgrade_method, part_name, part_need_erasure, \ + part_file_name_length, part_size_extended, part_free_space_extended, \ + part_low_space_notif_threshold = partition + except ValueError: + continue + + try: + dev_index, part_index = part_oid_end.split('.') + except ValueError: + continue + + part_size = int(part_size) if part_size.isdigit() else None + part_free_space = int(part_free_space) if part_free_space.isdigit() else None + part_size_extended = int(part_size_extended) if part_size_extended.isdigit() else None + part_free_space_extended = int(part_free_space_extended) if part_free_space_extended.isdigit() else None # change sizes to MB - size = cflpartSizeExtended if cflpartSizeExtended else cflpartSize + size = part_size_extended if part_size_extended else part_size size = size / 1024 / 1024 if size else None - freespace = cflpartFreeSpaceExtended if cflpartFreeSpaceExtended else cflpartFreeSpace - freespace = freespace / 1024 / 1024 if freespace else None + free_space = part_free_space_extended if part_free_space_extended else part_free_space + free_space = free_space / 1024 / 1024 if free_space else None flash_partition = {} for key, value in [ - ('index', cflPartIndex), - ('flashindex', cflDevIndex), - ('startchip', cflpartStartChip), - ('endchip', cflpartEndChip), - ('filecount', cflpartFileCount), - ('crcsumalgo', _PartChecksumAlgorithm.get(cflpartChecksumAlgorithm)), - ('status', _PartStatus.get(cflpartStatus)), - ('upgrademethod', _PartUpgradeMethod.get(cflpartUpgradeMethod)), - ('name', cflpartName), - ('neederasure', _PartNeedErasure.get(cflpartNeedErasure)), - ('filenamelength', cflpartFileNameLength), - ('lowspacenotifythreshold', cflpartLowSpaceNotifThreshold), + ('index', part_index), + ('flashindex', dev_index), + ('startchip', part_start_chip), + ('endchip', part_end_chip), + ('filecount', part_file_count), + ('crcsumalgo', _part_checksum_algorithm.get(part_checksum_algorithm)), + ('status', _PartStatus.get(part_status)), + ('upgrademethod', _part_upgrade_method.get(part_upgrade_method)), + ('name', part_name), + ('neederasure', _part_need_erasure.get(part_need_erasure)), + ('filenamelength', part_file_name_length), + ('lowspacenotifythreshold', part_low_space_notif_threshold), ('size', size), - ('freespace', freespace), + ('freespace', free_space), ]: if value: flash_partition.update({key: value}) @@ -198,25 +216,24 @@ def inventory_cisco_flash(params, section: Section) -> InventoryResult: flash_devices = section.flash_devices flash_chips = section.flash_chips flash_partitions = section.flash_partitions - + base_path = ['hardware', 'flash'] # inventory of cisco flash devices - removecolumns = [] + remove_columns = [] disabled = False # if params: disabled = params.get('cflDeviceDisable', disabled) # get list of columns to remove from inventory - removecolumns = params.get('cflDeviceRemovecolumns', removecolumns) + remove_columns = params.get('cflDeviceRemovecolumns', remove_columns) if not disabled: - - path = ['hardware', 'components', 'flash', 'devices'] + path = base_path + ['devices'] for flash_device in flash_devices: key_columns = {'index': flash_device['index'], } flash_device.pop('index') for key in flash_device.keys(): - if key in removecolumns: + if key in remove_columns: flash_device.pop(key) yield TableRow( @@ -227,23 +244,23 @@ def inventory_cisco_flash(params, section: Section) -> InventoryResult: # inventory of cisco flash chips - removecolumns = [] + remove_columns = [] disabled = False if params: disabled = params.get('cflChipDisable', disabled) # get list of columns to remove from inventory - removecolumns = params.get('cflChipRemovecolumns', removecolumns) + remove_columns = params.get('cflChipRemovecolumns', remove_columns) if not disabled: - path = ['hardware', 'components', 'flash', 'chips'] + path = base_path + ['chips'] for flash_chip in flash_chips: key_columns = {'index': flash_chip['index'], 'flashindex': flash_chip['flashindex']} flash_chip.pop('index') flash_chip.pop('flashindex') for key in flash_chip.keys(): - if key in removecolumns: + if key in remove_columns: flash_chip.pop(key) yield TableRow( @@ -254,23 +271,22 @@ def inventory_cisco_flash(params, section: Section) -> InventoryResult: # inventory of cisco flash partitions - removecolumns = [] + remove_columns = [] disabled = False if params: disabled = params.get('cflPartitionDisable', disabled) # get list of columns to remove from inventory - removecolumns = params.get('cflPartitionRemovecolumns', removecolumns) + remove_columns = params.get('cflPartitionRemovecolumns', remove_columns) if not disabled: - path = ['hardware', 'components', 'flash', 'partitions'] - + path = base_path + ['partitions'] for flash_partition in flash_partitions: key_columns = {'index': flash_partition['index'], 'flashindex': flash_partition['flashindex']} flash_partition.pop('index') flash_partition.pop('flashindex') for key in flash_partition.keys(): - if key in removecolumns: + if key in remove_columns: flash_partition.pop(key) yield TableRow( diff --git a/source/gui/views/inv_cisco_flash.py b/source/gui/views/inv_cisco_flash.py deleted file mode 100644 index fad000b..0000000 --- a/source/gui/views/inv_cisco_flash.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/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/source/gui/wato/cisco_flash.py b/source/gui/wato/check_parameters/cisco_flash.py similarity index 100% rename from source/gui/wato/cisco_flash.py rename to source/gui/wato/check_parameters/cisco_flash.py index d34daff..8d5eb8d 100644 --- a/source/gui/wato/cisco_flash.py +++ b/source/gui/wato/check_parameters/cisco_flash.py @@ -24,8 +24,8 @@ from cmk.gui.valuespec import ( from cmk.gui.plugins.wato.utils import ( CheckParameterRulespecWithItem, - rulespec_registry, RulespecGroupCheckParametersNetworking, + rulespec_registry, ) diff --git a/source/gui/wato/inv_cisco_flash.py b/source/gui/wato/check_parameters/inv_cisco_flash.py similarity index 91% rename from source/gui/wato/inv_cisco_flash.py rename to source/gui/wato/check_parameters/inv_cisco_flash.py index 7cf40a5..ef44cd0 100644 --- a/source/gui/wato/inv_cisco_flash.py +++ b/source/gui/wato/check_parameters/inv_cisco_flash.py @@ -29,7 +29,7 @@ from cmk.gui.plugins.wato.inventory import ( RulespecGroupInventory, ) -_inv_cisco_flash_cflDeviceRemovecolumns = [ +_inv_cisco_flash_cfl_device_remove_columns = [ ('minpartitionsize', 'min. partition size (MB)'), ('maxprtitions', 'max. partitions'), ('chipcount', 'Chip count'), @@ -41,7 +41,7 @@ _inv_cisco_flash_cflDeviceRemovecolumns = [ ('nameextended', 'Name extended'), ] -_inv_cisco_flash_cflPartitionRemovecolumns = [ +_inv_cisco_flash_cfl_partition_remove_columns = [ ('startchip', 'Start chip'), ('endchip', 'End chip'), ('crcsumalgo', 'Checksumm algorithm'), @@ -52,7 +52,7 @@ _inv_cisco_flash_cflPartitionRemovecolumns = [ ('lowspacenotifythreshold', 'Low space notify threshold (%)'), ] -_inv_cisco_flash_cflChipRemovecolumns = [ +_inv_cisco_flash_cfl_chip_remove_columns = [ ('code', 'Code'), ('writeretries', 'Write retries'), ('eraseretries', 'Erase retries'), @@ -84,7 +84,7 @@ def _valuespec_inv_cisco_flash(): ListChoice( title=_('list of columns to remove from flash devices'), help=_('information to remove from inventory'), - choices=_inv_cisco_flash_cflDeviceRemovecolumns, + choices=_inv_cisco_flash_cfl_device_remove_columns, default_value=[ 'chipcount', 'controller', @@ -98,7 +98,7 @@ def _valuespec_inv_cisco_flash(): ListChoice( title=_('list of columns to remove from flash partitions'), help=_('information to remove from inventory'), - choices=_inv_cisco_flash_cflPartitionRemovecolumns, + choices=_inv_cisco_flash_cfl_partition_remove_columns, default_value=[ 'startchip', 'endchip', @@ -108,7 +108,7 @@ def _valuespec_inv_cisco_flash(): ListChoice( title=_('list of columns to remove from flash chips'), help=_('information to remove from inventory'), - choices=_inv_cisco_flash_cflChipRemovecolumns, + choices=_inv_cisco_flash_cfl_chip_remove_columns, default_value=[ 'code', 'writeretries', diff --git a/source/packages/cisco_flash b/source/packages/cisco_flash index a732186..9576534 100644 --- a/source/packages/cisco_flash +++ b/source/packages/cisco_flash @@ -4,16 +4,17 @@ ' - cisco_flash: check for Cisco partitions\n' '\n' '- 2020-05-13: added support for CMK1.6x\n' - '- 2021-07-31: rewritten for CMK 2.0\n', + '- 2021-07-31: rewritten for CMK 2.0\n' + '- 2024-04-07: refactoring for CMK 2.2\n', 'download_url': 'https://thl-cmk.hopto.org', 'files': {'agent_based': ['cisco_flash.py', 'inv_cisco_flash.py'], 'gui': ['metrics/cisco_flash.py', - 'views/inv_cisco_flash.py', - 'wato/cisco_flash.py', - 'wato/inv_cisco_flash.py']}, + 'wato/check_parameters/cisco_flash.py', + 'wato/check_parameters/inv_cisco_flash.py'], + 'web': ['plugins/views/inv_cisco_flash.py']}, 'name': 'cisco_flash', 'title': 'Cisco flash plugins', - 'version': '0.3.0-20230607', - 'version.min_required': '2.1.0b1', + 'version': '0.4.0-20240407', + 'version.min_required': '2.2.0b1', 'version.packaged': '2.2.0p24', 'version.usable_until': None} diff --git a/source/web/plugins/views/inv_cisco_flash.py b/source/web/plugins/views/inv_cisco_flash.py new file mode 100644 index 0000000..69a1bba --- /dev/null +++ b/source/web/plugins/views/inv_cisco_flash.py @@ -0,0 +1,77 @@ +#!/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 +# + +# 2024-04-07: modified for CMK 2.2.x (ThX bitwiz@forum.checkmk.com) +# fixed some typos (ThX bitwiz@forum.checkmk.com) +# moved the Flash inventory from 'hardware.components.flash' to 'hardware.flash' + +from cmk.gui.i18n import _ +from cmk.gui.views.inventory.registry import inventory_displayhints + +inventory_displayhints.update({ + '.hardware.flash.': { + 'title': _('Flash'), + }, + '.hardware.flash.devices:': { + 'title': _('Flash Devices'), + 'keyorder': ['index', 'name', 'description', 'size', ], + 'view': 'invflashdevices_of_host', + }, + + '.hardware.flash.devices:*.index': {'title': _('Index'), }, + '.hardware.flash.devices:*.size': {'title': _('Size (MB)'), }, + '.hardware.flash.devices:*.minpartitionsize': {'title': _('Min. Partition Size (MB)'), }, + '.hardware.flash.devices:*.maxprtitions': {'title': _('Max. Partitions'), }, + '.hardware.flash.devices:*.chipcount': {'title': _('Chip Count'), }, + '.hardware.flash.devices:*.name': {'title': _('Name'), }, + '.hardware.flash.devices:*.description': {'title': _('Description'), }, + '.hardware.flash.devices:*.controller': {'title': _('Controller'), }, + '.hardware.flash.devices:*.programmingjumper': {'title': _('Programming Jumper'), }, + '.hardware.flash.devices:*.inittime': {'title': _('Init Time'), }, + '.hardware.flash.devices:*.removable': {'title': _('Removable'), }, + '.hardware.flash.devices:*.physentindex': {'title': _('Phys Entity Index'), }, + '.hardware.flash.devices:*.nameextended': {'title': _('Name Extended'), }, + + '.hardware.flash.chips:': { + 'title': _('Flash Chips'), + 'keyorder': ['flashindex', 'index', 'description', ], + 'view': 'invflashchips_of_host', + }, + + '.hardware.flash.chips:*.index': {'title': _('Chip Index'), }, + '.hardware.flash.chips:*.flashindex': {'title': _('Device Index'), }, + '.hardware.flash.chips:*.code': {'title': _('Code'), }, + '.hardware.flash.chips:*.description': {'title': _('Description'), }, + '.hardware.flash.chips:*.writeretries': {'title': _('Write Retries'), }, + '.hardware.flash.chips:*.eraseretries': {'title': _('Erase Retries'), }, + '.hardware.flash.chips:*.maxwriteretries': {'title': _('Max. Write Retries'), }, + '.hardware.flash.chips:*.maxeraseretries': {'title': _('Max. Erasure Retries'), }, + + '.hardware.flash.partitions:': { + 'title': _('Flash Partitions'), + 'keyorder': ['flashindex', 'index', 'name', 'size', 'freespace', 'filecount', ], + 'view': 'invflashpartitions_of_host', + }, + + '.hardware.flash.partitions:*.index': {'title': _('Partition Index'), }, + '.hardware.flash.partitions:*.flashindex': {'title': _('Device Index'), }, + '.hardware.flash.partitions:*.startchip': {'title': _('Start Chip'), }, + '.hardware.flash.partitions:*.endchip': {'title': _('End Chip'), }, + '.hardware.flash.partitions:*.size': {'title': _('Size (MB)'), }, + '.hardware.flash.partitions:*.freespace': {'title': _('Free Space (MB)'), }, + '.hardware.flash.partitions:*.filecount': {'title': _('File Count'), }, + '.hardware.flash.partitions:*.crcsumalgo': {'title': _('Checksum Algorithm'), }, + '.hardware.flash.partitions:*.status': {'title': _('Status'), }, + '.hardware.flash.partitions:*.upgrademethod': {'title': _('Upgrade Method'), }, + '.hardware.flash.partitions:*.name': {'title': _('Name'), }, + '.hardware.flash.partitions:*.neederasure': {'title': _('Need Erasure'), }, + '.hardware.flash.partitions:*.filenamelength': {'title': _('File Name Length'), }, + '.hardware.flash.partitions:*.lowspacenotifythreshold': {'title': _('Low Space Notify Threshold (%)'), }, +}) -- GitLab