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 # Author: Lars Michelsen <lm@mathias-kettner.de
29 # Example output of agent:
33 # Syntax of the hint file:
35 # +------------------------------------------+
36 # | in offset (Ascii, space padded, bytes) | 16 Bytes
37 # +------------------------------------------+
38 # | out offset | 16 Bytes
39 # +------------------------------------------+
40 # | Size of sylo | 16 Bytes
41 # +------------------------------------------+
43 # The check_mk_agents add the mtime in front of the hint file contents
45 # 0: alive_report (max age of hint file in seconds)
46 # 1: warn fill level in percent
47 # 2: crit fill level in percent
48 sylo_default_levels
= (70, 5, 25)
51 def inventory_sylo(info
):
52 if len(info
) > 0 and len(info
[0]) == 4:
53 return [(None, "", "sylo_default_levels")]
56 def check_sylo(item
, params
, info
):
58 return (2, "No hint file (sylo probably never ran on this system)")
63 alive_report
, warn
, crit
= params
65 mtime
= int(info
[0][0])
66 inOffset
= int(info
[0][1])
67 outOffset
= int(info
[0][2])
68 size
= int(info
[0][3])
69 size_mb
= size
/ (1024 * 1024.0)
70 warn_mb
= size_mb
* warn
/ 100.0
71 crit_mb
= size_mb
* crit
/ 100.0
74 now
= int(time
.time())
76 if age
> alive_report
:
78 return (2, "Sylo not running (Hintfile too old: last update %d secs ago)" % age
)
81 if inOffset
== outOffset
:
83 elif inOffset
> outOffset
:
84 bytesUsed
= inOffset
- outOffset
85 elif inOffset
< outOffset
:
86 bytesUsed
= size
- outOffset
+ inOffset
87 percUsed
= float(bytesUsed
) / size
* 100
88 used_mb
= bytesUsed
/ (1024 * 1024.0)
90 # Rates for input and output
91 in_rate
= get_rate("sylo.in", mtime
, inOffset
)
92 out_rate
= get_rate("sylo.out", mtime
, outOffset
)
93 msg
+= "Silo is filled %.1fMB (%.1f%%), in %.1f B/s, out %.1f B/s" % \
94 (bytesUsed
/ (1024*1024.0), percUsed
, in_rate
, out_rate
)
97 if percUsed
>= crit
and status
< 2:
99 elif percUsed
>= warn
and status
< 1:
102 return status
, msg
, [('in', '%f' % in_rate
), ('out', '%f' % out_rate
),
103 ('used', '%f' % used_mb
, warn_mb
, crit_mb
, 0, size_mb
)]
105 return (3, "Invalid hint file contents: " % info
)
108 check_info
["sylo"] = {
109 'check_function': check_sylo
,
110 'inventory_function': inventory_sylo
,
111 'service_description': 'Sylo',
112 'has_perfdata': True,