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

Side by Side Diff: metrics_daemon_main.cc

Issue 6541007: Find device-dependent disk stats file, and skip disk stats if not available. (Closed) Base URL: http://git.chromium.org/git/metrics.git@master
Patch Set: Use a (probably) better stat file Created 9 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« metrics_daemon.cc ('K') | « metrics_daemon.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include <base/logging.h>
6 #include <gflags/gflags.h> 7 #include <gflags/gflags.h>
8 #include <rootdev/rootdev.h>
7 9
8 #include "metrics_daemon.h" 10 #include "metrics_daemon.h"
9 11
10 DEFINE_bool(daemon, true, "run as daemon (use -nodaemon for debugging)"); 12 DEFINE_bool(daemon, true, "run as daemon (use -nodaemon for debugging)");
11 13
12 // Path to disk stats. This may be system dependent. 14 // Return the path to the disk stats in the sysfs.
13 const char kMetricsMainDiskStatsPath[] = "/sys/class/block/sda/stat"; 15 static
16 const std::string MetricsMainDiskStatsPath() {
17 char dev_path[PATH_MAX];
18 int ret = rootdev(dev_path, sizeof(dev_path), true, true);
19 if (ret != 0) {
20 LOG(WARNING) << "error " << ret << " determining root device";
21 return "";
22 }
23 if (strcmp(dev_path, "/dev/sda") == 0) {
petkov 2011/02/18 04:52:00 this is probably ok as is... just a suggestion tho
24 return "/sys/class/block/sda/stat";
25 } else if (strcmp(dev_path, "/dev/mmcblk0") == 0) {
26 return "/sys/class/block/mmcblk0/stat";
27 } else {
28 LOG(WARNING) << "unknown root device " << dev_path;
29 return "";
30 }
31 }
14 32
15 int main(int argc, char** argv) { 33 int main(int argc, char** argv) {
16 google::ParseCommandLineFlags(&argc, &argv, true); 34 google::ParseCommandLineFlags(&argc, &argv, true);
17 MetricsLibrary metrics_lib; 35 MetricsLibrary metrics_lib;
18 metrics_lib.Init(); 36 metrics_lib.Init();
19 MetricsDaemon daemon; 37 MetricsDaemon daemon;
20 daemon.Init(false, &metrics_lib, kMetricsMainDiskStatsPath); 38 daemon.Init(false, &metrics_lib, MetricsMainDiskStatsPath());
21 daemon.Run(FLAGS_daemon); 39 daemon.Run(FLAGS_daemon);
22 } 40 }
OLDNEW
« metrics_daemon.cc ('K') | « metrics_daemon.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698