Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / appdynamics_sessions
blobae2821be3305eaae75df141f4bccfa63364fd257
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 # +------------------------------------------------------------------+
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_sessions:sep(124)>>>
29 # Hans|/hans|rejectedSessions:0|sessionAverageAliveTime:1800|sessionCounter:13377|expiredSessions:13371|processingTime:1044|maxActive:7|activeSessions:6|sessionMaxAliveTime:4153
32 def inventory_appdynamics_sessions(info):
33 for line in info:
34 yield ' '.join(line[0:2]), {}
37 def check_appdynamics_sessions(item, params, info):
38 for line in info:
39 if item == ' '.join(line[0:2]):
40 values = {}
41 for metric in line[2:]:
42 name, value = metric.split(':')
43 values[name] = int(value)
45 active = values['activeSessions']
46 rejected = values['rejectedSessions']
47 max_active = values['maxActive']
48 counter = values['sessionCounter']
50 now = time.time()
51 rate_id = 'appdynamics_sessions.%s.counter' % (item.lower().replace(' ', '_'))
52 counter_rate = get_rate(rate_id, now, counter)
54 state = 0
55 perfdata = []
56 if isinstance(params, tuple):
57 min_warn, min_crit, max_warn, max_crit = params
58 perfdata.append(('running_sessions', active, max_warn, max_crit))
60 if active <= min_crit or active >= max_crit:
61 state = 2
62 elif active <= min_warn or active >= max_warn:
63 state = 1
64 else:
65 perfdata.append(('running_sessions', active))
67 active_label = ''
68 if state > 0:
69 active_label = ' (warn/crit below %d/%d / warn/crit at %d/%d)' \
70 % (min_warn, min_crit, max_warn, max_crit)
72 yield state, 'Active: %d (%.2f/sec)%s' % (active, counter_rate, active_label), perfdata
74 perfdata = [('rejected_sessions', rejected)]
75 yield 0, 'Rejected: %d' % rejected, perfdata
77 yield 0, 'Maximum active: %d' % max_active
80 check_info['appdynamics_sessions'] = {
81 'inventory_function': inventory_appdynamics_sessions,
82 'check_function': check_appdynamics_sessions,
83 'service_description': 'AppDynamics Sessions %s',
84 'has_perfdata': True,
85 'group': 'jvm_sessions',