From eea88787a9e0a5740f2392846e6a5b1f78b04423 Mon Sep 17 00:00:00 2001 From: Marius Pana Date: Sat, 24 Jan 2015 14:41:21 +0200 Subject: [PATCH] switched to factory settings - dictionary based switched to factory settings - dictionary based values for our check params --- agents/plugins/sph-exchange-database-size.ps1 | 2 +- checks/exchange_db_size | 10 +++--- info | 18 +++++++++++ .../wato/exchange_db_size_check_parameters.py | 31 ++++++++++++++----- 4 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 info diff --git a/agents/plugins/sph-exchange-database-size.ps1 b/agents/plugins/sph-exchange-database-size.ps1 index dfc2e89..fcac32e 100644 --- a/agents/plugins/sph-exchange-database-size.ps1 +++ b/agents/plugins/sph-exchange-database-size.ps1 @@ -14,6 +14,6 @@ $dbs = Get-MailboxDatabase -Status | ? {$_.Mounted -eq $True} | Sort Name ForEach ($db in $dbs) { $DBsize = $db.DatabaseSize.ToMB() $DBfreeSpace = $db.AvailableNewMailboxSpace.ToMB() - Write-Host "<<>>" + Write-Host "<<>>" Write-Host "$($db.Name) $DBsize $DBfreeSpace" } diff --git a/checks/exchange_db_size b/checks/exchange_db_size index aab8aee..5f08159 100644 --- a/checks/exchange_db_size +++ b/checks/exchange_db_size @@ -4,8 +4,8 @@ # EXAMPLE DATA FROM: # format: datbase size_in_MB free_MB_available #<<>> -#marius.pana@sphs.ro 177 -#mpana@sphs.ro 81 +#RomaniaEXC 177 +#ExchangeDB_Size 81 factory_settings["exchange_db_size_default_values"] = { "levels" : (20000, 25000), @@ -21,8 +21,10 @@ def inventory_exchange_db_size(info): return inventory def check_exchange_db_size(item, params, info): + if type(params) != dict: + params = { "levels" : params } #unpack check params - warn, crit = params + warn, crit = params["levels"] for line in info: if line[0] == item: dbsize = int(line[1]) @@ -43,7 +45,7 @@ check_info["exchange_db_size"] = { 'check_function': check_exchange_db_size, 'inventory_function': inventory_exchange_db_size, 'service_description': '%s Database size', - #'default_levels_variable': 'exchange_user_mbx_size_default_values', + 'default_levels_variable': 'exchange_user_mbx_size_default_values', 'has_perfdata': True, 'group': 'exchange_db_size', } diff --git a/info b/info new file mode 100644 index 0000000..c491ef5 --- /dev/null +++ b/info @@ -0,0 +1,18 @@ +{'author': 'Marius Pana', + 'description': 'Check exchange database size', + 'download_url': 'https://github.com/spearheadsys/check_mk-exchange-database-size', + 'files': {'agents': ['plugins/sph-exchange-database-size.ps1'], + 'checkman': ['exchange_db_size'], + 'checks': ['exchange_db_size'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': ['check_mk-exchange_db_size.php'], + 'web': ['plugins/perfometer/exchange_db_size_perfometer.py', + 'plugins/wato/exchange_db_size_check_parameters.py']}, + 'name': 'exchange_db_size', + 'num_files': 6, + 'title': 'exchange_db_size', + 'version': '1.1', + 'version.min_required': '1.2.6b1', + 'version.packaged': '1.2.6b1'} \ No newline at end of file diff --git a/web/plugins/wato/exchange_db_size_check_parameters.py b/web/plugins/wato/exchange_db_size_check_parameters.py index d4505d8..e565248 100644 --- a/web/plugins/wato/exchange_db_size_check_parameters.py +++ b/web/plugins/wato/exchange_db_size_check_parameters.py @@ -6,13 +6,28 @@ register_check_parameters( subgroup_applications, "exchange_db_size", _("MS Exchange Database Size"), - Tuple( - title = _('Maximum Database Size'), - elements = [ - Integer(title = _("Warning if above"), default_value = 20000 ), - Integer(title = _("Critical if above"), default_value = 25000 ), - ] + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for database", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("MB"), + default_value = 20000 + ), + Integer( + title = _("Critical if above"), + unit = _("MB"), + default_value = 25000 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup ), - None, - None, + TextAscii( title = "Name of database"), + "dict" )