Module: check_mk
Branch: master
Commit: 5dd361e4eac04cc84da7f7ad179f689e6f7f66ae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5dd361e4eac04c…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Oct 22 16:35:50 2015 +0200
added function to query the effective service level from a check
the effective service level is the service level for that service if one is configured,
otherwise
the one of the host.
---
modules/check_mk_base.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 762aa9d..dd6a756 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -2253,6 +2253,20 @@ def check_timeperiod(timeperiod):
return timeperiod not in g_inactive_timerperiods
+# retrive the service level that applies to the calling check.
+def get_effective_service_level():
+ service_levels = service_extra_conf(g_hostname, g_service_description,
+ service_service_levels)
+
+ if service_levels:
+ return service_levels[0]
+ else:
+ service_levels = host_extra_conf(g_hostname, host_service_levels)
+ if service_levels:
+ return service_levels[0]
+ return 0
+
+
#.
# .--Aggregation---------------------------------------------------------.
# | _ _ _ |