OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 // Dumps CPU and IO stats to a file at a regular interval. | 5 // Dumps CPU and IO stats to a file at a regular interval. |
6 // | 6 // |
7 // Output may be post processed by host to get top/iotop style information. | 7 // Output may be post processed by host to get top/iotop style information. |
8 | 8 |
9 #include <signal.h> | 9 #include <signal.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 | 11 |
12 #include <fstream> | 12 #include <fstream> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/string_split.h" | 18 #include "base/strings/string_split.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const char kIOStatsPath[] = "/proc/diskstats"; | 22 const char kIOStatsPath[] = "/proc/diskstats"; |
23 const char kCPUStatsPath[] = "/proc/stat"; | 23 const char kCPUStatsPath[] = "/proc/stat"; |
24 | 24 |
25 class DeviceStatsMonitor { | 25 class DeviceStatsMonitor { |
26 public: | 26 public: |
27 explicit DeviceStatsMonitor(const std::string& out_path) | 27 explicit DeviceStatsMonitor(const std::string& out_path) |
28 : out_path_(out_path), | 28 : out_path_(out_path), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 kDefaultHz; | 99 kDefaultHz; |
100 | 100 |
101 printf("Starting device stats monitor\n"); | 101 printf("Starting device stats monitor\n"); |
102 g_device_stats_monitor = new DeviceStatsMonitor(args[0]); | 102 g_device_stats_monitor = new DeviceStatsMonitor(args[0]); |
103 signal(SIGTERM, SigTermHandler); | 103 signal(SIGTERM, SigTermHandler); |
104 g_device_stats_monitor->Start(hz); | 104 g_device_stats_monitor->Start(hz); |
105 delete g_device_stats_monitor; | 105 delete g_device_stats_monitor; |
106 | 106 |
107 return 0; | 107 return 0; |
108 } | 108 } |
OLD | NEW |