]> git.proxmox.com Git - zfsonlinux.git/blob - zfs-patches/0014-Add-documentation-strings-to-arc_summary.py.patch
add remaining zfs-0.7.6 changes as patches
[zfsonlinux.git] / zfs-patches / 0014-Add-documentation-strings-to-arc_summary.py.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
3 Date: Sun, 5 Nov 2017 22:11:37 +0100
4 Subject: [PATCH] Add documentation strings to arc_summary.py
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Include docstrings (PEP8, PEP257) for module and all functions.
10 Separately, remove outdated section in comment at start of
11 module. Separately, remove unused global constant "usetunable".
12
13 Reviewed-by: George Melikov <mail@gmelikov.ru>
14 Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
15 Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
16 Closes #6818
17 (cherry picked from commit 03955e348803a942048db8b32827f7ff6715c02e)
18 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
19 ---
20 cmd/arc_summary/arc_summary.py | 56 +++++++++++++++++++++++++++++++-----------
21 1 file changed, 42 insertions(+), 14 deletions(-)
22
23 diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
24 index cbb7d20bc..f4968fb6a 100755
25 --- a/cmd/arc_summary/arc_summary.py
26 +++ b/cmd/arc_summary/arc_summary.py
27 @@ -31,34 +31,37 @@
28 #
29 # If you are having troubles when using this script from cron(8) please try
30 # adjusting your PATH before reporting problems.
31 -#
32 -# /usr/bin & /sbin
33 -#
34 -# Binaries used are:
35 -#
36 -# dc(1), kldstat(8), sed(1), sysctl(8) & vmstat(8)
37 -#
38 -# Binaries that I am working on phasing out are:
39 -#
40 -# dc(1) & sed(1)
41 +"""Print statistics on the ZFS Adjustable Replacement Cache (ARC)
42 +
43 +Provides basic information on the ARC, its efficiency, the L2ARC (if present),
44 +the Data Management Unit (DMU), Virtual Devices (VDEVs), and tunables. See the
45 +in-source documentation and code at
46 +https://github.com/zfsonlinux/zfs/blob/master/module/zfs/arc.c for details.
47 +"""
48
49 import sys
50 import time
51 import getopt
52 import re
53 +
54 from os import listdir
55 from subprocess import Popen, PIPE
56 from decimal import Decimal as D
57
58 -
59 -usetunable = True
60 show_tunable_descriptions = False
61 alternate_tunable_layout = False
62 kstat_pobj = re.compile("^([^:]+):\s+(.+)\s*$", flags=re.M)
63
64
65 def get_Kstat():
66 + """Collect information on the ZFS subsystem from the /proc virtual
67 + file system. The name "kstat" is a holdover from the Solaris utility
68 + of the same name.
69 + """
70 +
71 def load_proc_kstats(fn, namespace):
72 + """Collect information on a specific subsystem of the ARC"""
73 +
74 kstats = [line.strip() for line in open(fn)]
75 del kstats[0:2]
76 for kstat in kstats:
77 @@ -148,6 +151,8 @@ def fHits(hits=0):
78
79
80 def fPerc(lVal=0, rVal=0, Decimal=2):
81 + """Calculate percentage value and return in human-readable format"""
82 +
83 if rVal > 0:
84 return str("%0." + str(Decimal) + "f") % (100 * (lVal / rVal)) + "%"
85 else:
86 @@ -155,6 +160,7 @@ def fPerc(lVal=0, rVal=0, Decimal=2):
87
88
89 def get_arc_summary(Kstat):
90 + """Collect general data on the ARC"""
91
92 output = {}
93 memory_throttle_count = Kstat[
94 @@ -256,6 +262,8 @@ def get_arc_summary(Kstat):
95
96
97 def _arc_summary(Kstat):
98 + """Print information on the ARC"""
99 +
100 # ARC Sizing
101 arc = get_arc_summary(Kstat)
102
103 @@ -330,6 +338,8 @@ def _arc_summary(Kstat):
104
105
106 def get_arc_efficiency(Kstat):
107 + """Collect information on the efficiency of the ARC"""
108 +
109 output = {}
110
111 arc_hits = Kstat["kstat.zfs.misc.arcstats.hits"]
112 @@ -453,6 +463,8 @@ def get_arc_efficiency(Kstat):
113
114
115 def _arc_efficiency(Kstat):
116 + """Print information on the efficiency of the ARC"""
117 +
118 arc = get_arc_efficiency(Kstat)
119
120 sys.stdout.write("ARC Total accesses:\t\t\t\t\t%s\n" %
121 @@ -563,6 +575,8 @@ def _arc_efficiency(Kstat):
122
123
124 def get_l2arc_summary(Kstat):
125 + """Collection information on the L2ARC"""
126 +
127 output = {}
128
129 l2_abort_lowmem = Kstat["kstat.zfs.misc.arcstats.l2_abort_lowmem"]
130 @@ -657,6 +671,7 @@ def get_l2arc_summary(Kstat):
131
132
133 def _l2arc_summary(Kstat):
134 + """Print information on the L2ARC"""
135
136 arc = get_l2arc_summary(Kstat)
137
138 @@ -741,6 +756,8 @@ def _l2arc_summary(Kstat):
139
140
141 def get_dmu_summary(Kstat):
142 + """Collect information on the DMU"""
143 +
144 output = {}
145
146 zfetch_hits = Kstat["kstat.zfs.misc.zfetchstats.hits"]
147 @@ -766,6 +783,7 @@ def get_dmu_summary(Kstat):
148
149
150 def _dmu_summary(Kstat):
151 + """Print information on the DMU"""
152
153 arc = get_dmu_summary(Kstat)
154
155 @@ -787,6 +805,8 @@ def _dmu_summary(Kstat):
156
157
158 def get_vdev_summary(Kstat):
159 + """Collect information on the VDEVs"""
160 +
161 output = {}
162
163 vdev_cache_delegations = \
164 @@ -817,6 +837,8 @@ def get_vdev_summary(Kstat):
165
166
167 def _vdev_summary(Kstat):
168 + """Print information on the VDEVs"""
169 +
170 arc = get_vdev_summary(Kstat)
171
172 if arc['vdev_cache_total'] > 0:
173 @@ -836,6 +858,8 @@ def _vdev_summary(Kstat):
174
175
176 def _tunable_summary(Kstat):
177 + """Print information on tunables"""
178 +
179 global show_tunable_descriptions
180 global alternate_tunable_layout
181
182 @@ -901,8 +925,8 @@ unSub = [
183
184
185 def zfs_header():
186 - """Print title string with date
187 - """
188 + """Print title string with date"""
189 +
190 daydate = time.strftime('%a %b %d %H:%M:%S %Y')
191
192 sys.stdout.write('\n'+'-'*72+'\n')
193 @@ -911,6 +935,8 @@ def zfs_header():
194
195
196 def usage():
197 + """Print usage information"""
198 +
199 sys.stdout.write("Usage: arc_summary.py [-h] [-a] [-d] [-p PAGE]\n\n")
200 sys.stdout.write("\t -h, --help : "
201 "Print this help message and exit\n")
202 @@ -931,6 +957,8 @@ def usage():
203
204
205 def main():
206 + """Main function"""
207 +
208 global show_tunable_descriptions
209 global alternate_tunable_layout
210
211 --
212 2.14.2
213