2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | "_ \ / _ \/ __| |/ / | |\/| | " / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # .--general-------------------------------------------------------------.
29 # | __ _ ___ _ __ ___ _ __ __ _| | |
30 # | / _` |/ _ \ '_ \ / _ \ '__/ _` | | |
31 # | | (_| | __/ | | | __/ | | (_| | | |
32 # | \__, |\___|_| |_|\___|_| \__,_|_| |
34 # +----------------------------------------------------------------------+
36 mbg_lantime_ng_refclock_types
= {
102 def mbg_lantime_ng_generalstate(clock_type
, usage
, state
, substate
):
104 "0": "not available",
111 "0": (2, "not available"),
112 "1": (0, "synchronized"),
113 "2": (1, "not synchronized"),
116 # Translation for values of MBG-SNMP-LTNG-MIB::mbgLtNgRefclockSubstate
117 refclock_substates
= {
118 "0": "not available",
121 "3": "GPS antenna disconnected",
122 "4": "GPS warm boot",
123 "5": "GPS cold boot",
124 "6": "GPS antenna short circuit",
125 "50": "LW never sync",
128 "100": "TCR not sync",
130 "149": "MRS internal oscillator sync",
131 "150": "MRS GPS sync",
132 "151": "MRS 10Mhz sync",
133 "152": "MRS PPS in sync",
134 "153": "MRS 10Mhz PPS in sync",
135 "154": "MRS IRIG sync",
136 "155": "MRS NTP sync",
137 "156": "MRS PTP IEEE 1588 sync",
138 "157": "MRS PTP over E1 sync",
139 "158": "MRS fixed frequency in sync",
140 "159": "MRS PPS string sync",
141 "160": "MRS variable frequency GPIO sync",
142 "161": "MRS reserved",
143 "162": "MRS DCF77 PZF sync",
144 "163": "MRS longwave sync",
145 "164": "MRS GLONASS GPS sync",
146 "165": "MRS HAVE QUICK sync",
147 "166": "MRS external oscillator sync",
151 state
, state_txt
= refclock_states
[state
]
152 detailed_state_txt
= (' (%s)' % refclock_substates
[substate
] if substate
!= '0' else '')
153 infotext
= "Type: %s, Usage: %s, State: %s%s" % (mbg_lantime_ng_refclock_types
[clock_type
],
154 refclock_usages
[usage
], state_txt
,
157 return state
, infotext
161 # .--gps refclocks-------------------------------------------------------.
163 # | __ _ _ __ ___ _ __ ___ / _| ___| | ___ ___| | _____ |
164 # | / _` | '_ \/ __| | '__/ _ \ |_ / __| |/ _ \ / __| |/ / __| |
165 # | | (_| | |_) \__ \ | | | __/ _| (__| | (_) | (__| <\__ \ |
166 # | \__, | .__/|___/ |_| \___|_| \___|_|\___/ \___|_|\_\___/ |
168 # +----------------------------------------------------------------------+
170 # number of good satellites
171 mbg_lantime_refclock_default_levels
= (3, 3)
174 def inventory_lantime_ng_refclock_gps(info
):
176 if mbg_lantime_ng_refclock_types
[line
[1]].startswith("gps"):
177 yield (line
[0], 'mbg_lantime_refclock_default_levels')
180 def check_lantime_ng_refclock_gps(item
, params
, info
):
181 for (index
, clock_type
, usage
, state
, substate
, status_a
, max_status_a
, _
, _
, _
,
182 leapsecond_date
) in info
:
185 yield mbg_lantime_ng_generalstate(clock_type
, usage
, state
, substate
)
187 if substate
not in ("1", "2"):
188 yield 0, "Next leap second: %s" % str(leapsecond_date
)
190 # Levels for satellites are checked only if we have a substate
191 # that indicates that a GPS connection is needed. For the
192 # LANTIME M600/MRS the GPS antenna is e.g. optional.
193 if substate
in ("1", "2", "3", "4", "5", "6", "150"):
194 state
, levels_txt
= 0, ""
195 good_sats
, total_sats
= int(status_a
), int(max_status_a
)
199 levels_txt
= " (warn/crit below %d/%d)" % params
200 elif good_sats
< warn
:
202 levels_txt
= " (warn/crit below %d/%d)" % params
204 yield state
, "Satellites: %d/%d%s" % (good_sats
, total_sats
, levels_txt
)
207 check_info
["mbg_lantime_ng_refclock.gps"] = {
208 "check_function": check_lantime_ng_refclock_gps
,
209 "inventory_function": inventory_lantime_ng_refclock_gps
,
210 "service_description": "LANTIME Refclock %s",
211 "has_perfdata": True,
215 # .--other refclocks-----------------------------------------------------.
217 # | ___ | |_| |__ ___ _ __ |
218 # | / _ \| __| '_ \ / _ \ '__| |
219 # | | (_) | |_| | | | __/ | |
220 # | \___/ \__|_| |_|\___|_| |
223 # | _ __ ___ / _| ___| | ___ ___| | _____ |
224 # | | '__/ _ \ |_ / __| |/ _ \ / __| |/ / __| |
225 # | | | | __/ _| (__| | (_) | (__| <\__ \ |
226 # | |_| \___|_| \___|_|\___/ \___|_|\_\___/ |
228 # +----------------------------------------------------------------------+
231 def inventory_lantime_ng_refclock(info
):
233 if not mbg_lantime_ng_refclock_types
[line
[1]].startswith("gps"):
234 yield (line
[0], None)
237 def check_lantime_ng_refclock(item
, _no_params
, info
):
239 for (index
, clock_type
, usage
, state
, substate
, status_a
, max_status_a
, status_b
, max_status_b
,
243 yield mbg_lantime_ng_generalstate(clock_type
, usage
, state
, substate
)
245 field_strength
= round(float(status_b
) / float(max_status_b
) * 100.0)
246 perfdata
= [("field_strength", field_strength
)]
248 yield 0, "Field strength: %d%%" % field_strength
, perfdata
250 # only used for longwave - pzf refclocks
251 if max_status_a
!= "0":
252 correlation
= round(float(status_a
) / float(max_status_a
) * 100.0)
253 perfdata
= [("correlation", correlation
)]
254 yield 0, "Correlation: %d%%" % correlation
, perfdata
257 check_info
["mbg_lantime_ng_refclock"] = {
258 "check_function": check_lantime_ng_refclock
,
259 "inventory_function": inventory_lantime_ng_refclock
,
260 "service_description": "LANTIME Refclock %s",
261 "has_perfdata": True,
263 ".1.3.6.1.4.1.5597.30.0.1.2.1",
265 1, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockIndex
266 2, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockType
267 3, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockUsage
268 4, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockState
269 5, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockSubstate
270 6, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockStatusA
271 7, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockMaxStatusA
272 8, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockStatusB
273 9, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockMaxStatusB
274 10, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockAdditionalInfo
275 11, # MBG-SNMP-LTNG-MIB::mbgLtNgRefclockLeapSecondDate
277 "snmp_scan_function": snmp_scan_mbg_lantime_ng_hw
,
278 "includes": ["mbg_lantime.include"],