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.
28 # Memory: 256G real, 54G free, 257G swap in use, 86G swap free
31 # Memory: 512M phys mem, 353M free mem, 2000M total swap, 2000M free swap
34 # Memory: 10G phys mem, 1905M free mem, 8002M total swap, 8002M free swap
37 # Memory: 640M real, 10M free, 293M swap in use, 349M swap free
40 # Memory: 2048M real, 913M free, 723M swap in use, 2863M swap free
43 def parse_solaris_mem(info
):
44 # The 1.2.4 agent seems to create an empty section under some circumstances
49 mem_tokens
= " ".join(info
[0][1:]).split(",")
51 for token
in mem_tokens
:
52 if "total swap" in token
:
54 values
.append(solaris_mem_to_kbytes(token
.split()[0]))
56 # convert swap-in-use to swap-total, as expected by check_memory()
58 values
[2] = values
[2] + values
[3]
60 keys
= ['MemTotal', 'MemFree', 'SwapTotal', 'SwapFree']
61 return dict(zip(keys
, values
))
64 def solaris_mem_to_kbytes(s
):
66 return int(s
[:-1]) * 1024 * 1024
68 return int(s
[:-1]) * 1024
72 raise Exception("Could not parse value %s" % s
)
75 def inventory_solaris_mem_used(parsed
):
80 def check_solaris_mem_used(_no_item
, params
, parsed
):
81 return check_memory(params
, parsed
)
84 check_info
['solaris_mem'] = {
85 "parse_function": parse_solaris_mem
,
86 "check_function": check_solaris_mem_used
,
87 "inventory_function": inventory_solaris_mem_used
,
88 "service_description": "Memory used",
91 "default_levels_variable": "memory_default_levels",
92 "includes": ["mem.include"],