Cleanup config.nodes_of
[check_mk.git] / checks / netapp_api_systemtime
blob11d73e04764c6775dcbb8aee4ab516005663b987
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2017 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 # 7 mode
28 # <<<netapp_api_systemtime:sep(9)>>>
29 # name 76123 123
31 # Cluster mode
32 # <<<netapp_api_systemtime:sep(9)>>>
33 # node1 76123 123123
34 # node2 7612311 123123
37 def inventory_netapp_api_systemtime(info):
38 for line in info:
39 yield line[0], {}
42 def check_netapp_api_systemtime(item, params, info):
43 for line in info:
44 if line[0] == item:
45 agent_time = int(line[1])
46 system_time = int(line[2])
47 timediff = agent_time - system_time
48 warn, crit = params.get("levels", (None, None))
50 if crit is not None and timediff >= crit:
51 state = 2
52 elif warn is not None and timediff >= warn:
53 state = 1
54 else:
55 state = 0
57 infotext = "System time: %s, Time difference: %s" % \
58 (get_timestamp_human_readable(system_time),
59 get_age_human_readable(timediff))
61 if state > 0:
62 infotext += " (warn/crit at %s/%s)" % (get_age_human_readable(warn),
63 get_age_human_readable(crit))
65 return state, infotext
68 check_info['netapp_api_systemtime'] = {
69 'inventory_function': inventory_netapp_api_systemtime,
70 'check_function': check_netapp_api_systemtime,
71 'service_description': 'Systemtime %s',
72 'group': 'netapp_systemtime'