default levels

This commit is contained in:
George Pochiscan 2019-01-07 19:06:10 +02:00
parent 50f7e378fe
commit 207b17d688
5 changed files with 151 additions and 5 deletions

BIN
Check_NSX-1.5.mkp Normal file

Binary file not shown.

View File

@ -169,12 +169,19 @@ check_info['nsx_components'] = {
# +----------------------------------------------------------------------+ # +----------------------------------------------------------------------+
# | | # | |
# '----------------------------------------------------------------------' # '----------------------------------------------------------------------'
factory_settings["nsx_backups_default_levels"] = {
"levels" : ( 7, 14 ),
}
nsx_backups_default_levels = ( 7, 14 )
def inventory_nsx_backups(info): def inventory_nsx_backups(info):
return [(None, {})] return [(None, {})]
def check_nsx_backup(item, params, info): def check_nsx_backup(item, params, info):
warn, crit = params warn, crit = params["levels"]
if info: if info:
last_backup = sorted(info, key=lambda tup: tup[2])[-1] last_backup = sorted(info, key=lambda tup: tup[2])[-1]
last_backup_size = last_backup[1] last_backup_size = last_backup[1]
@ -197,6 +204,7 @@ check_info['nsx_backup'] = {
'service_description' : 'NSX Backups', 'service_description' : 'NSX Backups',
'has_perfdata' : False, 'has_perfdata' : False,
'group' : "backups", 'group' : "backups",
'default_levels_variable': "nsx_backups_default_levels",
} }
#. #.
@ -208,7 +216,10 @@ check_info['nsx_backup'] = {
# | |_| |_|\___|_| |_| |_|\___/|_| \__, | | # | |_| |_|\___|_| |_| |_|\___/|_| \__, | |
# | |___/ | # | |___/ |
# +----------------------------------------------------------------------+ # +----------------------------------------------------------------------+
nsx_memory_default_levels = ( 80.0, 90.0 ) factory_settings["nsx_mem_default_levels"] = {
"levels" : ( 80.0, 90.0 ),
}
def nsx_convert(info): def nsx_convert(info):
data = {} data = {}
@ -222,7 +233,7 @@ def inventory_nsx_mem(info):
def check_nsx_mem(item, params, info): def check_nsx_mem(item, params, info):
data = nsx_convert(info) data = nsx_convert(info)
warn, crit = params warn,crit = params["levels"]
memory_usage = savefloat(data['UsedMemory'][0]) * 1024 * 1024 memory_usage = savefloat(data['UsedMemory'][0]) * 1024 * 1024
memory_size = savefloat(data['TotalMem'][0]) * 1024 * 1024 memory_size = savefloat(data['TotalMem'][0]) * 1024 * 1024
level = savefloat(data['UsedPercentage'][0]) level = savefloat(data['UsedPercentage'][0])
@ -360,14 +371,17 @@ check_info['nsx_vcenter_connection'] = {
# +----------------------------------------------------------------------+ # +----------------------------------------------------------------------+
# | | # | |
# '----------------------------------------------------------------------' # '----------------------------------------------------------------------'
nsx_storage_default_levels = ( 70.0, 80.0 ) factory_settings["nsx_storage_default_levels"] = {
"levels" : ( 80.0, 90.0 ),
}
def inventory_nsx_storage(info): def inventory_nsx_storage(info):
data = nsx_convert(info) data = nsx_convert(info)
return [(None, 'nsx_storage_default_levels')] return [(None, 'nsx_storage_default_levels')]
def check_nsx_storage(item, params, info): def check_nsx_storage(item, params, info):
warn,crit = params warn,crit = params["levels"]
data = nsx_convert(info) data = nsx_convert(info)
used_storage = float(re.sub('G','', data['UsedStorage'][0],count =1)) used_storage = float(re.sub('G','', data['UsedStorage'][0],count =1))
total_storage = float(re.sub('G','', data['TotalStorage'][0],count =1)) total_storage = float(re.sub('G','', data['TotalStorage'][0],count =1))

View File

@ -0,0 +1,77 @@
register_check_parameters(
subgroup_applications,
"backups",
_("Time since last backup"),
Dictionary(
elements = [
("levels",
Tuple(
title = _("Time since of last backup"),
elements = [
Integer(
title = _("Warning Level for time since last backup"),
help = _("Warning Level for time since last backup."),
unit = _("days"),
default_value = 7,
),
Integer(
title = _("Critical Level for time since last backup"),
help = _("Critical Level for time since last backup."),
unit = _("days"),
default_value = 14,
),
]
)
)]
),
None,
"dict"
)
register_check_parameters(
subgroup_os,
"nsx_memory",
_("Main memory usage of VMWare NSX system"),
Dictionary(
elements = [
("levels",
Tuple(
title = _("Specify levels in percentage of total RAM"),
elements = [
Percentage(
title = _("Warning at a RAM usage of"),
help = _("Warning level if memory usage is above"),
default_value = 80.0
),
Percentage(
title = _("Critical at a RAM usage of"),
help= _("Critical level if memory usage is above"),
default_value = 90.0
),
]
)
)]
),
None,
match_type = "dict",
)
register_check_parameters(
subgroup_os,
"nsx_storage",
_("Storage usage of VMWare NSX system"),
Dictionary(
elements = [
("levels",
Tuple(
title = _("Specify levels in percentage of total RAM"),
elements = [
Percentage(title = _("Warning at a storage usage of"), default_value = 80.0),
Percentage(title = _("Critical at a storage usage of"), default_value = 90.0),
]
)
)]
),
None,
match_type = "dict",
)

View File

@ -0,0 +1,33 @@
group = 'datasource_programs'
register_rule(
group,
"special_agents:nsx",
Dictionary(
optional_keys = [ "cert", "nsx_resource" ],
elements = [
("user", TextAscii(title = _("Username"), allow_empty = False)),
("password", Password(title = _("Password"), allow_empty = False)),
("cert", DropdownChoice(
title = _("SSL certificate verification"),
choices = [
(True, _("Activate")),
(False, _("Deactivate")),
] )),
("nsx_resource", ListOfStrings(
title = _("Resource"),
orientation = "horizontal",
help = _("Enter the full list of resources for Cluster"
"Compute Resource that needs to be monitored."
"If no value is entered, No Computer Resource"
"will be monitored."),
allow_empty = True)),
],
),
title = _("Check VMWare NSX"),
help = _("This rule set selects the special agent for VMWare NSX "
"instead of the normal Check_MK agent and allows monitoring via Web API. "
"Resource value is optional and used for monitoring the NSX host "
"preparation status"),
match = "first",
)

View File

@ -0,0 +1,22 @@
group = 'datasource_programs'
register_rule(
group,
"special_agents:srm",
Dictionary(
optional_keys = [ "cert" ],
elements = [
("cert", DropdownChoice(
title = _("SSL certificate verification"),
choices = [
(True, _("Activate")),
(False, _("Deactivate")),
] )),
],
),
title = _("Check VMWare SRM"),
help = _("This rule set selects the special agent for VMWare SRM "
"instead of the normal Check_MK agent and allows monitoring via Web API. "
"Connection is made on NSX appliance on port 9086."),
match = "first",
)