Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / cmk_base / check_utils.py
blobd97b4d536d4f6431d86b3362e99cd81999610a69
1 #!/usr/bin/env python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # .------------------------------------------------------------------------.
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |_____| |
10 # | _____ _ _ |
11 # | | ____|_ __ | |_ ___ _ __ _ __ _ __(_)___ ___ |
12 # | | _| | '_ \| __/ _ \ '__| '_ \| '__| / __|/ _ \ |
13 # | | |___| | | | || __/ | | |_) | | | \__ \ __/ |
14 # | |_____|_| |_|\__\___|_| | .__/|_| |_|___/\___| |
15 # | |_| |
16 # | _____ _ _ _ _ |
17 # | | ____|__| (_) |_(_) ___ _ __ |
18 # | | _| / _` | | __| |/ _ \| '_ \ |
19 # | | |__| (_| | | |_| | (_) | | | | |
20 # | |_____\__,_|_|\__|_|\___/|_| |_| |
21 # | |
22 # | mathias-kettner.com mathias-kettner.de |
23 # '------------------------------------------------------------------------'
24 # This file is part of the Check_MK Enterprise Edition (CEE).
25 # Copyright by Mathias Kettner and Mathias Kettner GmbH. All rights reserved.
27 # Distributed under the Check_MK Enterprise License.
29 # You should have received a copy of the Check_MK Enterprise License
30 # along with Check_MK. If not, email to mk@mathias-kettner.de
31 # or write to the postal address provided at www.mathias-kettner.de
33 import cmk_base
36 def section_name_of(check_plugin_name):
37 return check_plugin_name.split(".")[0]
40 def is_snmp_check(check_plugin_name):
41 cache = cmk_base.runtime_cache.get_dict("is_snmp_check")
42 try:
43 return cache[check_plugin_name]
44 except KeyError:
45 snmp_checks = cmk_base.runtime_cache.get_set("check_type_snmp")
46 result = section_name_of(check_plugin_name) in snmp_checks
47 cache[check_plugin_name] = result
48 return result
51 def is_tcp_check(check_plugin_name):
52 cache = cmk_base.runtime_cache.get_dict("is_tcp_check")
53 try:
54 return cache[check_plugin_name]
55 except KeyError:
56 tcp_checks = cmk_base.runtime_cache.get_set("check_type_tcp")
57 result = section_name_of(check_plugin_name) in tcp_checks
58 cache[check_plugin_name] = result
59 return result