2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
12 # Written by comNET GmbH, Ringo Hartmann
14 # This file is part of Check_MK.
15 # The official homepage is at http://mathias-kettner.de/check_mk.
17 # check_mk is free software; you can redistribute it and/or modify it
18 # under the terms of the GNU General Public License as published by
19 # the Free Software Foundation in version 2. check_mk is distributed
20 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
21 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
22 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
23 # tails. You should have received a copy of the GNU General Public
24 # License along with GNU Make; see the file COPYING. If not, write
25 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
26 # Boston, MA 02110-1301 USA.
28 # <<<appdynamics_memory:sep(124)>>>
29 # Hans|Non-Heap|Max Available (MB):304|Current Usage (MB):78|Used %:25|Committed (MB):267
30 # Hans|Heap|Max Available (MB):455|Current Usage (MB):66|Used %:14|Committed (MB):252
33 def inventory_appdynamics_memory(info
):
35 yield ' '.join(line
[0:2]), {}
38 def check_appdynamics_memory(item
, params
, info
):
40 if item
== ' '.join(line
[0:2]):
43 if item
.endswith('Non-Heap'):
45 elif item
.endswith('Heap'):
48 mem_type
= '' # Should not happen...
51 for metric
in line
[2:]:
52 name
, value
= metric
.split(':')
53 values
[name
] = int(value
)
55 used
= values
.get('Current Usage (MB)', 0) * mb
56 committed
= values
.get('Committed (MB)', 0) * mb
59 max_available
= values
['Max Available (MB)'] * mb
61 max_available
= -1 # Java 8 has no maximum for Non-Heap
64 used_percent
= 100.0 * used
/ max_available
66 warn
, crit
= params
.get(mem_type
, (None, None))
68 warn
, crit
= (None, None)
70 if isinstance(crit
, float):
71 crit_label
= '%.2f%%' % crit
72 crit
= int((max_available
/ 100) * crit
)
73 elif isinstance(crit
, int):
74 crit_label
= '%d MB free' % (crit
)
75 crit
= max_available
- (crit
* mb
)
79 if isinstance(warn
, float):
80 warn_label
= '%.2f%%' % warn
81 warn
= int((max_available
/ 100) * warn
)
82 elif isinstance(warn
, int):
83 warn_label
= '%d MB free' % (warn
)
84 warn
= max_available
- (warn
* mb
)
89 if crit
and used
>= crit
:
91 elif warn
and used
>= warn
:
96 levels_label
= ' (levels at %s/%s)' % (warn_label
, crit_label
)
99 perfdata
= [('mem_%s' % mem_type
, used
, warn
, crit
, 0, max_available
)]
100 yield state
, 'Used: %s of %s (%.2f%%)%s' % (
101 get_bytes_human_readable(used
),
102 get_bytes_human_readable(max_available
),
107 perfdata
= [('mem_%s' % mem_type
, used
)]
108 yield state
, 'Used: %s' % get_bytes_human_readable(used
), perfdata
110 if max_available
> 0:
111 perfdata
= [('mem_%s_committed' % mem_type
, committed
, None, None, 0,
114 perfdata
= [('mem_%s_committed' % mem_type
, committed
)]
115 yield 0, 'Committed: %s' % get_bytes_human_readable(committed
), perfdata
118 check_info
['appdynamics_memory'] = {
119 'inventory_function': inventory_appdynamics_memory
,
120 'check_function': check_appdynamics_memory
,
121 'service_description': 'AppDynamics Memory %s',
122 'has_perfdata': True,
123 'group': 'jvm_memory',