Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / acme_sbc
blob394e470b8c524672c990235ffaafdd4fc74aae79
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2013 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 # <<<acme_sbc>>>
28 # show health
29 # Media Synchronized true
30 # SIP Synchronized true
31 # BGF Synchronized disabled
32 # MGCP Synchronized disabled
33 # H248 Synchronized disabled
34 # Config Synchronized true
35 # Collect Synchronized disabled
36 # Radius CDR Synchronized disabled
37 # Rotated CDRs Synchronized disabled
38 # IPSEC Synchronized disabled
39 # Iked Synchronized disabled
40 # Active Peer Address 179.253.2.2
42 # Redundancy Protocol Process (v3):
43 # State Standby
44 # Health 100
45 # Lowest Local Address 189.253.3.1:9090
46 # 1 peer(s) on 2 socket(s):
47 # BERTZSBC02: v3, Active, health=100, max silence=1050
48 # last received from 142.224.2.3 on wancom1:0
50 # Switchover log:
51 # Apr 24 10:14:09.235: Standby to BecomingActive, active peer xxx has timed out, no arp reply from active in 250ms
52 # Oct 17 10:07:44.567: Active to RelinquishingActive
53 # Oct 20 18:41:11.855: Standby to BecomingActive, active peer xxx has unacceptable health (70)
54 # Oct 29 11:46:04.294: Active to RelinquishingActive
55 # Oct 29 11:47:05.452: Standby to BecomingActive, active peer xxx has unacceptable health (70)
56 # Dec 8 11:37:36.445: Active to RelinquishingActive
57 # Dec 8 11:43:00.227: Standby to BecomingActive, active peer xxx has timed out, no arp reply from active in 250ms
58 # Mar 16 10:13:33.248: Active to RelinquishingActive
61 def acme_sbc_parse_function(info):
62 states = {}
63 settings = {}
64 for line in info:
65 if len(line) == 2:
66 for what in ["Health", "State"]:
67 if line[0] == what:
68 states[what] = line[1]
69 elif len(line) == 3 and line[1] == "Synchronized":
70 settings[line[0]] = line[2]
71 return states, settings
74 def inventory_acme_sbc(parsed):
75 return [(None, None)]
78 def check_acme_sbc(_no_item, _no_params, parsed):
79 health = int(parsed[0]["Health"])
80 dev_state = parsed[0]["State"]
81 if health == 100:
82 state = 0
83 else:
84 state = 2
85 return state, "Health at %d %% (State: %s)" % (health, dev_state)
88 check_info["acme_sbc"] = {
89 "check_function": check_acme_sbc,
90 "inventory_function": inventory_acme_sbc,
91 "service_description": "Status",
92 "parse_function": acme_sbc_parse_function,
96 def inventory_acme_sbc_settings(parsed):
97 return [(None, parsed[1])]
100 def check_acme_sbc_settings(_no_item, params, parsed):
101 current_settings = parsed[1]
102 saved_settings = params
103 yield 0, "Checking %d settings" % len(saved_settings)
104 for setting, value in saved_settings.items():
105 if current_settings[setting] != value:
106 yield 2, "%s changed from %s to %s" % (setting, value, current_settings[setting])
109 check_info["acme_sbc.settings"] = {
110 "check_function": check_acme_sbc_settings,
111 "inventory_function": inventory_acme_sbc_settings,
112 "service_description": "Settings",