From be53bf90cf8899b2eea1561e1b0ab2f83d380ce5 Mon Sep 17 00:00:00 2001
From: thl-cmk <thl-cmk@outlook.com>
Date: Sat, 31 Jul 2021 14:38:31 +0000
Subject: [PATCH] Delete cisco_flash

---
 checks/cisco_flash | 232 ---------------------------------------------
 1 file changed, 232 deletions(-)
 delete mode 100644 checks/cisco_flash

diff --git a/checks/cisco_flash b/checks/cisco_flash
deleted file mode 100644
index bb54cc1..0000000
--- a/checks/cisco_flash
+++ /dev/null
@@ -1,232 +0,0 @@
-#!/usr/bin/python
-# -*- encoding: utf-8; py-indent-offset: 4 -*-
-#
-# Cisco flash
-#
-# Author: Th.L.
-# Date  : 2019-10-28
-#
-# Monitor status of Cisco flash file systems
-#
-# snmpwalk sample
-#
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.2.1.1 = INTEGER: 1
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.2.2.1 = INTEGER: 1
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.3.1.1 = INTEGER: 1
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.3.2.1 = INTEGER: 1
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.1.1 = Gauge32: 2908606464
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.4.2.1 = Gauge32: 4294967295
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.1.1 = Gauge32: 1756741632
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.5.2.1 = Gauge32: 4294967295
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.6.1.1 = Gauge32: 624
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.6.2.1 = Gauge32: 0
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.7.1.1 = INTEGER: 3
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.7.2.1 = INTEGER: 3
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.8.1.1 = INTEGER: 3
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.8.2.1 = INTEGER: 3
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.9.1.1 = INTEGER: 3
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.9.2.1 = INTEGER: 3
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.1.1 = STRING: "bootflash"
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.2.1 = STRING: "usb0"
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.11.1.1 = INTEGER: 2
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.11.2.1 = INTEGER: 2
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.12.1.1 = INTEGER: 63
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.12.2.1 = INTEGER: 63
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.1.1 = Counter64: 2908606464
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.13.2.1 = Counter64: 16424566784
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.1.1 = Counter64: 1756741632
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.14.2.1 = Counter64: 16424558592
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.15.1.1 = INTEGER: 10
-# .1.3.6.1.4.1.9.9.10.1.1.4.1.1.15.2.1 = INTEGER: 10
-#
-# sample info
-#
-# [
-#  [u'1.1', u'2908606464', u'1758527488', u'446', u'3', u'bootflash', u'2', u'2908606464', u'1758527488', u'10'],
-#  [u'2.1', u'4294967295', u'4294967295', u'0', u'3', u'usb0', u'2', u'16423845888', u'7506280448', u'10']
-# ]
-#
-#
-
-factory_settings['cisco_flash_defaults'] = {
-    'warn_level_percent': 85,
-    'crit_level_percent': 90,
-}
-
-###########################################################################
-#
-#  DATA Parser function
-#
-###########################################################################
-
-
-def parse_cisco_flash(info):
-    def PartNeedErasure(mode):
-        modes = {
-            1: True,
-            2: False,
-        }
-        if mode.isdigit():
-            mode = modes.get(int(mode), mode)
-        return mode
-
-    partitions = []
-
-    for cflPartition in info:
-        cflpartOID_END, cflpartSize, cflpartFreeSpace, cflpartFileCount, cflpartName, cflpartNeedErasure, \
-        cflpartSizeExtended, cflpartFreeSpaceExtended, cflpartLowSpaceNotifThreshold = cflPartition
-
-        cflDevIndex, cflPartIndex = cflpartOID_END.split('.')
-
-        if cflpartFreeSpace.isdigit():
-            cflpartFreeSpace = int(cflpartFreeSpace)
-        else:
-            cflpartFreeSpace = 0
-
-        if cflpartFreeSpaceExtended.isdigit():
-            cflpartFreeSpaceExtended = int(cflpartFreeSpaceExtended)
-        else:
-            cflpartFreeSpaceExtended = 0
-
-        if cflpartSize.isdigit():
-            cflpartSize = int(cflpartSize)
-        else:
-            cflpartSize = 0
-
-        if cflpartSizeExtended.isdigit():
-            cflpartSizeExtended = int(cflpartSizeExtended)
-        else:
-            cflpartSizeExtended = 0
-
-        if cflpartLowSpaceNotifThreshold.isdigit():
-            cflpartLowSpaceNotifThreshold = int(cflpartLowSpaceNotifThreshold)
-        else:
-            cflpartLowSpaceNotifThreshold = 0
-
-        if cflpartFileCount.isdigit():
-            cflpartFileCount = int(cflpartFileCount)
-        else:
-            cflpartFileCount = 0
-
-        freespace = max(cflpartFreeSpace, cflpartFreeSpaceExtended)
-        size = max(cflpartSize, cflpartSizeExtended)
-        #size = size / 1024 / 1024
-        #freespace = freespace / 1024 /1024
-
-        partitions.append({
-            'index': cflPartIndex,
-            'flashindex': cflDevIndex,
-            'size': size,
-            'freespace': freespace,
-            'usedspace': size - freespace,
-            'filecount': cflpartFileCount,
-            'name': cflpartName,
-            'neederasure': PartNeedErasure(cflpartNeedErasure),
-            'lowspacenotifythreshold': cflpartLowSpaceNotifThreshold,
-        })
-    return partitions
-
-###########################################################################
-#
-#  INVENTORY function
-#
-###########################################################################
-
-
-def inventory_cisco_flash(parsed):
-    if parsed:
-        for cflPartition in parsed:
-            yield '%s' % (cflPartition.get('name')), {}
-
-###########################################################################
-#
-#  CHECK function
-#
-###########################################################################
-
-
-def check_cisco_flash(item, params, parsed):
-
-    if parsed:
-        for cflPartition in parsed:
-
-            if cflPartition.get('name') == item:
-                state = 0
-                perfdata = []
-                infotext = ''
-                longoutput = ''
-
-                size = cflPartition.get('size')
-                usedspace = cflPartition.get('usedspace')
-                freespace = cflPartition.get('freespace')
-
-                size = size / 1024 / 1024
-                usedspace = usedspace / 1024 /1024
-                freespace = freespace / 1024 / 1024
-
-                filecount = cflPartition.get('filecount')
-                lowspacenotifythreshold = cflPartition.get('lowspacenotifythreshold')
-                size = max(size, 1)  # for size = 0 --> div/0
-                percentused = 100 * usedspace / size
-
-                crit_level_percent =  params.get('crit_level_percent', 90)
-                warn_level_percent =  params.get('warn_level_percent', 85)
-
-                if percentused >= crit_level_percent:
-                    yield 2, 'Low space, more then %s%% used' % crit_level_percent
-                elif percentused > warn_level_percent:
-                    yield 1, 'Low space, more then %s%% used' % warn_level_percent
-
-                if cflPartition.get('neederasure'):
-                    yield 1, 'Partition needs erasure'
-
-                spacewarn = size - ((size / 100) * lowspacenotifythreshold)
-
-                # 'unit', <value>, <warn-at>, <crit-at>, <min value>, <max value>
-                perfdata.append(('partusedspace', usedspace, spacewarn, size - 10, 0, size))
-                perfdata.append(('partfilecount', filecount))
-
-                longoutput += '\nDevice index: %s' % cflPartition.get('flashindex')
-                longoutput += '\nPartition index: %s' % cflPartition.get('index')
-                longoutput += '\nPartition need erasure: %s' % cflPartition.get('neederasure')
-                longoutput += '\nPartition low space notify threshold: %s' % lowspacenotifythreshold
-
-                infotext += '%s%% used (%s of %s MB), %s MB free, File count: %s' % (percentused, usedspace, size, freespace, filecount)
-
-                yield 0, infotext + longoutput, perfdata
-
-###########################################################################
-#
-#  CHECK info
-#
-###########################################################################
-
-
-check_info['cisco_flash'] = {
-    'check_function'          : check_cisco_flash,
-    'inventory_function'      : inventory_cisco_flash,
-    'service_description'     : 'Cisco flash partition %s',
-    'has_perfdata'            : True,
-    'group'                   : 'cisco_flash',
-    'default_levels_variable' : 'cisco_flash_defaults',
-    'parse_function'          : parse_cisco_flash,
-    'snmp_scan_function'      : lambda oid: oid('.1.3.6.1.2.1.1.1.0').lower().find('cisco') != -1 and
-                                           oid('.1.3.6.1.4.1.9.9.10.1.1.4.1.1.10.*'),  # CISCO-FLASH-MIB::ciscoFlashDevicesSupported
-    'snmp_info'               :  ('.1.3.6.1.4.1.9.9.10.1.1.4.1.1', [
-                                  OID_END,  # <deviceindex.partitionindex>
-                                  '4',   # ciscoFlashPartitionSize
-                                  '5',   # ciscoFlashPartitionFreeSpace
-                                  '6',   # ciscoFlashPartitionFileCount
-                                  '10',  # ciscoFlashPartitionName
-                                  '11',  # ciscoFlashPartitionNeedErasure
-                                  '13',  # ciscoFlashPartitionSizeExtended
-                                  '14',  # ciscoFlashPartitionFreeSpaceExtended
-                                  '15',  # ciscoFlashPartitionLowSpaceNotifThreshold
-                                # '2',  # ciscoFlashPartitionStartChip
-                                # '3',  # ciscoFlashPartitionEndChip
-                                # '7',  # ciscoFlashPartitionChecksumAlgorithm
-                                # '8',  # ciscoFlashPartitionStatus
-                                # '9',  # ciscoFlashPartitionUpgradeMethod
-                                # '12',  # ciscoFlashPartitionFileNameLength
-                            ])
-}
-- 
GitLab