Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / ucd_hr.include
blobc35fed96b86669e4a44bb159b1fed9c1dbfe41c9
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # We are not sure how to safely detect the UCD SNMP Daemon. We know that
28 # it is mainly used on Linux, but not only. But fetching and OID outside
29 # of the info area for scanning is not a good idea. It will slow down
30 # scans for *all* hosts.
32 # ---ucd cpu load---------------------------------------------------------
34 # We prefer HOST-RESOURCES-MIB implementation but not in case
35 # of check 'ucd_cpu_load' because the HR-MIB has not data
36 # about cpu load
39 def is_ucd(oid):
40 return _is_ucd(oid)
43 # ---general ucd/hr-------------------------------------------------------
46 def is_hr(oid):
47 return bool(oid('.1.3.6.1.2.1.25.1.1.0'))
50 def prefer_hr_else_ucd(oid):
51 return _is_ucd(oid) and not oid(".1.3.6.1.2.1.25.1.1.0")
54 # ---memory---------------------------------------------------------------
57 def is_ucd_mem(oid):
58 # Avoid inverting output of a function in a check plugin and be
59 # descriptive about what a function is actually doing
60 if _ignore_both(oid):
61 return False
62 return _is_ucd_mem(oid)
65 def is_hr_mem(oid):
66 # We prefer HOST-RESOURCES-MIB implementation but not in case
67 # of devices, which are known to report incorrect information
68 # about mem usage
69 if _ignore_both(oid):
70 return False
71 return not _is_ucd_mem(oid)
74 # ---helper---------------------------------------------------------------
76 # Within _is_ucd or _is_ucd_mem we make use of a whitelist
77 # in order to expand this list of devices easily.
80 def _is_ucd(oid):
81 sys_descr = oid(".1.3.6.1.2.1.1.1.0").lower()
82 for name in [
83 "linux",
84 "cmc-tc",
85 "hp onboard administrator",
86 "barracuda",
87 "pfsense",
88 "genugate",
90 if name in sys_descr:
91 return True
93 # Artec email archive appliances
94 if oid('.1.3.6.1.2.1.1.2.0') == '.1.3.6.1.4.1.8072.3.2.10' \
95 and "version" in sys_descr and "serial" in sys_descr:
96 return True
98 return False
101 def _is_ucd_mem(oid):
102 sys_descr = oid(".1.3.6.1.2.1.1.1.0").lower()
103 # Devices for which ucd_mem should be used
104 # if and only if HR-table is not available
105 for name in [
106 "pfsense",
107 "ironport model c3",
109 if name in sys_descr and not oid(".1.3.6.1.2.1.25.1.1.0"):
110 return True
112 # Astaro and Synology are Linux but should use hr_mem
113 # Otherwise Cache/Buffers are included in used memory
114 # generating critical state
115 if oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.8072."):
116 return False
118 # Otherwise use ucd_mem for listed devices in _is_ucd.
119 return _is_ucd(oid)
122 def _ignore_both(oid):
123 # Some devices report incorrect data on both HR and UCD, eg. F5 BigIP
124 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3375")