blob: 9c234a132b729eead1f5e94a97e0f478d5aa8d99 [file] [log] [blame]
Darin Petkov65b01462010-04-14 13:32:20 -07001// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Luigi Semenzato4a6c9422014-06-30 18:12:28 -07005#ifndef METRICS_METRICS_DAEMON_H_
6#define METRICS_METRICS_DAEMON_H_
Darin Petkov65b01462010-04-14 13:32:20 -07007
Darin Petkov703ec972010-04-27 11:02:18 -07008#include <dbus/dbus.h>
Darin Petkov41e06232010-05-03 16:45:37 -07009#include <glib.h>
Ken Mixter4c5daa42010-08-26 18:35:06 -070010#include <map>
Luigi Semenzato4a6c9422014-06-30 18:12:28 -070011#include <string>
12#include <vector>
Darin Petkov65b01462010-04-14 13:32:20 -070013
Ben Chan2e6543d2014-02-05 23:26:25 -080014#include <base/files/file_path.h>
Chris Masone817016a2011-05-12 14:14:48 -070015#include <base/memory/scoped_ptr.h>
Ben Chan2e6543d2014-02-05 23:26:25 -080016#include <base/time/time.h>
Darin Petkovf1e85e42010-06-10 15:59:53 -070017#include <gtest/gtest_prod.h> // for FRIEND_TEST
18
Luigi Semenzato4a6c9422014-06-30 18:12:28 -070019#include "metrics/metrics_library.h"
20#include "metrics/persistent_integer.h"
Darin Petkovfc91b422010-05-12 13:05:45 -070021
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -080022using chromeos_metrics::PersistentInteger;
Darin Petkov2ccef012010-05-05 16:06:37 -070023
Darin Petkov65b01462010-04-14 13:32:20 -070024class MetricsDaemon {
Darin Petkov65b01462010-04-14 13:32:20 -070025 public:
Darin Petkovf1e85e42010-06-10 15:59:53 -070026 MetricsDaemon();
27 ~MetricsDaemon();
Darin Petkov65b01462010-04-14 13:32:20 -070028
Darin Petkov11b8eb32010-05-18 11:00:59 -070029 // Initializes.
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080030 void Init(bool testing, MetricsLibraryInterface* metrics_lib,
Luigi Semenzato5bd764f2011-10-14 12:03:35 -070031 const std::string& diskstats_path,
Luigi Semenzatofb3a8212013-05-07 16:55:00 -070032 const std::string& vmstats_path,
33 const std::string& cpuinfo_max_freq_path,
34 const std::string& scaling_max_freq_path);
Darin Petkov11b8eb32010-05-18 11:00:59 -070035
Darin Petkov703ec972010-04-27 11:02:18 -070036 // Does all the work. If |run_as_daemon| is true, daemonizes by
Darin Petkov2ccef012010-05-05 16:06:37 -070037 // forking.
38 void Run(bool run_as_daemon);
Darin Petkov65b01462010-04-14 13:32:20 -070039
Luigi Semenzato96360192014-06-04 10:53:35 -070040 protected:
41 // Used also by the unit tests.
42 static const char kComprDataSizeName[];
43 static const char kOrigDataSizeName[];
44 static const char kZeroPagesName[];
45
Darin Petkov65b01462010-04-14 13:32:20 -070046 private:
Darin Petkov2ccef012010-05-05 16:06:37 -070047 friend class MetricsDaemonTest;
Ken Mixterccd84c02010-08-16 19:57:13 -070048 FRIEND_TEST(MetricsDaemonTest, CheckSystemCrash);
Ken Mixter4c5daa42010-08-26 18:35:06 -070049 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoCurrent);
50 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoLast);
51 FRIEND_TEST(MetricsDaemonTest, GetHistogramPath);
52 FRIEND_TEST(MetricsDaemonTest, IsNewEpoch);
Darin Petkove579d662010-05-05 16:19:39 -070053 FRIEND_TEST(MetricsDaemonTest, MessageFilter);
Luigi Semenzato5bd764f2011-10-14 12:03:35 -070054 FRIEND_TEST(MetricsDaemonTest, ParseVmStats);
Darin Petkov38d5cb02010-06-24 12:10:26 -070055 FRIEND_TEST(MetricsDaemonTest, ProcessKernelCrash);
Luigi Semenzato29c7ef92011-04-12 14:12:35 -070056 FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo);
57 FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo2);
Ken Mixterccd84c02010-08-16 19:57:13 -070058 FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown);
Darin Petkov1bb904e2010-06-16 15:58:06 -070059 FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash);
Ken Mixterccd84c02010-08-16 19:57:13 -070060 FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency);
Luigi Semenzatofb3a8212013-05-07 16:55:00 -070061 FRIEND_TEST(MetricsDaemonTest, ReadFreqToInt);
Ken Mixterccd84c02010-08-16 19:57:13 -070062 FRIEND_TEST(MetricsDaemonTest, ReportDailyUse);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080063 FRIEND_TEST(MetricsDaemonTest, ReportDiskStats);
Ken Mixterccd84c02010-08-16 19:57:13 -070064 FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval);
65 FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval);
66 FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval);
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -080067 FRIEND_TEST(MetricsDaemonTest, SendSample);
Luigi Semenzatofb3a8212013-05-07 16:55:00 -070068 FRIEND_TEST(MetricsDaemonTest, SendCpuThrottleMetrics);
Luigi Semenzato96360192014-06-04 10:53:35 -070069 FRIEND_TEST(MetricsDaemonTest, SendZramMetrics);
Darin Petkov41e06232010-05-03 16:45:37 -070070
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080071 // State for disk stats collector callback.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -070072 enum StatsState {
73 kStatsShort, // short wait before short interval collection
74 kStatsLong, // final wait before new collection
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080075 };
76
Darin Petkov41e06232010-05-03 16:45:37 -070077 // Data record for aggregating daily usage.
78 class UseRecord {
79 public:
80 UseRecord() : day_(0), seconds_(0) {}
81 int day_;
82 int seconds_;
83 };
84
Luigi Semenzato3ccca062013-02-04 19:50:45 -080085 // Type of scale to use for meminfo histograms. For most of them we use
86 // percent of total RAM, but for some we use absolute numbers, usually in
87 // megabytes, on a log scale from 0 to 4000, and 0 to 8000 for compressed
88 // swap (since it can be larger than total RAM).
Luigi Semenzato942cbab2013-02-12 13:17:07 -080089 enum MeminfoOp {
90 kMeminfoOp_HistPercent = 0,
91 kMeminfoOp_HistLog,
92 kMeminfoOp_SwapTotal,
93 kMeminfoOp_SwapFree,
Luigi Semenzato3ccca062013-02-04 19:50:45 -080094 };
95
Luigi Semenzato8accd332011-05-17 16:37:18 -070096 // Record for retrieving and reporting values from /proc/meminfo.
97 struct MeminfoRecord {
Luigi Semenzato3ccca062013-02-04 19:50:45 -080098 const char* name; // print name
99 const char* match; // string to match in output of /proc/meminfo
Luigi Semenzato942cbab2013-02-12 13:17:07 -0800100 MeminfoOp op; // histogram scale selector, or other operator
Luigi Semenzato3ccca062013-02-04 19:50:45 -0800101 int value; // value from /proc/meminfo
Luigi Semenzato8accd332011-05-17 16:37:18 -0700102 };
103
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700104 // Record for retrieving and reporting values from /proc/vmstat
105 struct VmstatRecord {
106 uint64_t page_faults_; // major faults
107 uint64_t swap_in_; // pages swapped in
108 uint64_t swap_out_; // pages swapped out
109 };
110
Darin Petkov2ccef012010-05-05 16:06:37 -0700111 // Metric parameters.
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800112 static const char kMetricReadSectorsLongName[];
113 static const char kMetricReadSectorsShortName[];
114 static const char kMetricWriteSectorsLongName[];
115 static const char kMetricWriteSectorsShortName[];
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700116 static const char kMetricPageFaultsShortName[];
117 static const char kMetricPageFaultsLongName[];
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700118 static const char kMetricSwapInLongName[];
119 static const char kMetricSwapInShortName[];
120 static const char kMetricSwapOutLongName[];
121 static const char kMetricSwapOutShortName[];
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700122 static const char kMetricScaledCpuFrequencyName[];
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700123 static const int kMetricStatsShortInterval;
124 static const int kMetricStatsLongInterval;
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700125 static const int kMetricMeminfoInterval;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800126 static const int kMetricSectorsIOMax;
127 static const int kMetricSectorsBuckets;
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700128 static const int kMetricPageFaultsMax;
129 static const int kMetricPageFaultsBuckets;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800130 static const char kMetricsDiskStatsPath[];
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700131 static const char kMetricsVmStatsPath[];
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700132 static const char kMetricsProcStatFileName[];
133 static const int kMetricsProcStatFirstLineItemsCount;
Darin Petkov2ccef012010-05-05 16:06:37 -0700134
Luigi Semenzato8accd332011-05-17 16:37:18 -0700135 // Returns the active time since boot (uptime minus sleep time) in seconds.
136 double GetActiveTime();
137
Darin Petkov65b01462010-04-14 13:32:20 -0700138 // Creates the event loop and enters it.
139 void Loop();
140
Darin Petkov703ec972010-04-27 11:02:18 -0700141 // D-Bus filter callback.
142 static DBusHandlerResult MessageFilter(DBusConnection* connection,
143 DBusMessage* message,
144 void* user_data);
Darin Petkov65b01462010-04-14 13:32:20 -0700145
Darin Petkov41e06232010-05-03 16:45:37 -0700146 // Updates the daily usage file, if necessary, by adding |seconds|
147 // of active use to the |day| since Epoch. If there's usage data for
148 // day in the past in the usage file, that data is sent to UMA and
149 // removed from the file. If there's already usage data for |day| in
150 // the usage file, the |seconds| are accumulated.
151 void LogDailyUseRecord(int day, int seconds);
152
Darin Petkov1bb904e2010-06-16 15:58:06 -0700153 // Updates the active use time and logs time between user-space
154 // process crashes.
155 void ProcessUserCrash();
156
Darin Petkov38d5cb02010-06-24 12:10:26 -0700157 // Updates the active use time and logs time between kernel crashes.
158 void ProcessKernelCrash();
159
Ken Mixterccd84c02010-08-16 19:57:13 -0700160 // Updates the active use time and logs time between unclean shutdowns.
161 void ProcessUncleanShutdown();
162
163 // Checks if a kernel crash has been detected and returns true if
164 // so. The method assumes that a kernel crash has happened if
165 // |crash_file| exists. It removes the file immediately if it
166 // exists, so it must not be called more than once.
167 bool CheckSystemCrash(const std::string& crash_file);
Darin Petkov38d5cb02010-06-24 12:10:26 -0700168
Ken Mixter4c5daa42010-08-26 18:35:06 -0700169 // Report daily use through UMA.
Luigi Semenzato5ef2e392014-04-15 15:15:02 -0700170 void ReportDailyUse(int use_seconds);
Ken Mixter4c5daa42010-08-26 18:35:06 -0700171
Darin Petkov11b8eb32010-05-18 11:00:59 -0700172 // Sends a regular (exponential) histogram sample to Chrome for
173 // transport to UMA. See MetricsLibrary::SendToUMA in
174 // metrics_library.h for a description of the arguments.
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800175 void SendSample(const std::string& name, int sample,
Darin Petkov11b8eb32010-05-18 11:00:59 -0700176 int min, int max, int nbuckets);
Darin Petkov65b01462010-04-14 13:32:20 -0700177
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700178 // Sends a linear histogram sample to Chrome for transport to UMA. See
179 // MetricsLibrary::SendToUMA in metrics_library.h for a description of the
180 // arguments.
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800181 void SendLinearSample(const std::string& name, int sample,
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700182 int max, int nbuckets);
183
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700184 // Sends various cumulative kernel crash-related stats, for instance the
185 // total number of kernel crashes since the last version update.
Luigi Semenzatoe5883fa2014-04-18 17:00:35 -0700186 void SendKernelCrashesCumulativeCountStats();
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700187
188 // Returns the total (system-wide) CPU usage between the time of the most
189 // recent call to this function and now.
190 base::TimeDelta GetIncrementalCpuUse();
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800191
Luigi Semenzatoe5883fa2014-04-18 17:00:35 -0700192 // Sends a sample representing the number of seconds of active use
193 // for a 24-hour period.
194 void SendDailyUseSample(const scoped_ptr<PersistentInteger>& use);
195
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800196 // Sends a sample representing a time interval between two crashes of the
197 // same type.
198 void SendCrashIntervalSample(const scoped_ptr<PersistentInteger>& interval);
199
200 // Sends a sample representing a frequency of crashes of some type.
201 void SendCrashFrequencySample(const scoped_ptr<PersistentInteger>& frequency);
202
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700203 // Initializes vm and disk stats reporting.
204 void StatsReporterInit();
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800205
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700206 // Schedules a callback for the next vm and disk stats collection.
207 void ScheduleStatsCallback(int wait);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800208
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700209 // Reads cumulative disk statistics from sysfs. Returns true for success.
Luigi Semenzato4a6c9422014-06-30 18:12:28 -0700210 bool DiskStatsReadStats(uint64* read_sectors, uint64* write_sectors);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800211
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700212 // Reads cumulative vm statistics from procfs. Returns true for success.
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700213 bool VmStatsReadStats(struct VmstatRecord* stats);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800214
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700215 // Parse cumulative vm statistics from a C string. Returns true for success.
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700216 bool VmStatsParseStats(const char* stats, struct VmstatRecord* record);
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700217
218 // Reports disk and vm statistics (static version for glib). Arguments are a
219 // glib artifact.
220 static gboolean StatsCallbackStatic(void* handle);
221
222 // Reports disk and vm statistics.
223 void StatsCallback();
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800224
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700225 // Schedules meminfo collection callback.
226 void ScheduleMeminfoCallback(int wait);
227
228 // Reports memory statistics (static version for glib). Argument is a glib
229 // artifact.
230 static gboolean MeminfoCallbackStatic(void* handle);
231
232 // Reports memory statistics. Returns false on failure.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700233 bool MeminfoCallback();
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700234
235 // Parses content of /proc/meminfo and sends fields of interest to UMA.
Luigi Semenzato8accd332011-05-17 16:37:18 -0700236 // Returns false on errors. |meminfo_raw| contains the content of
237 // /proc/meminfo.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700238 bool ProcessMeminfo(const std::string& meminfo_raw);
Luigi Semenzato8accd332011-05-17 16:37:18 -0700239
240 // Parses meminfo data from |meminfo_raw|. |fields| is a vector containing
241 // the fields of interest. The order of the fields must be the same in which
242 // /proc/meminfo prints them. The result of parsing fields[i] is placed in
243 // fields[i].value.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700244 bool FillMeminfo(const std::string& meminfo_raw,
245 std::vector<MeminfoRecord>* fields);
Luigi Semenzato8accd332011-05-17 16:37:18 -0700246
Luigi Semenzato0d9a9c92013-12-05 15:55:12 -0800247 // Schedule a memory use callback in |interval| seconds.
248 void ScheduleMemuseCallback(double interval);
Luigi Semenzato8accd332011-05-17 16:37:18 -0700249
250 // Static wrapper for MemuseCallback. Always returns false.
251 static gboolean MemuseCallbackStatic(void* handle);
252
253 // Calls MemuseCallbackWork, and possibly schedules next callback, if enough
254 // active time has passed. Otherwise reschedules itself to simulate active
255 // time callbacks (i.e. wall clock time minus sleep time).
256 void MemuseCallback();
257
258 // Reads /proc/meminfo and sends total anonymous memory usage to UMA.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700259 bool MemuseCallbackWork();
Luigi Semenzato8accd332011-05-17 16:37:18 -0700260
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700261 // Parses meminfo data and sends it to UMA.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700262 bool ProcessMemuse(const std::string& meminfo_raw);
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700263
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700264 // Sends stats for thermal CPU throttling.
265 void SendCpuThrottleMetrics();
266
267 // Reads an integer CPU frequency value from sysfs.
268 bool ReadFreqToInt(const std::string& sysfs_file_name, int* value);
269
Luigi Semenzato859b3f02014-02-05 15:33:19 -0800270 // Reads the current OS version from /etc/lsb-release and hashes it
271 // to a unsigned 32-bit int.
272 uint32 GetOsVersionHash();
273
Daniel Eratc83975a2014-04-04 08:53:44 -0700274 // Updates stats, additionally sending them to UMA if enough time has elapsed
275 // since the last report.
276 void UpdateStats(base::TimeTicks now_ticks, base::Time now_wall_time);
277
278 // Invoked periodically by |update_stats_timeout_id_| to call UpdateStats().
279 static gboolean HandleUpdateStatsTimeout(gpointer data);
280
Luigi Semenzato96360192014-06-04 10:53:35 -0700281 // Reports zram statistics.
282 bool ReportZram(const base::FilePath& zram_dir);
283
284 // Reads a string from a file and converts it to uint64.
285 static bool ReadFileToUint64(const base::FilePath& path, uint64* value);
286
287 // VARIABLES
288
Darin Petkov2ccef012010-05-05 16:06:37 -0700289 // Test mode.
Darin Petkov41e06232010-05-03 16:45:37 -0700290 bool testing_;
Darin Petkov65b01462010-04-14 13:32:20 -0700291
Darin Petkovfc91b422010-05-12 13:05:45 -0700292 // The metrics library handle.
293 MetricsLibraryInterface* metrics_lib_;
294
Darin Petkovf27f0362010-06-04 13:14:19 -0700295 // Timestamps last network state update. This timestamp is used to
296 // sample the time from the network going online to going offline so
297 // TimeTicks ensures a monotonically increasing TimeDelta.
298 base::TimeTicks network_state_last_;
Darin Petkov65b01462010-04-14 13:32:20 -0700299
Daniel Eratc83975a2014-04-04 08:53:44 -0700300 // The last time that UpdateStats() was called.
301 base::TimeTicks last_update_stats_time_;
Darin Petkov41e06232010-05-03 16:45:37 -0700302
Daniel Eratc83975a2014-04-04 08:53:44 -0700303 // ID of a GLib timeout that repeatedly runs UpdateStats().
304 gint update_stats_timeout_id_;
Darin Petkov41e06232010-05-03 16:45:37 -0700305
Darin Petkov41e06232010-05-03 16:45:37 -0700306 // Sleep period until the next daily usage aggregation performed by
307 // the daily use monitor (see ScheduleUseMonitor).
308 int usemon_interval_;
309
310 // Scheduled daily use monitor source (see ScheduleUseMonitor).
311 GSource* usemon_source_;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800312
Luigi Semenzato0d9a9c92013-12-05 15:55:12 -0800313 // End time of current memuse stat collection interval.
314 double memuse_final_time_;
Luigi Semenzato8accd332011-05-17 16:37:18 -0700315
316 // Selects the wait time for the next memory use callback.
317 unsigned int memuse_interval_index_;
318
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700319 // Contain the most recent disk and vm cumulative stats.
Luigi Semenzato4a6c9422014-06-30 18:12:28 -0700320 uint64 read_sectors_;
321 uint64 write_sectors_;
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700322 struct VmstatRecord vmstats_;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800323
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700324 StatsState stats_state_;
325 double stats_initial_time_;
326
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700327 // The system "HZ", or frequency of ticks. Some system data uses ticks as a
328 // unit, and this is used to convert to standard time units.
329 uint32 ticks_per_second_;
330 // Used internally by GetIncrementalCpuUse() to return the CPU utilization
331 // between calls.
332 uint64 latest_cpu_use_ticks_;
333
334 // Persistent values and accumulators for crash statistics.
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800335 scoped_ptr<PersistentInteger> daily_cycle_;
336 scoped_ptr<PersistentInteger> weekly_cycle_;
337 scoped_ptr<PersistentInteger> version_cycle_;
338
Luigi Semenzatoe5883fa2014-04-18 17:00:35 -0700339 // Active use accumulated in a day.
340 scoped_ptr<PersistentInteger> daily_active_use_;
341 // Active use accumulated since the latest version update.
342 scoped_ptr<PersistentInteger> version_cumulative_active_use_;
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800343
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700344 // The CPU time accumulator. This contains the CPU time, in milliseconds,
345 // used by the system since the most recent OS version update.
346 scoped_ptr<PersistentInteger> version_cumulative_cpu_use_;
347
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800348 scoped_ptr<PersistentInteger> user_crash_interval_;
349 scoped_ptr<PersistentInteger> kernel_crash_interval_;
350 scoped_ptr<PersistentInteger> unclean_shutdown_interval_;
351
352 scoped_ptr<PersistentInteger> any_crashes_daily_count_;
353 scoped_ptr<PersistentInteger> any_crashes_weekly_count_;
354 scoped_ptr<PersistentInteger> user_crashes_daily_count_;
355 scoped_ptr<PersistentInteger> user_crashes_weekly_count_;
356 scoped_ptr<PersistentInteger> kernel_crashes_daily_count_;
357 scoped_ptr<PersistentInteger> kernel_crashes_weekly_count_;
358 scoped_ptr<PersistentInteger> kernel_crashes_version_count_;
359 scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_;
360 scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
361
Luigi Semenzato0f132bb2011-02-28 11:17:43 -0800362 std::string diskstats_path_;
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700363 std::string vmstats_path_;
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700364 std::string scaling_max_freq_path_;
365 std::string cpuinfo_max_freq_path_;
Darin Petkov65b01462010-04-14 13:32:20 -0700366};
367
Luigi Semenzato4a6c9422014-06-30 18:12:28 -0700368#endif // METRICS_METRICS_DAEMON_H_