Cleanup config.nodes_of
[check_mk.git] / checks / mbg_lantime_refclock
blobe909d475690786fadaf49494c69dfa017b0b945c
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 mbg_lantime_refclock_refmode_map = {
28 '0': 'notavailable',
29 '1': 'normalOperation',
30 '2': 'trackingSearching',
31 '3': 'antennaFaulty',
32 '4': 'warmBoot',
33 '5': 'coldBoot',
34 '6': 'antennaShortcircuit',
37 mbg_lantime_refclock_gpsstate_map = {
38 '0': 'not available',
39 '1': 'synchronized',
40 '2': 'not synchronized',
43 # number of good satellites
44 mbg_lantime_refclock_default_levels = (3, 3)
47 def inventory_mbg_lantime_refclock(info):
48 if len(info) > 0 and len(info[0]) == 6:
49 return [(None, None, "mbg_lantime_refclock_default_levels")]
52 def check_mbg_lantime_refclock(item, params, info):
53 if len(info) > 0 and len(info[0]) == 6:
54 ref_mode, gps_state, gps_pos, gps_sat_good, gps_sat_total, _gps_mode = info[0]
56 state = 0
57 state_txt = []
59 # Handle the reported refclock mode
60 thr_txt = ''
61 if ref_mode in ['0', '3', '6']:
62 state = max(state, 2)
63 thr_txt = ' (!!)'
64 elif ref_mode in ['2', '4', '5']:
65 state = max(state, 1)
66 thr_txt = ' (!)'
67 state_txt.append('Refclock State: %s%s' % (mbg_lantime_refclock_refmode_map.get(
68 ref_mode, 'UNKNOWN'), thr_txt))
70 # Handle gps state
71 thr_txt = ''
72 if gps_state in ['0', '2']:
73 state = max(state, 2)
74 thr_txt = ' (!!)'
75 state_txt.append('GPS State: %s%s' % (mbg_lantime_refclock_gpsstate_map.get(
76 gps_state, 'UNKNOWN'), thr_txt))
78 # Add gps position
79 state_txt.append(gps_pos)
81 # Handle number of satellites
82 thr_txt = ''
83 if params[0] is not None and int(gps_sat_good) < params[1]:
84 state = max(state, 2)
85 thr_txt = ' (!!)'
86 elif params[1] is not None and int(gps_sat_good) < params[0]:
87 state = max(state, 1)
88 thr_txt = ' (!)'
89 state_txt.append('Satellites: %s/%s%s' % (gps_sat_good, gps_sat_total, thr_txt))
91 perfdata = [('sat_good', gps_sat_good, params[0], params[1]), ('sat_total', gps_sat_total)]
93 return (state, ', '.join(state_txt), perfdata)
95 return (3, 'Got no state information')
98 check_info["mbg_lantime_refclock"] = {
99 'check_function': check_mbg_lantime_refclock,
100 'inventory_function': inventory_mbg_lantime_refclock,
101 'service_description': 'LANTIME Refclock',
102 'has_perfdata': True,
103 'snmp_info': (
104 '.1.3.6.1.4.1.5597.3.2',
106 4, # MBG-SNMP-MIB::mbgLtRefClockModeVal
107 6, # MBG-SNMP-MIB::mbgLtRefGpsStateVal
108 7, # MBG-SNMP-MIB::mbgLtRefGpsPosition
109 9, # MBG-SNMP-MIB::mbgLtRefGpsSatellitesGood
110 10, # MBG-SNMP-MIB::mbgLtRefGpsSatellitesInView
111 16, # MBG-SNMP-MIB::mbgLtRefGpsModeVal
113 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.5597.3",