From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11911 invoked by alias); 12 Jul 2016 01:51:38 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38833 Received: (qmail 27682 invoked from network); 12 Jul 2016 01:51:38 -0000 X-Qmail-Scanner-Diagnostics: from mout.gmx.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.227.17.22):SA:0(0.0/5.0):. Processed in 0.343485 secs); 12 Jul 2016 01:51:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: llua@gmx.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | From: Eric Cook To: zsh-workers@zsh.org Subject: [PATCH v2] improve iostat completion Date: Mon, 11 Jul 2016 21:51:28 -0400 Message-Id: <1468288288-19915-1-git-send-email-llua@gmx.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1467666732-30571-1-git-send-email-llua@gmx.com> References: <1467666732-30571-1-git-send-email-llua@gmx.com> X-Provags-ID: V03:K0:aJngoXlNgvq+jLqmBw3f42SXxBGAdnaSrGVln5zSHjVUqo3fhUw eNyet+GOsEgq3n+YGLfokY0BV/45DRE7V8ltT921LDoGtPpKntIA6VJ7xYelrkXoStrllg8 mFA7uaeGE1D2llmCoq6xeoSiGXFVyASyiUpHKna44G/7kj2VzCxO+ltyN23AS4DOcZXf1V6 eSgC5Kr1hEZ8rrqQO8uAg== X-UI-Out-Filterresults: notjunk:1;V01:K0:BNg8qmudr2o=:aiB5wqNmtnIEu0940R4xo5 OPEaH1g3Nn+bk2C62Xh5vSyn19Hu95UnB3kIdJ6jmj/cSe8kWtWfkMrhSpNIoTRpfXO8h1O8C Sji6wm/ZAfTBaofjbyhbnSBcI/zC14EZ5ZXdQyYD54Eb98+rCx1+uAKiDcj1OW3z90mnR1Aci etQzm8FZ/J0o+65JwUYRJaSAjN+I2E7+kFLCUfW31VBBjZANpGxdQw0l1ukWg8DmO1x5LBvlO uRzEUdXxo3NntjgSgbiVhSUuCCJk3Kfv4fK5pafvJQPDU/8sojQX2uNd+0WR+5AUVuBpwhR+y fpi6xD/hJ4BZcHChNwz6WPTvCmfpYoqhr5f3qDPaWeTg1TDZi2YjdVVayozRH8iwT5dtoYy33 betDqpNulzHS9gYiyhlE7mjOnihR5K4lsOKw4Ad57YWVR6SYQaLJljT1PaxPr5Xdncez50SR3 kpRFMwj6CF9oZUr7LFxrSu/f9483gVuRCZ3a8fIHl3wE52dFlCmTrRnG2/jSosSNHQygHZ7tX S3eQplMh63dQYG865q8X4O5SU8v0Kl5Lo+lmivZiz35dF54kRr/2OvihBoPSJ48Dk1j78A1bI ihNYSX+eWDRmu1AWfu5FKZtd9xnGUU7r2Qzczgki+Dyza158xZV+fujU53lvtOS+99WN5TsqL pKC4UvLio2i+l48yQc9zhJSpZBEqtwj4lBuA/1RrdR2tFZm8o6QkAHxr/HPcQtw03hKHjc/lW 7ZCFSwVv0uBxXZr+7d41O6qcRIUs5y/Dgm+zvJktgVNR7gHU8C3HoD6ak4o= Removed useless use of compdef -P --- Completion/Linux/Command/_sysstat | 37 ++++------- Completion/Unix/Command/_iostat | 132 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 26 deletions(-) create mode 100644 Completion/Unix/Command/_iostat diff --git a/Completion/Linux/Command/_sysstat b/Completion/Linux/Command/_sysstat index 2a7128c..d41e5ef 100644 --- a/Completion/Linux/Command/_sysstat +++ b/Completion/Linux/Command/_sysstat @@ -1,4 +1,4 @@ -#compdef -P mpstat (|cifs)iostat isag sadf sar pidstat +#compdef mpstat cifsiostat isag sadf sar pidstat # -V can appear with other options, so (- *) isn't needed. #TODO: # sysstat-nfsiostat - there seems to be two nfsiostat(1)s. one from oracle and one by redhat. @@ -10,24 +10,8 @@ _mpstat() { '-P[specify processor number]:processor: _values -s "," processor ON ALL {1..$(_call_program processors getconf _NPROCESSORS_ONLN)}' \ '-u[report CPU utilization]' \ '-V[print version number]' \ - '1:interval' \ - '2:count' -} - -_iostat() { - _arguments : \ - '-c[display CPU utilization report]' \ - '-d[display device utilization report]' \ - '-T[only display global statistics for group_name]' \ - '-g[display statistics for a group of devices]:group name' \ - '-h[human readable device utilization report]' \ - '-j[display persistent device name]' \ - '(-m)-k[display statistics in kB/s]' \ - '(-k)-m[display statistics in MB/s]' \ - '-N[display registered device mapper names]' \ - '::device:_files -W /dev -g "*(-%)"' \ - ': :_guard "[0-9]#" "interval"' \ - ':count' + '1: : _guard "^-*" interval' \ + '2: : _guard "^-*" count' } _cifsiostat() { @@ -37,8 +21,8 @@ _cifsiostat() { '(-k)-m[display statistics in MB/s]' \ '-t[print timestamp for each report]' \ '-V[print version number]' \ - '1:interval' \ - '2:count' + '1: : _guard "^-*" interval' \ + '2: : _guard "^-*" count' } _isag() { @@ -68,8 +52,8 @@ _sadf() { '(-t -T)-U[display in seconds since epoch (UTC)]' \ '-V[print version number]' \ '(-j -d -p)-x[output file in XML]' \ - '1:interval' \ - '2:count' \ + '1: : _guard "^-*" interval' \ + '2: : _guard "^-*" count' \ '3:data file:_files' && ret=0 else _arguments : '*::sar: _sar' && ret=0 @@ -107,8 +91,8 @@ _sar() { '-W[report swapping statistics]' \ '-w[report task creation and system switching activity]' \ '-y[report TTY device activity]' \ - '1:interval' \ - '2:count' + '1: : _guard "^-*" interval' \ + '2: : _guard "^-*" count' } _pidstat() { @@ -128,7 +112,8 @@ _pidstat() { '-V[print version number]' \ '-v[display values from kernel table]' \ '-w[report task switching activity]' \ - ':interval' ':count' + '1: : _guard "^-*" interval' \ + '2: : _guard "^-*" count' } _sysstat() { diff --git a/Completion/Unix/Command/_iostat b/Completion/Unix/Command/_iostat new file mode 100644 index 0000000..7dc33a1 --- /dev/null +++ b/Completion/Unix/Command/_iostat @@ -0,0 +1,132 @@ +#compdef iostat + +local -a args + +case $OSTYPE:l in + *bsd*) + args+=( + '-c[repeat the display N times]:count' + '-C[display CPU statistics]' + '-d[display only device statistics]' + '-I[display total statistics for a given period, rather than average]' + '-M[extract values of the name list from specified file]:core:_files' + '-N[extract the name list from the specified file]:system:_files' + '-T[display TTY statistics]' + '-w[specify the duration of pauses between each display]:duration' + ) + ;| + freebsd*) + args+=( + '-h[top mode]' + '-K[display block count in kilobytes, not block size]' + '-o[display old-style iostat device statistics]' + '-t[specify which type of device to display]: :->devicetype' + '-x[show extended disk statistics]' + '-z[omit lines for devices with no activity]' + '-?[display a usage statement and exit]' + '*:drives:( ${${(M)${(f)"$(geom disk list)"}\:#Geom name\:*}#*\: } )' + ) + ;; + openbsd*) + args+=( + '-D[display alternate disk statistics]' + '*:drives:( ${${(s.,.)"$(sysctl -n hw.disknames)"}%\:*} )' + ) + ;; + netbsd*) + args+=( + '-D[display alternate disk statistics]' + '-x[show extended disk statistics]' + '*:drives:( $(sysctl -n hw.disknames) )' + ) + ;; + aix*) + args=( + '(-b -q -Q -f -F)-a[displays the adapter throughput report]' + '(-b)-A[displays the legacy asynchronous IO utilization report, and turns off the display of TTY utilization report]' + '-b[displays the block I/O device utilization statistics]' + '(-b)-d[turns off the display of TTY utilization report or CPU utilization report]' + '(-b -f -F)-D[displays the extended tape/drive utilization report]' + '(-a -b -D)-f[displays the file system utilization report]' + '(-a -b -D)-F[displays the file system utilization report, and turns off other utilization reports]' + '(-b)-l[displays the output in long listing mode]' + '(-b -t)-m[displays the path utilization report]' + '(-b)-p[displays the tape utilization report]' + '(-b)-P[displays the POSIX asynchronous IO utilization report]' + '(-b)-q[specifies AIO queues and their request counts]' + '(-b)-Q[displays a list of all the mounted file systems and the associated queue numbers with their request counts]' + '(-b)-R[specifies that the reset of min* and max* values should happen at each interval]' + '(-b)-s[specifies the system throughput report]' + '(-b)-S[displays the processor statistics that are multiplied by a value of 10]:power' + '(-b -m)-t[turns off the display of disk utilization report]' + '-T[displays the time stamp]' + '(-b)-V[displays valid nonzero statistics]' + '(-b)-z[resets the disk input/output statistics]' + '(-b)-@[reports I/O activities of a workload partition]:workload:(ALL Global)' + '*:drives:_files' # not sure how to enumerate drives on aix + ) + ;; + solaris*) + args=( + '-c[report percentage of time the system spent in user/system mode, dtrace probes and idling]' + '-C[report extended disk statistics aggregated by controller id, when used with -x]' + '-d[report the number of kilobytes tranferred per second, tranfers per second and average service time]' + '-D[report reads/writes per second and percentage disk utilization]' + '-e[display device error summary statistics]' + '-E[display all device error statistics]' + '-i[display Device ID instead of the Serial No, when used with -E]' + '-I[report counts in each interval]' + '-l[limit the number of disks included in the report]:number of disks' + '-m[report file system mount points]' + '-M[display data throughtput in MB/sec instead of KB/sec]' + '-n[display names in descriptive format]' + '-p[report per-partition statistics]' + '-P[report per-partition statistics only]' + '-r[display data in comma-separated format]' + '-s[suppress message related to state changes]' + '-t[report the number of characters read and written to terminals per second]' + '-T[display a timestamp]:format:(( "u\:internal representation of time" "d\:standard date format" ))' + '-X[report statistics for lun.controller, for disks under scsi_vhci(7D) control]' + '-x[report extended disk statistics]' + '-Y[report statistics for lun.targetport and lun.targetport.controller, for disks under scsi_vhci(7D) control]' + '-z[ignore lines where data values are all zeros]' + '::device:( ${${${(f)"$(iostat -rx 1 1)"}[3,-1]}%%,*} )' + ) + ;; + darwin*) + args=( + '-C[display CPU statistics]' + '-c[number of times to display statistics]' + '-d[display only device statistics]' + '-l[total statstics for a given time period]' + '-K[display block count in kilobytes]' + '-n[limit the number of disks included in the report]:number of disks' + '-o[display old-style iostat device statistics]' + '-T[display TTY statistics]' + '-U[display system load averages]' + '-w[specify the duration of pauses between each display]:duration' + '*::device:_files -W /dev -g "disk*"' + ) + ;; + *linux*) + args=( + '-c[display CPU utilization report]' + '-d[display device utilization report]' + '-T[only display global statistics for group_name]' + '-g[display statistics for a group of devices]:group name' + '-h[human readable device utilization report]' + '-j[display persistent device name]' + '(-m)-k[display statistics in kB/s]' + '(-k)-m[display statistics in MB/s]' + '-N[display registered device mapper names]' + '*::device:_files -W /dev -g "*(-%)"' + ) + ;; +esac + +if (( $#args )); then + _arguments -s -w -A '-*' : $args + return +fi + +_normal -- 2.6.6