Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / sophos
bloba348d97128e647af198e8ac4f818ffe365c4dcef
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 # .1.3.6.1.4.1.2604.3.4 2 --> SOPHOS::sophosHwMemoryConsumption Indicates whether the appliance is consuming excessive memory
28 # .1.3.6.1.4.1.2604.3.5 2 --> SOPHOS::sophosHwMemoryStatus Indicates whether the appliance detects less memory than expected
29 # .1.3.6.1.4.1.2604.3.6 0 --> SOPHOS::sophosHwRaid Indicates whether the appliance RAID system is operating normally
30 # .1.3.6.1.4.1.2604.3.7 2 --> SOPHOS::sophosHwCpuStatus Indicates whether the appliance CPU is operating normally
31 # .1.3.6.1.4.1.2604.3.8 0 --> SOPHOS::sophosHwPowerSupplyLeft Indicates whether the left power supply is operating normally
32 # .1.3.6.1.4.1.2604.3.9 0 --> SOPHOS::sophosHwPowerSupplyRight Indicates whether the right power supply is operating normally
33 # .1.3.6.1.4.1.2604.3.10 0 --> SOPHOS::sophosHwPowerSupplyFanLeft Indicates whether the left power supply fan is operating normally
34 # .1.3.6.1.4.1.2604.3.11 0 --> SOPHOS::sophosHwPowerSupplyFanRight Indicates whether the left power supply fan is operating normally
35 # .1.3.6.1.4.1.2604.3.12 2 --> SOPHOS::sophosHwSystemFan Indicates whether all fans are operating normally
36 # .1.3.6.1.4.1.2604.3.13 2 --> SOPHOS::sophosHwTemperature Indicates whether the appliance is operating within an acceptable temperature range
37 # .1.3.6.1.4.1.2604.3.14 2 --> SOPHOS::sophosHwVoltage Indicates whether the appliance is operating within normal voltage ranges
38 # .1.3.6.1.4.1.2604.3.16 2 --> SOPHOS::sophosHwPowerSupplies Indicates whether both power supplies are operating normally
40 sophos_map_oid = {
41 "4": ("Memory Consumption", {
42 "2": " (the appliance is consuming normal memory)",
43 "3": " (the appliance is consuming inflated memory)",
44 "4": " (the appliance is consuming excessive memory)",
45 }),
46 "5": ("Memory", {
47 "2": " (the appliance detects memory than expected)",
48 "3": " (the appliance detects less memory than expected)",
49 "4": " (the appliance detects insufficient memory than expected)",
50 }),
51 "6": ("RAID", {
52 "2": " (the appliance RAID system is operating normally)",
53 "3": " (the appliance RAID system is operating abnormally)",
54 "4": " (the appliance RAID system is operating viciously)",
55 }),
56 "7": ("CPU Utilization", {
57 "2": " (the appliance CPU is operating normally)",
58 "3": " (the appliance CPU is operating abnormally)",
59 "4": " (the appliance CPU is operating viciously)",
60 }),
61 "8": ("Power Supply Left", {
62 "2": " (the left power supply is operating normally)",
63 "3": " (the left power supply is operating abnormally)",
64 "4": " (the left power supply is operating viciously)",
65 }),
66 "9": ("Power Supply Right", {
67 "2": " (the right power supply is operating normally)",
68 "3": " (the right power supply is operating abnormally)",
69 "4": " (the right power supply is operating viciously)",
70 }),
71 "10": ("Fan Left", {
72 "2": " (the left fan is operating normally)",
73 "3": " (the left fan is operating abnormally)",
74 "4": " (the left fan is operating viciously)",
75 }),
76 "11": ("Fan Right", {
77 "2": " (the right fan is operating normally)",
78 "3": " (the right fan is operating abnormally)",
79 "4": " (the right fan is operating viciously)",
80 }),
81 "12": ("Fan Summary", {
82 "2": " (all fans are operating normally)",
83 "3": " (all fans are operating abnormally)",
84 "4": " (all fans are operating viciously)",
85 }),
86 "13": ("Temperature", {
87 "2": " (the appliance is operating within an acceptable temperature range)",
88 "3": " (the appliance is operating in the margins of an acceptable temperature range)",
89 "4": " (the appliance is operating outside an acceptable temperature range)",
90 }),
91 "14": ("Power Supply Voltage", {
92 "2": " (the appliance is operating within a normal voltage range)",
93 "3": " (the appliance is operating in the margins of a normal voltage range)",
94 "4": " (the appliance is operating outside of a normal voltage range)",
95 }),
96 "16": ("Power Supply Summary", {
97 "2": " (both power supplies are operating normally)",
98 "3": " (one or both power supplies are operating abnormally)",
99 "4": " (one or both power supplies are operating viciously)",
104 def inventory_sophos(info):
105 inventory = []
106 for item_oid, item_state in info:
107 if item_oid in sophos_map_oid and item_state in ["2", "3", "4"]:
108 inventory.append((sophos_map_oid[item_oid][0], None))
109 return inventory
112 def check_sophos(item, _no_params, info):
113 sophos_map_state = {
114 "0": (3, "unknown"),
115 "1": (3, "disabled"),
116 "2": (0, "OK"),
117 "3": (1, "warn"),
118 "4": (2, "error"),
120 for item_oid, item_state in info:
121 item_name, item_info = sophos_map_oid.get(item_oid, (None, None))
122 if item_name == item:
123 state, state_readable = sophos_map_state[item_state]
124 extra_info = item_info.get(item_state, "")
125 infotext = "Status: %s%s" % (state_readable, extra_info)
126 return state, infotext
129 check_info['sophos'] = {
130 'inventory_function': inventory_sophos,
131 'check_function': check_sophos,
132 'service_description': '%s',
133 'snmp_info': (".1.3.6.1.4.1.2604.3", [OID_END, ""]),
134 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.2604",