about summary refs log tree commit diff
path: root/Completion/Unix/Command/_vmstat
blob: 7082cbbd5b6fa2618fcf3d32eca728562191a991 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#compdef vmstat

local -a specs
case $OSTYPE in
  *linux*)
    specs=(
      '(-a --active)'{-a,--active}'[active/inactive memory]'
      '(-f --forks)'{-f,--forks}'[number of forks since boot]'
      '(-m --slabs)'{-m,--slabs}'[slabinfo]'
      '(-n --one-header)'{-n,--one-header}'[do not redisplay header]'
      '(-s --stats)'{-s,--stats}'[event counter statistics]'
      '(-d --disk)'{-d,--disk}'[disk statistics]'
      '(-D --disk-sum)'{-D,--disk-sum}'[summarize disk statistics]'
      '(-p --partition)'{-p,--partition}'[partition specific statistics]:partition:_files'
      '(-S --unit)'{-S+,--unit}'[define display unit]:unit prefix:(( k\:1000 K\:1024 m\:1000000 M\:1048576 ))'
      '(-w --wide)'{-w,--wide}'[wide output]'
      '(-t --timestamp)'{-t,--timestamp}'[show timestamp]'
      '1:delay' '2:count'
    )
  ;;
  freebsd*|openbsd*)
    specs=(
      '-c[number of times to refresh the display]:count'
      '-f[report on the number fork syscalls since boot and pages of virtual memory for each]'
      '-i[report the number of interrupts taken by devices since boot]'
      '-M[source file to extract values associated with the name list from]:core:_files'
      '-N[source file to extract the name list from]:system:_files'
      '-w[specify delay between each display]:delay (seconds)'
      '*:disk:_files'
    )
  ;|
  freebsd*)
    specs+=(
      '-a[include statistics about all interrupts]'
      '-h[human readable memory columns output]'
      '-H[scriptable memory columns output]'
      '-m[report on the usage of kernel dynamic memory allocated using malloc(9) by type]'
      '-n[change the maximum number of disks to display]:number of disks to display'
      '-o[list virtual memory objects]'
      '-P[report per-cpu system/user/idle cpu statistics]'
      '-p[specify which types of devices to display]: :->devices'
      '-s[display the contents of the SUM structure]:sum'
      '-z[report on memory used by the kernel zone allocator, uma(9), by zone]'
    )
  ;;
  openbsd*)
    specs+=(
      '-m[report usage of kernel dynamic memory listed first by size of allocation then type of usage]'
      '-s[display the contents of the UVMEXP structure]:uvmexp'
      '-t[report on the number of page in and page reclaims since boot]'
      '-v[print more verbose information]'
      '-z[include statistics about all interrupts]'
    )
  ;;
esac

if (( $#specs )); then
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A {opt,val}_args

  _arguments -C -s -w -A '-*' : "$specs[@]" && ret=0

  if [[ $state == devices ]]; then
    local -a types
    types=(
      'da[direct access devices]' 'sa[sequential access devices]'
      'printer[printers]' 'proc[processor devices]'
      'worm[write once read multiple devices]' 'cd[CD devices]'
      'scanner[scanner devices]' 'optical[optical memory devices]'
      'changer[medium changer devices]' 'comm[communication devices]'
      'array[storage array devices]' 'enclosure[enclosure services devices]'
      'floppy[floppy devices]' 'IDE[Integrated Drive Electronics devices]'
      'SCSI[Small Computer System Interface devices]'
      'other[any other device interface]' 'pass[passthrough devices]'
    )
    _values -C -s , 'device type' "$types[@]" && ret=0
  fi
  return ret
fi

_default