Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / df_zos
blob742344339cbac439925dc3f70544ab8fffdc6667
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2013 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 # <<<df_zos>>>
28 # SYS5.OMVS.ALF0.HFS 720 92 504 16% /ALF0
29 # HFS, Read/Write, Device:2, ACLS=Y
30 # Filetag : T=off codeset=0
31 # ##########
32 # SYS5.OMVS.SYSPLEX.ROOT 720 224 372 38% /
33 # HFS, Read Only, Device:1, ACLS=Y
34 # Filetag : T=off codeset=0
35 # ##########
37 # FS Types:
38 # AUTOMNT
39 # TFS
40 # ZFS
41 # NFS
42 # HFS
45 def parse_df_zos(info):
46 parsed = {}
47 fs = None
48 usage = []
49 options = []
51 for line in info:
52 if line[0].startswith('#####'):
53 # Add item for filesystem
54 if fs and usage and options:
55 parsed.setdefault(fs, {})
56 parsed[fs].setdefault('size', usage)
57 parsed[fs].setdefault('options', options)
59 fs = None
60 usage = []
61 options = []
62 elif line[0].startswith('Filesystem'):
63 # Ignore header line
64 continue
65 else:
66 if fs is None:
67 # First line: filesystem with usage information
68 fs = line[5]
69 usage = line[1:5]
70 elif not options:
71 # Second line: filesystem options
72 for option in line:
73 options.append(option.replace(',', ''))
74 if 'Read' in options and 'Only' in options:
75 options.remove('Read')
76 options.remove('Only')
77 options.append('ReadOnly')
78 return parsed
81 df_zos_exclude_list = ['AUTOMNT', 'TFS', 'NFS']
84 def inventory_df_zos(parsed):
85 mplist = []
87 for item in parsed.keys():
88 fs_rw = False
89 fs_ex = False
91 # Check filesystem options
92 for option in parsed[item]['options']:
93 # Check if filesystem is rw
94 if option == 'Read/Write':
95 fs_rw = True
97 # Check if filesystem is excluded
98 if option in df_zos_exclude_list:
99 fs_ex = True
101 if fs_rw and not fs_ex:
102 mplist.append(item)
103 return df_inventory(mplist)
106 def check_df_zos(item, params, parsed):
107 fslist = []
109 for filesystem in parsed.keys():
110 (size_mb, used_mb, avail_mb) = map(float, parsed[filesystem]['size'][0:3])
111 size_mb /= 1024
112 used_mb /= 1024
113 avail_mb /= 1024
114 fslist.append((filesystem, size_mb, avail_mb, 0))
116 return df_check_filesystem_list(item, params, fslist)
119 check_info['df_zos'] = {
120 'parse_function': parse_df_zos,
121 'check_function': check_df_zos,
122 'inventory_function': inventory_df_zos,
123 'service_description': "Filesystem %s",
124 'has_perfdata': True,
125 'group': 'filesystem',
126 'default_levels_variable': "filesystem_default_levels",
127 'includes': ['size_trend.include', 'df.include'],