diff --git a/checks/cisco_flash b/checks/cisco_flash index 1b22e8c5e043c8f7f0197f184c9bc84112fb17ae..bb54cc1653ef376434ace60deba46e5520eff98e 100644 --- a/checks/cisco_flash +++ b/checks/cisco_flash @@ -49,6 +49,8 @@ # factory_settings['cisco_flash_defaults'] = { + 'warn_level_percent': 85, + 'crit_level_percent': 90, } ########################################################################### @@ -164,13 +166,16 @@ def check_cisco_flash(item, params, parsed): filecount = cflPartition.get('filecount') lowspacenotifythreshold = cflPartition.get('lowspacenotifythreshold') + size = max(size, 1) # for size = 0 --> div/0 percentused = 100 * usedspace / size - spacewarn = (size / 100) * lowspacenotifythreshold - if spacewarn >= freespace: - yield 1, 'Low space' - elif freespace <= 10: # 10 MB - yield 2, 'Low space' + 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' @@ -183,14 +188,10 @@ def check_cisco_flash(item, params, parsed): longoutput += '\nDevice index: %s' % cflPartition.get('flashindex') longoutput += '\nPartition index: %s' % cflPartition.get('index') -# longoutput += '\nPartition size: %s' % size -# longoutput += '\nPartition used space: %s' % usedspace -# longoutput += '\nPartition free space: %s' % freespace -# longoutput += '\nPartition warn space: %s' % spacewarn longoutput += '\nPartition need erasure: %s' % cflPartition.get('neederasure') longoutput += '\nPartition low space notify threshold: %s' % lowspacenotifythreshold - infotext += '%s%% used (%s of %s MB), File count: %s' % (percentused, usedspace, size, filecount) + infotext += '%s%% used (%s of %s MB), %s MB free, File count: %s' % (percentused, usedspace, size, freespace, filecount) yield 0, infotext + longoutput, perfdata diff --git a/cisco_flash.mkp b/cisco_flash.mkp index d5816ecfc4296eafc49a245de96475c3d90298cf..a7b120f0d9ee3a1aacf5e4843167d88365af9825 100644 Binary files a/cisco_flash.mkp and b/cisco_flash.mkp differ diff --git a/packages/cisco_flash b/packages/cisco_flash index 430f50c91e1272c7dc374d9abda50c0c673e7b00..f34666b53bf98357e83f69f4724d77c3945c1616 100644 --- a/packages/cisco_flash +++ b/packages/cisco_flash @@ -13,10 +13,11 @@ 'pnp-templates': [], 'web': ['plugins/metrics/cisco_flash.py', 'plugins/views/inv_cisco_flash.py', + 'plugins/wato/cisco_flash.py', 'plugins/wato/inv_cisco_flash.py']}, 'name': 'cisco_flash', - 'num_files': 5, + 'num_files': 6, 'title': 'Cisco flash plugins', - 'version': '20191103v.0.2a', + 'version': '20191104v.0.2b', 'version.min_required': '1.4.0p35', 'version.packaged': '1.4.0p35'} \ No newline at end of file diff --git a/web/plugins/wato/cisco_flash.py b/web/plugins/wato/cisco_flash.py new file mode 100644 index 0000000000000000000000000000000000000000..fa7636494d00211d3720842b01a96719eb239fd2 --- /dev/null +++ b/web/plugins/wato/cisco_flash.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# +# Check_MK cisco_flash WATO plugin +# +# Author: Th.L. +# Date: 2019-11-04 +# +# +# +# + +register_check_parameters( + subgroup_networking, + 'cisco_flash', + _('Cisco Flash'), + Dictionary( + help=_(''), + elements=[ + ('warn_level_percent', + Integer( + title=_('Warning if above percentage of used space'), + label=_('Warning if above percentage of used space'), + help=_('Warning if above percentage of used space'), + default_value=85, + allow_empty=False, + minvalue=1, + maxvalue=100 + )), + ('crit_level_percent', + Integer( + title=_('Critical if above percentage of used space'), + label=_('Critical if above percentage of used space'), + help=_('Critical if above percentage of used space'), + default_value=90, + allow_empty=False, + minvalue=1, + maxvalue=100 + )), + ], + ), + TextAscii(title=_('Cisco flash')), + match_type='dict', +)