OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/sh | |
2 | |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 getfield() { | |
8 shift $1 | |
9 echo $1 | |
10 } | |
11 | |
12 EVENT=$1 | |
13 shift | |
14 if [ $# -eq 0 ]; then | |
petkov
2010/12/04 00:00:55
you could do this on one line:
[ $# -eq 0 ] && ..
jrbarnette
2010/12/04 00:12:49
The code guidelines actually discourage this, and
| |
15 set -- time | |
16 fi | |
17 | |
18 while [ $# -gt 0 ]; do | |
19 case "$1" in | |
20 time) | |
21 TAG=uptime | |
22 FIELD=1 | |
23 ;; | |
24 read-sectors) | |
25 TAG=disk | |
26 FIELD=3 | |
27 ;; | |
28 write-sectors) | |
29 TAG=disk | |
30 FIELD=7 | |
31 ;; | |
32 *) | |
33 shift | |
34 continue | |
35 ;; | |
36 esac | |
37 STATFILE=/tmp/${TAG}-${EVENT} | |
38 if [ -f $STATFILE ]; then | |
petkov
2010/12/04 00:00:55
you could do this on one line:
[ -f $STATFILE ] &&
| |
39 getfield $FIELD $(tail -1 $STATFILE) | |
40 fi | |
41 shift | |
42 done | |
OLD | NEW |