GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / kaspersky_av_client
blob77a272ce28aebec6c8b56208dc4d193c4faa9700
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # <<<kaspersky_av_client>>>
28 # Signatures 08.05.2015 01:23:00
29 # Fullscan 08.05.2015 05:43:16 0
31 # <<<kaspersky_av_client>>>
32 # Signatures 13.12.2016 11:55:00
34 factory_settings['kaspersky_av_client_default_levels'] = {
35 'signature_age': (86400, 7 * 86400),
36 'fullscan_age': (86400, 7 * 86400),
40 def parse_kaspersky_av_client(info):
41 now = time.time()
42 parsed = {}
44 for line in info:
45 if line[1] == 'Missing':
46 continue
48 timestamp_text = line[1] + " " + line[2]
49 # We assume that the timestamp is to be interpreted in the timezone of
50 # the Check_MK server. This might be a problem, if e.g. the agent is located
51 # in China and the Check_MK server in USA.
52 age = now - time.mktime(time.strptime(timestamp_text, '%d.%m.%Y %H:%M:%S'))
54 if line[0] == "Signatures":
55 parsed['signature_age'] = age
57 elif line[0] == "Fullscan":
58 parsed['fullscan_age'] = age
60 # handle state of last fullscan if provided
61 if len(line) == 4:
62 parsed['fullscan_failed'] = line[3] != "0"
64 return parsed
67 def inventory_kaspersky_av_client(parsed):
68 return [(None, {})]
71 def check_kaspersky_av_client(_no_item, params, parsed):
72 for key, what in [
73 ("signature_age", "Last update of signatures"),
74 ("fullscan_age", "Last fullscan"),
76 age = parsed.get(key)
77 if age is None:
78 yield 3, what + ": unknown"
79 else:
80 warn, crit = params[key]
81 if age >= crit:
82 state = 2
83 elif age >= warn:
84 state = 1
85 else:
86 state = 0
88 infotext = "%s %s ago" % (what, get_age_human_readable(age))
89 if state > 0:
90 infotext += " (warn/crit at %s/%s)" % (get_age_human_readable(warn),
91 get_age_human_readable(crit))
93 yield state, infotext
95 if parsed.get("fullscan_failed"):
96 yield 2, "Last fullscan failed"
99 check_info['kaspersky_av_client'] = {
100 'parse_function': parse_kaspersky_av_client,
101 'inventory_function': inventory_kaspersky_av_client,
102 'check_function': check_kaspersky_av_client,
103 'service_description': 'Kaspersky AV',
104 'default_levels_variable': 'kaspersky_av_client_default_levels',
105 'group': 'kaspersky_av_client',