2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2018 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 # .1.3.6.1.2.1.25.2.3.1.2.1 .1.3.6.1.2.1.25.2.1.2 --> HOST-RESOURCES-MIB::hrStorageType.1
28 # .1.3.6.1.2.1.25.2.3.1.2.3 .1.3.6.1.2.1.25.2.1.3 --> HOST-RESOURCES-MIB::hrStorageType.3
29 # .1.3.6.1.2.1.25.2.3.1.3.1 Physical memory --> HOST-RESOURCES-MIB::hrStorageDescr.1
30 # .1.3.6.1.2.1.25.2.3.1.3.3 Virtual memory --> HOST-RESOURCES-MIB::hrStorageDescr.3
31 # .1.3.6.1.2.1.25.2.3.1.4.1 1024 --> HOST-RESOURCES-MIB::hrStorageAllocationUnits.1
32 # .1.3.6.1.2.1.25.2.3.1.4.3 1024 --> HOST-RESOURCES-MIB::hrStorageAllocationUnits.3
33 # .1.3.6.1.2.1.25.2.3.1.5.1 8122520 --> HOST-RESOURCES-MIB::hrStorageSize.1
34 # .1.3.6.1.2.1.25.2.3.1.5.3 21230740 --> HOST-RESOURCES-MIB::hrStorageSize.3
35 # .1.3.6.1.2.1.25.2.3.1.6.1 7749124 --> HOST-RESOURCES-MIB::hrStorageUsed.1
36 # .1.3.6.1.2.1.25.2.3.1.6.3 7749124 --> HOST-RESOURCES-MIB::hrStorageUsed.3
39 # Juniper devices put information about the device into the
40 # field where we expect the mount point. Ugly. Remove that crap.
41 def fix_hr_fs_mountpoint(mp
):
42 mp
= mp
.replace("\\", "/")
43 if "mounted on:" in mp
:
44 return mp
.rsplit(":", 1)[-1].strip()
46 pos
= mp
.find("Label:")
47 return mp
[:pos
].rstrip()
51 def inventory_hr_fs(info
):
53 for hrtype
, hrdescr
, _hrunits
, hrsize
, _hrused
in info
:
54 hrdescr
= fix_hr_fs_mountpoint(hrdescr
)
55 # NOTE: These types are defined in the HR-TYPES-MIB.
56 # .1.3.6.1.2.1.25.2.1 +
57 # +-> .4 "hrStorageFixedDisk"
58 if hrtype
in [ ".1.3.6.1.2.1.25.2.1.4",
59 # This strange value below is needed for VCenter Appliances
60 ".1.3.6.1.2.1.25.2.3.1.2.4"] and \
61 hrdescr
not in inventory_df_exclude_mountpoints
and \
63 mplist
.append(hrdescr
)
64 return df_inventory(mplist
)
67 def check_hr_fs(item
, params
, info
):
70 if "Label:" in item
or "\\" in item
:
71 return 3, "check had an incompatible change, please re-discover services on this host"
73 for _hrtype
, hrdescr
, hrunits
, hrsize
, hrused
in info
:
74 hrdescr
= fix_hr_fs_mountpoint(hrdescr
)
75 if "patterns" in params
or item
== hrdescr
:
76 unit_size
= saveint(hrunits
)
77 hrsize
= saveint(hrsize
)
79 hrsize
= hrsize
+ 2**32
80 size
= hrsize
* unit_size
81 hrused
= saveint(hrused
)
83 hrused
= hrused
+ 2**32
84 used
= hrused
* unit_size
85 size_mb
= size
/ 1048576.0
86 used_mb
= used
/ 1048576.0
87 avail_mb
= size_mb
- used_mb
88 fslist
.append((hrdescr
, size_mb
, avail_mb
, 0))
90 return df_check_filesystem_list(item
, params
, fslist
)