Browse Source

Initial commit.

George Mocanu 3 years ago
parent
commit
3720f87dd2

BIN
agents/windows/plugins/pending_reboot.ps1 View File


+ 25
- 0
checkman/pending_reboot View File

@@ -0,0 +1,25 @@
1
+title: Check for pending reboot state of Windows machines
2
+agents: windows
3
+catalog: os/windows
4
+license: GPL
5
+distribution:
6
+description:
7
+ This check checks for machines in pending reboot. 
8
+ You need to install the plugin {pending_reboot.ps1}
9
+ into the {plugins} directory of your windows agent.  
10
+ This check was tested with Windows 2008 Server and Windows 7 
11
+ and must have PowerShell installed. On Windows x64 is 
12
+ recommended to use x64 agent. As always you must set
13
+ "set-executionpolicy remotesigned" on monitored host.
14
+
15
+ The check gets critical if the pending reboot status have 24 
16
+ hours age and warning if the pending reboot status has more 
17
+ than 12 hour age.
18
+ Both limits are definable in Wato under "Parameters for 
19
+ Inventorized Checks", "Applications, Processes & Services".
20
+
21
+inventory:
22
+ One service will be created for each host running the plugin.
23
+
24
+perfdata:
25
+ None.

+ 48
- 0
checks/pending_reboot View File

@@ -0,0 +1,48 @@
1
+#!/usr/bin/python
2
+# Author: George Mocanu <george.mocanu@sphs.ro>
3
+
4
+# EXAMPLE DATA FROM: 
5
+# fomat: pendingReboot 0 8 
6
+#
7
+#<<<pending_reboot>>>
8
+#pendingReboot 0 8
9
+
10
+factory_settings["pending_reboot_default_values"] = {
11
+        "levels": (12, 24),
12
+}
13
+
14
+def inventory_pending_reboot(info):
15
+    inventory = []
16
+    for line in info:
17
+        checkName = line[0]
18
+        inventory.append( (checkName, {} ) )
19
+    return inventory
20
+
21
+
22
+def check_pending_reboot(item, params, info):
23
+    if type(params) != dict:
24
+        params = { "levels": params }
25
+    warn, crit = params["levels"]
26
+    for line in info:
27
+        if line[0] == item:
28
+            status = int(line[1])
29
+            status_time = int(line[2])
30
+            if status == 1:
31
+                if status_time > crit:
32
+                    return (2, "Computer in pending reboot for %d Hours" %status_time)
33
+                elif status_time > warn:
34
+                    return (1, "Computer in pending reboot for %d Hours" %status_time)
35
+                else:
36
+                    return (0, "Computer in pending reboot for %d Hours" %status_time)
37
+            else:
38
+                return (0, "Computer not expecting reboot")
39
+    return(3, "Plugin not running on host")
40
+
41
+check_info["pending_reboot"] = {
42
+    "check_function"		:check_pending_reboot,
43
+    "inventory_function"	:inventory_pending_reboot,
44
+    "service_description"	:"%s",
45
+    "default_levels_variable"	:"pending_reboot_default_values",
46
+    "has_perfdata"		:False,
47
+    "group"			:"pending_reboot",
48
+}

+ 17
- 0
info View File

@@ -0,0 +1,17 @@
1
+{'author': 'SpearHead Systems george.mocanu@sphs.ro',
2
+ 'description': 'Pending reboot status check',
3
+ 'download_url': 'https://github.com/spearheadsys/check_mk-pending_reboot',
4
+ 'files': {'agents': ['windows/plugins/pending_reboot.ps1'],
5
+           'checkman': ['pending_reboot'],
6
+           'checks': ['pending_reboot'],
7
+           'doc': [],
8
+           'inventory': [],
9
+           'notifications': [],
10
+           'pnp-templates': [],
11
+           'web': ['plugins/wato/pending_reboot.py']},
12
+ 'name': 'pending_reboot',
13
+ 'num_files': 4,
14
+ 'title': 'Package of pending_reboot check',
15
+ 'version': '1.1',
16
+ 'version.min_required': '1.2.6b5',
17
+ 'version.packaged': '1.2.6b5'}

BIN
pending_reboot-1.1.mkp View File


+ 32
- 0
web/plugins/wato/pending_reboot.py View File

@@ -0,0 +1,32 @@
1
+#!/usr/bin/python
2
+# 2015 george.mocanu@sphs.ro
3
+
4
+register_check_parameters(
5
+    subgroup_applications,
6
+    "pending_reboot",
7
+    _("Windows Pending Reboot Status"),
8
+    Dictionary(
9
+        elements = [
10
+            ("levels", # Name of your parameters
11
+                Tuple(
12
+                    title = "Levels for pending reboot check", # Specify a title for this parameters
13
+                    elements = [
14
+                        Integer(
15
+                            title = _("Warning if above"),
16
+                            unit = _("Hours"),
17
+                            default_value = 10
18
+                        ),
19
+                        Integer(
20
+                            title = _("Critical if above"),
21
+                            unit = _("Hours"),
22
+                            default_value = 20
23
+                        ),
24
+                    ]
25
+                )
26
+            ),
27
+	],
28
+        optional_keys = None, # Always show this subgroup
29
+    ),
30
+    TextAscii( title = "Service name"),
31
+    "dict"
32
+)    

Loading…
Cancel
Save