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 # Example output from agent:
29 # 2036F23D SRV_WATCHPROD LEF 0 05:10:00.39 945007498 7721395
30 # 20201AF1 DRS_WATCHDOG_22 LEF 0 00:01:39.97 284611 2030
33 def inventory_vms_queuejobs(info
):
37 def check_vms_queuejobs(_no_item
, params
, info
):
41 for _id
, name
, _state
, cpu_days
, cpu_time
, _ios
, _pgfaults
in info
:
43 hours
, minutes
, seconds
= map(float, cpu_time
.split(":"))
44 cpu_secs
= int(cpu_days
) * 86400 + hours
* 3600 + minutes
* 60 + seconds
45 if cpu_secs
> max_cpu_secs
:
46 max_cpu_secs
= cpu_secs
49 infotext
= "%d jobs" % len(info
)
51 minutes
, seconds
= divmod(max_cpu_secs
, 60)
52 hours
, minutes
= divmod(minutes
, 60)
53 days
, hours
= divmod(hours
, 24)
54 infotext
+= ', most CPU used by %s (%d days, %02d:%02d:%02d.%02d)' % \
55 (max_cpu_job
, days
, hours
, minutes
, int(seconds
), int(seconds
* 100))
60 check_info
['vms_queuejobs'] = {
61 "check_function": check_vms_queuejobs
,
62 "inventory_function": inventory_vms_queuejobs
,
63 "service_description": "Queue Jobs",