2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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
= {
29 '1': 'normalOperation',
30 '2': 'trackingSearching',
34 '6': 'antennaShortcircuit',
37 mbg_lantime_refclock_gpsstate_map
= {
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]
59 # Handle the reported refclock mode
61 if ref_mode
in ['0', '3', '6']:
64 elif ref_mode
in ['2', '4', '5']:
67 state_txt
.append('Refclock State: %s%s' % (mbg_lantime_refclock_refmode_map
.get(
68 ref_mode
, 'UNKNOWN'), thr_txt
))
72 if gps_state
in ['0', '2']:
75 state_txt
.append('GPS State: %s%s' % (mbg_lantime_refclock_gpsstate_map
.get(
76 gps_state
, 'UNKNOWN'), thr_txt
))
79 state_txt
.append(gps_pos
)
81 # Handle number of satellites
83 if params
[0] is not None and int(gps_sat_good
) < params
[1]:
86 elif params
[1] is not None and int(gps_sat_good
) < params
[0]:
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,
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",