Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2981)

Unified Diff: bootstat_last

Issue 5265008: Add new bootstat_get_last command (Closed) Base URL: http://git.chromium.org/git/bootstat.git@master
Patch Set: Update the README file Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« README ('K') | « README ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bootstat_last
diff --git a/bootstat_last b/bootstat_last
new file mode 100755
index 0000000000000000000000000000000000000000..36707cb2b529a45f9fea37a33cb5fa1fff2a03b5
--- /dev/null
+++ b/bootstat_last
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+getfield() {
+ shift $1
+ echo $1
+}
+
+EVENT=$1
+shift
+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
+ set -- time
+fi
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ time)
+ TAG=uptime
+ FIELD=1
+ ;;
+ read-sectors)
+ TAG=disk
+ FIELD=3
+ ;;
+ write-sectors)
+ TAG=disk
+ FIELD=7
+ ;;
+ *)
+ shift
+ continue
+ ;;
+ esac
+ STATFILE=/tmp/${TAG}-${EVENT}
+ if [ -f $STATFILE ]; then
petkov 2010/12/04 00:00:55 you could do this on one line: [ -f $STATFILE ] &&
+ getfield $FIELD $(tail -1 $STATFILE)
+ fi
+ shift
+done
« README ('K') | « README ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698