diff --git a/agents/windows/plugins/pending_reboot.ps1 b/agents/windows/plugins/pending_reboot.ps1 new file mode 100644 index 0000000..7f11804 Binary files /dev/null and b/agents/windows/plugins/pending_reboot.ps1 differ diff --git a/checkman/pending_reboot b/checkman/pending_reboot new file mode 100644 index 0000000..b66e270 --- /dev/null +++ b/checkman/pending_reboot @@ -0,0 +1,25 @@ +title: Check for pending reboot state of Windows machines +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check checks for machines in pending reboot. + You need to install the plugin {pending_reboot.ps1} + into the {plugins} directory of your windows agent. + This check was tested with Windows 2008 Server and Windows 7 + and must have PowerShell installed. On Windows x64 is + recommended to use x64 agent. As always you must set + "set-executionpolicy remotesigned" on monitored host. + + The check gets critical if the pending reboot status have 24 + hours age and warning if the pending reboot status has more + than 12 hour age. + Both limits are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each host running the plugin. + +perfdata: + None. diff --git a/checks/pending_reboot b/checks/pending_reboot new file mode 100644 index 0000000..e44a23e --- /dev/null +++ b/checks/pending_reboot @@ -0,0 +1,48 @@ +#!/usr/bin/python +# Author: George Mocanu + +# EXAMPLE DATA FROM: +# fomat: pendingReboot 0 8 +# +#<<>> +#pendingReboot 0 8 + +factory_settings["pending_reboot_default_values"] = { + "levels": (12, 24), +} + +def inventory_pending_reboot(info): + inventory = [] + for line in info: + checkName = line[0] + inventory.append( (checkName, {} ) ) + return inventory + + +def check_pending_reboot(item, params, info): + if type(params) != dict: + params = { "levels": params } + warn, crit = params["levels"] + for line in info: + if line[0] == item: + status = int(line[1]) + status_time = int(line[2]) + if status == 1: + if status_time > crit: + return (2, "Computer in pending reboot for %d Hours" %status_time) + elif status_time > warn: + return (1, "Computer in pending reboot for %d Hours" %status_time) + else: + return (0, "Computer in pending reboot for %d Hours" %status_time) + else: + return (0, "Computer not expecting reboot") + return(3, "Plugin not running on host") + +check_info["pending_reboot"] = { + "check_function" :check_pending_reboot, + "inventory_function" :inventory_pending_reboot, + "service_description" :"%s", + "default_levels_variable" :"pending_reboot_default_values", + "has_perfdata" :False, + "group" :"pending_reboot", +} diff --git a/info b/info new file mode 100644 index 0000000..e753f18 --- /dev/null +++ b/info @@ -0,0 +1,17 @@ +{'author': 'SpearHead Systems george.mocanu@sphs.ro', + 'description': 'Pending reboot status check', + 'download_url': 'https://github.com/spearheadsys/check_mk-pending_reboot', + 'files': {'agents': ['windows/plugins/pending_reboot.ps1'], + 'checkman': ['pending_reboot'], + 'checks': ['pending_reboot'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/wato/pending_reboot.py']}, + 'name': 'pending_reboot', + 'num_files': 4, + 'title': 'Package of pending_reboot check', + 'version': '1.1', + 'version.min_required': '1.2.6b5', + 'version.packaged': '1.2.6b5'} diff --git a/pending_reboot-1.1.mkp b/pending_reboot-1.1.mkp new file mode 100644 index 0000000..d06a582 Binary files /dev/null and b/pending_reboot-1.1.mkp differ diff --git a/web/plugins/wato/pending_reboot.py b/web/plugins/wato/pending_reboot.py new file mode 100644 index 0000000..aed530b --- /dev/null +++ b/web/plugins/wato/pending_reboot.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# 2015 george.mocanu@sphs.ro + +register_check_parameters( + subgroup_applications, + "pending_reboot", + _("Windows Pending Reboot Status"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for pending reboot check", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("Hours"), + default_value = 10 + ), + Integer( + title = _("Critical if above"), + unit = _("Hours"), + default_value = 20 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Service name"), + "dict" +)