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 factory_settings
["mbg_lantime_state_default_levels"] = {
29 "offset": (10, 20), # us
33 def snmp_scan_mbg_lantime_ng_hw(oid
):
34 return oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.5597.3" or \
35 oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.5597.30"
38 def check_mbg_lantime_state_common(states
, _no_item
, params
, info
):
39 ntp_state
, stratum
, refclock_name
, refclock_offset
= info
[0]
40 if not isinstance(params
, dict):
42 "stratum": (params
[0], params
[1]),
43 "offset": (params
[2], params
[3]),
47 yield states
[ntp_state
][0], "State: " + states
[ntp_state
][1]
49 # Check the reported stratum
52 warn
, crit
= params
["stratum"]
53 if int(stratum
) >= crit
:
55 elif int(stratum
) >= warn
:
58 levels_text
= " (warn/crit at %d/%d)" % (warn
, crit
)
59 yield state
, "Stratum: %s%s" % (stratum
, levels_text
)
61 # Add refclock information
62 yield 0, "Reference clock: " + refclock_name
67 warn
, crit
= params
["offset"]
68 refclock_offset
= float(refclock_offset
)
69 pos_refclock_offset
= abs(refclock_offset
)
70 if pos_refclock_offset
>= crit
:
72 elif pos_refclock_offset
>= warn
:
75 levels_text
= u
" (warn/crit at %d/%d µs)" % (warn
, crit
)
76 perfdata
= [("offset", refclock_offset
, warn
* 1000, crit
* 1000)] # all in us
77 yield state
, u
"Reference clock offset: %g µs%s" % (refclock_offset
, levels_text
), perfdata