GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / systemtime
blob3f56036c54d572174cba5637afd5df470f2035fa
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 systemtime_default_values = (30, 60) # warn/crit sec. offset
30 def inventory_systemtime(info):
31 if len(info) >= 1:
32 return [(None, "systemtime_default_values")]
35 def check_systemtime(item, params, info):
36 if len(info) == 0:
37 return (3, "no information sent by agent")
39 systemtime = int(info[0][0])
40 try:
41 systemtime += get_agent_data_time()
42 except (NameError, TypeError):
43 pass
45 ourtime = int(time.time())
46 offset = systemtime - ourtime
47 warn, crit = params
48 infotext = "Offset is %d sec (warn/crit at %d/%d sec)" % (offset, warn, crit)
49 perfdata = [("offset", offset, warn, crit, 0)]
51 if abs(offset) >= crit:
52 return (2, infotext, perfdata)
53 elif abs(offset) >= warn:
54 return (1, infotext, perfdata)
55 return (0, infotext, perfdata)
58 check_info["systemtime"] = {
59 'check_function': check_systemtime,
60 'inventory_function': inventory_systemtime,
61 'service_description': 'System Time',
62 'has_perfdata': True,
63 'group': 'systemtime',