Module: check_mk
Branch: master
Commit: f7741b0fc6eb4c5998ca4cd85b76263a83121f8c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f7741b0fc6eb4c…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Jan 14 15:12:13 2014 +0100
services.summary: new check to monitor stopped services of mode autostart in windows
---
.werks/566 | 8 +++++
ChangeLog | 1 +
checkman/services.summary | 30 ++++++++++++++++
checks/services | 62 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 33 ++++++++++++++++++
5 files changed, 134 insertions(+)
diff --git a/.werks/566 b/.werks/566
new file mode 100644
index 0000000..d375693
--- /dev/null
+++ b/.werks/566
@@ -0,0 +1,8 @@
+Title: services.summary: new check to monitor stopped services of mode autostart in
windows
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1389708658
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 2f8e444..cc4e873 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,7 @@
* 0324 hitachi_hnas_cifs: new check for the number of users using a CIFS share
* 0455 hitachi_hnas_span: new check for Spans (Storage Pools) in Hitachi HNAS storage
systems
* 0445 mem.win: Allow time-averaging of values before applying levels...
+ * 0566 services.summary: new check to monitor stopped services of mode autostart in
windows
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/checkman/services.summary b/checkman/services.summary
new file mode 100644
index 0000000..2071226
--- /dev/null
+++ b/checkman/services.summary
@@ -0,0 +1,30 @@
+title: Windows Services
+agents: windows
+catalog: applications
+license: GPL
+distribution: check_mk
+description:
+ This check gives a summary of the windows services and monitors
+ the number of services of mode "autostart" which are stopped.
+ The state of the check as soon as such a stopped service is found
+ can be configured to be any valid state. The default is {OK}. Also,
+ if no such stopped service is found, the state is {OK}.
+
+ A list of ignored services can be configured. These services will not be
+ considered when determining the stopped services.
+
+[configuration]
+{services_summary_default_levels(dict):} A dictionary with the following preset keys
+
+{"ignored": (),}
+{"state_of_stopped": 0}
+
+
+[parameters]
+parameters(dict): A dictionary with the following keys:
+
+ {"ignored"}: tuple: A tuple of service names or regular expressions for
+ services. These services will be disregarded when determining the state of the check
+
+ {"state_if_stopped"}: int: The monitoring state that should be applied if
+ stopped services are found
diff --git a/checks/services b/checks/services
index decd941..5fa1f4e 100644
--- a/checks/services
+++ b/checks/services
@@ -235,3 +235,65 @@ check_info['services'] = {
"group" : "services",
"default_levels_variable" : "services_default_levels",
}
+
+factory_settings["services_summary_default_levels"] = {
+ "ignored": (),
+ "state_if_stopped": 0
+}
+
+def inventory_services_summary(info):
+ if info[0]:
+ return [ (None, "services_summary_default_levels") ]
+
+def check_services_summary(item, params, info):
+ blacklist = params.get("ignored", () )
+ stoplist = []
+ num_blacklist = 0
+ num_auto = 0
+ for line in info:
+ startstop, auto = line[2].split("/")
+ srv_name = line[1]
+ if auto == "auto":
+ num_auto += 1
+ if startstop == "stopped":
+ match = False
+ for srv in blacklist:
+ if re.match(srv,srv_name):
+ match = True
+ if match == False:
+ stoplist.append(srv_name)
+ else:
+ num_blacklist += 1
+
+ num_stoplist = len(stoplist)
+ num_srv = len(info)
+ length_runlist = len(info) - len(stoplist) - num_blacklist
+
+ if len(stoplist) > 0:
+ stopped_srvs = " ("+", ".join(stoplist)+")"
+ state = params.get("state_if_stopped")
+ if state == 1:
+ sym = "(!)"
+ elif state == 2:
+ sym="(!!)"
+ else:
+ sym = ""
+ else:
+ stopped_srvs = ""
+ state = 0
+ sym = ""
+
+
+ infotext = "%d services, %d services in autostart - of which %d services are
stopped%s%s, %d services stopped but ignored" % \
+ ( num_srv, num_auto, num_stoplist, sym, stopped_srvs, num_blacklist )
+
+ return state, infotext
+
+check_info['services.summary'] = {
+ "check_function" : check_services_summary,
+ "inventory_function" : inventory_services_summary,
+ "default_levels_variable" : "services_summary_default_levels",
+ "service_description" : "Services Summary",
+ "node_info" : True,
+ "group" : "services_summary",
+}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 9af97d5..f51346e 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -2083,6 +2083,38 @@ register_check_parameters(
None,
"dict",
)
+
+register_check_parameters(
+ subgroup_applications,
+ "services_summary",
+ _("Windows Service Summary"),
+ Dictionary(
+ title = _('Autostart Services'),
+ elements = [
+ ('ignored',
+ ListOfStrings(
+ title = _("Ignored autostart services"),
+ help = _('Regular expressions matching the begining of the internal
name '
+ 'or the description of the service. '
+ 'If no name is given then this rule will match all
services. The '
+ 'match is done on the <i>beginning</i> of the
service name. It '
+ 'is done <i>case sensitive</i>. You can do a
case insensitive match '
+ 'by prefixing the regular expression with
<tt>(?i)</tt>. Example: '
+ '<tt>(?i).*mssql</tt> matches all services
which contain <tt>MSSQL</tt> '
+ 'or <tt>MsSQL</tt> or
<tt>mssql</tt> or...'),
+ orientation = "horizontal",
+ )),
+ ('state_if_stopped',
+ MonitoringState(
+ title = _("Default state if stopped autostart services are
found"),
+ default_value = 0,
+ )),
+ ],
+ ),
+ None,
+ "dict"
+)
+
register_check_parameters(
subgroup_applications,
"esx_vsphere_objects",
@@ -4536,3 +4568,4 @@ register_check_parameters(
),
"first", False
)
+