blob: 04c40e566723970ac6447d15d3d5f142aec7d531 [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
Ben Chanf05ab402014-08-07 00:54:59 -07008#include <stdint.h>
9
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>
Steve Funge86591e2014-12-01 13:38:21 -080017#include <chromeos/daemons/dbus_daemon.h>
Darin Petkovf1e85e42010-06-10 15:59:53 -070018#include <gtest/gtest_prod.h> // for FRIEND_TEST
19
Luigi Semenzato4a6c9422014-06-30 18:12:28 -070020#include "metrics/metrics_library.h"
Bertrand SIMONNET4b915ae2015-07-28 15:38:14 -070021#include "persistent_integer.h"
Bertrand SIMONNET46b49da2014-06-25 14:38:07 -070022#include "uploader/upload_service.h"
Darin Petkovfc91b422010-05-12 13:05:45 -070023
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -080024using chromeos_metrics::PersistentInteger;
Darin Petkov2ccef012010-05-05 16:06:37 -070025
Steve Funge86591e2014-12-01 13:38:21 -080026class MetricsDaemon : public chromeos::DBusDaemon {
Darin Petkov65b01462010-04-14 13:32:20 -070027 public:
Darin Petkovf1e85e42010-06-10 15:59:53 -070028 MetricsDaemon();
29 ~MetricsDaemon();
Darin Petkov65b01462010-04-14 13:32:20 -070030
Steve Funge86591e2014-12-01 13:38:21 -080031 // Initializes metrics class variables.
Bertrand SIMONNET46b49da2014-06-25 14:38:07 -070032 void Init(bool testing,
33 bool uploader_active,
34 MetricsLibraryInterface* metrics_lib,
Luigi Semenzato5bd764f2011-10-14 12:03:35 -070035 const std::string& diskstats_path,
Luigi Semenzatofb3a8212013-05-07 16:55:00 -070036 const std::string& vmstats_path,
37 const std::string& cpuinfo_max_freq_path,
Steve Fung67906c62014-10-06 15:15:30 -070038 const std::string& scaling_max_freq_path,
Bertrand SIMONNETcac74e12014-10-09 10:14:13 -070039 const base::TimeDelta& upload_interval,
Steve Fung67906c62014-10-06 15:15:30 -070040 const std::string& server,
Bertrand SIMONNET71a62ef2014-10-07 11:26:25 -070041 const std::string& metrics_file,
42 const std::string& config_root);
Darin Petkov11b8eb32010-05-18 11:00:59 -070043
Steve Funge86591e2014-12-01 13:38:21 -080044 // Initializes DBus and MessageLoop variables before running the MessageLoop.
45 int OnInit() override;
46
47 // Clean up data set up in OnInit before shutting down message loop.
48 void OnShutdown(int* return_code) override;
49
50 // Does all the work.
51 int Run() override;
Darin Petkov65b01462010-04-14 13:32:20 -070052
Bertrand SIMONNET46b49da2014-06-25 14:38:07 -070053 // Triggers an upload event and exit. (Used to test UploadService)
54 void RunUploaderTest();
55
Luigi Semenzato96360192014-06-04 10:53:35 -070056 protected:
57 // Used also by the unit tests.
58 static const char kComprDataSizeName[];
59 static const char kOrigDataSizeName[];
60 static const char kZeroPagesName[];
61
Darin Petkov65b01462010-04-14 13:32:20 -070062 private:
Darin Petkov2ccef012010-05-05 16:06:37 -070063 friend class MetricsDaemonTest;
Ken Mixterccd84c02010-08-16 19:57:13 -070064 FRIEND_TEST(MetricsDaemonTest, CheckSystemCrash);
Ken Mixter4c5daa42010-08-26 18:35:06 -070065 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoCurrent);
66 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoLast);
67 FRIEND_TEST(MetricsDaemonTest, GetHistogramPath);
68 FRIEND_TEST(MetricsDaemonTest, IsNewEpoch);
Darin Petkove579d662010-05-05 16:19:39 -070069 FRIEND_TEST(MetricsDaemonTest, MessageFilter);
Luigi Semenzato5bd764f2011-10-14 12:03:35 -070070 FRIEND_TEST(MetricsDaemonTest, ParseVmStats);
Darin Petkov38d5cb02010-06-24 12:10:26 -070071 FRIEND_TEST(MetricsDaemonTest, ProcessKernelCrash);
Luigi Semenzato29c7ef92011-04-12 14:12:35 -070072 FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo);
73 FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo2);
Ken Mixterccd84c02010-08-16 19:57:13 -070074 FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown);
Darin Petkov1bb904e2010-06-16 15:58:06 -070075 FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash);
Ken Mixterccd84c02010-08-16 19:57:13 -070076 FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency);
Luigi Semenzatofb3a8212013-05-07 16:55:00 -070077 FRIEND_TEST(MetricsDaemonTest, ReadFreqToInt);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080078 FRIEND_TEST(MetricsDaemonTest, ReportDiskStats);
Ken Mixterccd84c02010-08-16 19:57:13 -070079 FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval);
80 FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval);
81 FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval);
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -080082 FRIEND_TEST(MetricsDaemonTest, SendSample);
Luigi Semenzatofb3a8212013-05-07 16:55:00 -070083 FRIEND_TEST(MetricsDaemonTest, SendCpuThrottleMetrics);
Luigi Semenzato96360192014-06-04 10:53:35 -070084 FRIEND_TEST(MetricsDaemonTest, SendZramMetrics);
Darin Petkov41e06232010-05-03 16:45:37 -070085
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080086 // State for disk stats collector callback.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -070087 enum StatsState {
88 kStatsShort, // short wait before short interval collection
89 kStatsLong, // final wait before new collection
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -080090 };
91
Darin Petkov41e06232010-05-03 16:45:37 -070092 // Data record for aggregating daily usage.
93 class UseRecord {
94 public:
95 UseRecord() : day_(0), seconds_(0) {}
96 int day_;
97 int seconds_;
98 };
99
Luigi Semenzato3ccca062013-02-04 19:50:45 -0800100 // Type of scale to use for meminfo histograms. For most of them we use
101 // percent of total RAM, but for some we use absolute numbers, usually in
102 // megabytes, on a log scale from 0 to 4000, and 0 to 8000 for compressed
103 // swap (since it can be larger than total RAM).
Luigi Semenzato942cbab2013-02-12 13:17:07 -0800104 enum MeminfoOp {
105 kMeminfoOp_HistPercent = 0,
106 kMeminfoOp_HistLog,
107 kMeminfoOp_SwapTotal,
108 kMeminfoOp_SwapFree,
Luigi Semenzato3ccca062013-02-04 19:50:45 -0800109 };
110
Luigi Semenzato8accd332011-05-17 16:37:18 -0700111 // Record for retrieving and reporting values from /proc/meminfo.
112 struct MeminfoRecord {
Luigi Semenzato3ccca062013-02-04 19:50:45 -0800113 const char* name; // print name
114 const char* match; // string to match in output of /proc/meminfo
Luigi Semenzato942cbab2013-02-12 13:17:07 -0800115 MeminfoOp op; // histogram scale selector, or other operator
Luigi Semenzato3ccca062013-02-04 19:50:45 -0800116 int value; // value from /proc/meminfo
Luigi Semenzato8accd332011-05-17 16:37:18 -0700117 };
118
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700119 // Record for retrieving and reporting values from /proc/vmstat
120 struct VmstatRecord {
121 uint64_t page_faults_; // major faults
122 uint64_t swap_in_; // pages swapped in
123 uint64_t swap_out_; // pages swapped out
124 };
125
Darin Petkov2ccef012010-05-05 16:06:37 -0700126 // Metric parameters.
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800127 static const char kMetricReadSectorsLongName[];
128 static const char kMetricReadSectorsShortName[];
129 static const char kMetricWriteSectorsLongName[];
130 static const char kMetricWriteSectorsShortName[];
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700131 static const char kMetricPageFaultsShortName[];
132 static const char kMetricPageFaultsLongName[];
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700133 static const char kMetricSwapInLongName[];
134 static const char kMetricSwapInShortName[];
135 static const char kMetricSwapOutLongName[];
136 static const char kMetricSwapOutShortName[];
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700137 static const char kMetricScaledCpuFrequencyName[];
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700138 static const int kMetricStatsShortInterval;
139 static const int kMetricStatsLongInterval;
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700140 static const int kMetricMeminfoInterval;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800141 static const int kMetricSectorsIOMax;
142 static const int kMetricSectorsBuckets;
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700143 static const int kMetricPageFaultsMax;
144 static const int kMetricPageFaultsBuckets;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800145 static const char kMetricsDiskStatsPath[];
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700146 static const char kMetricsVmStatsPath[];
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700147 static const char kMetricsProcStatFileName[];
148 static const int kMetricsProcStatFirstLineItemsCount;
Darin Petkov2ccef012010-05-05 16:06:37 -0700149
Luigi Semenzato8accd332011-05-17 16:37:18 -0700150 // Returns the active time since boot (uptime minus sleep time) in seconds.
151 double GetActiveTime();
152
Darin Petkov703ec972010-04-27 11:02:18 -0700153 // D-Bus filter callback.
154 static DBusHandlerResult MessageFilter(DBusConnection* connection,
155 DBusMessage* message,
156 void* user_data);
Darin Petkov65b01462010-04-14 13:32:20 -0700157
Darin Petkov41e06232010-05-03 16:45:37 -0700158 // Updates the daily usage file, if necessary, by adding |seconds|
159 // of active use to the |day| since Epoch. If there's usage data for
160 // day in the past in the usage file, that data is sent to UMA and
161 // removed from the file. If there's already usage data for |day| in
162 // the usage file, the |seconds| are accumulated.
163 void LogDailyUseRecord(int day, int seconds);
164
Darin Petkov1bb904e2010-06-16 15:58:06 -0700165 // Updates the active use time and logs time between user-space
166 // process crashes.
167 void ProcessUserCrash();
168
Darin Petkov38d5cb02010-06-24 12:10:26 -0700169 // Updates the active use time and logs time between kernel crashes.
170 void ProcessKernelCrash();
171
Ken Mixterccd84c02010-08-16 19:57:13 -0700172 // Updates the active use time and logs time between unclean shutdowns.
173 void ProcessUncleanShutdown();
174
175 // Checks if a kernel crash has been detected and returns true if
176 // so. The method assumes that a kernel crash has happened if
177 // |crash_file| exists. It removes the file immediately if it
178 // exists, so it must not be called more than once.
179 bool CheckSystemCrash(const std::string& crash_file);
Darin Petkov38d5cb02010-06-24 12:10:26 -0700180
Darin Petkov11b8eb32010-05-18 11:00:59 -0700181 // Sends a regular (exponential) histogram sample to Chrome for
182 // transport to UMA. See MetricsLibrary::SendToUMA in
183 // metrics_library.h for a description of the arguments.
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800184 void SendSample(const std::string& name, int sample,
Darin Petkov11b8eb32010-05-18 11:00:59 -0700185 int min, int max, int nbuckets);
Darin Petkov65b01462010-04-14 13:32:20 -0700186
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700187 // Sends a linear histogram sample to Chrome for transport to UMA. See
188 // MetricsLibrary::SendToUMA in metrics_library.h for a description of the
189 // arguments.
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800190 void SendLinearSample(const std::string& name, int sample,
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700191 int max, int nbuckets);
192
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700193 // Sends various cumulative kernel crash-related stats, for instance the
194 // total number of kernel crashes since the last version update.
Luigi Semenzatoe5883fa2014-04-18 17:00:35 -0700195 void SendKernelCrashesCumulativeCountStats();
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700196
197 // Returns the total (system-wide) CPU usage between the time of the most
198 // recent call to this function and now.
199 base::TimeDelta GetIncrementalCpuUse();
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800200
Luigi Semenzatoe5883fa2014-04-18 17:00:35 -0700201 // Sends a sample representing the number of seconds of active use
202 // for a 24-hour period.
203 void SendDailyUseSample(const scoped_ptr<PersistentInteger>& use);
204
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800205 // Sends a sample representing a time interval between two crashes of the
206 // same type.
207 void SendCrashIntervalSample(const scoped_ptr<PersistentInteger>& interval);
208
209 // Sends a sample representing a frequency of crashes of some type.
210 void SendCrashFrequencySample(const scoped_ptr<PersistentInteger>& frequency);
211
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700212 // Initializes vm and disk stats reporting.
213 void StatsReporterInit();
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800214
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700215 // Schedules a callback for the next vm and disk stats collection.
216 void ScheduleStatsCallback(int wait);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800217
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700218 // Reads cumulative disk statistics from sysfs. Returns true for success.
Ben Chanf05ab402014-08-07 00:54:59 -0700219 bool DiskStatsReadStats(uint64_t* read_sectors, uint64_t* write_sectors);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800220
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700221 // Reads cumulative vm statistics from procfs. Returns true for success.
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700222 bool VmStatsReadStats(struct VmstatRecord* stats);
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800223
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700224 // Parse cumulative vm statistics from a C string. Returns true for success.
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700225 bool VmStatsParseStats(const char* stats, struct VmstatRecord* record);
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700226
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700227 // Reports disk and vm statistics.
228 void StatsCallback();
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800229
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700230 // Schedules meminfo collection callback.
231 void ScheduleMeminfoCallback(int wait);
232
Steve Funge86591e2014-12-01 13:38:21 -0800233 // Reports memory statistics. Reschedules callback on success.
234 void MeminfoCallback(base::TimeDelta wait);
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700235
236 // Parses content of /proc/meminfo and sends fields of interest to UMA.
Luigi Semenzato8accd332011-05-17 16:37:18 -0700237 // Returns false on errors. |meminfo_raw| contains the content of
238 // /proc/meminfo.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700239 bool ProcessMeminfo(const std::string& meminfo_raw);
Luigi Semenzato8accd332011-05-17 16:37:18 -0700240
241 // Parses meminfo data from |meminfo_raw|. |fields| is a vector containing
242 // the fields of interest. The order of the fields must be the same in which
243 // /proc/meminfo prints them. The result of parsing fields[i] is placed in
244 // fields[i].value.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700245 bool FillMeminfo(const std::string& meminfo_raw,
246 std::vector<MeminfoRecord>* fields);
Luigi Semenzato8accd332011-05-17 16:37:18 -0700247
Luigi Semenzato0d9a9c92013-12-05 15:55:12 -0800248 // Schedule a memory use callback in |interval| seconds.
249 void ScheduleMemuseCallback(double interval);
Luigi Semenzato8accd332011-05-17 16:37:18 -0700250
Luigi Semenzato8accd332011-05-17 16:37:18 -0700251 // Calls MemuseCallbackWork, and possibly schedules next callback, if enough
252 // active time has passed. Otherwise reschedules itself to simulate active
253 // time callbacks (i.e. wall clock time minus sleep time).
254 void MemuseCallback();
255
256 // Reads /proc/meminfo and sends total anonymous memory usage to UMA.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700257 bool MemuseCallbackWork();
Luigi Semenzato8accd332011-05-17 16:37:18 -0700258
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700259 // Parses meminfo data and sends it to UMA.
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700260 bool ProcessMemuse(const std::string& meminfo_raw);
Luigi Semenzato29c7ef92011-04-12 14:12:35 -0700261
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700262 // Sends stats for thermal CPU throttling.
263 void SendCpuThrottleMetrics();
264
265 // Reads an integer CPU frequency value from sysfs.
266 bool ReadFreqToInt(const std::string& sysfs_file_name, int* value);
267
Luigi Semenzato859b3f02014-02-05 15:33:19 -0800268 // Reads the current OS version from /etc/lsb-release and hashes it
269 // to a unsigned 32-bit int.
Ben Chanf05ab402014-08-07 00:54:59 -0700270 uint32_t GetOsVersionHash();
Luigi Semenzato859b3f02014-02-05 15:33:19 -0800271
Ben Chan067ec8b2015-02-17 13:54:04 -0800272 // Returns true if the system is using an official build.
273 bool IsOnOfficialBuild() const;
274
Daniel Eratc83975a2014-04-04 08:53:44 -0700275 // Updates stats, additionally sending them to UMA if enough time has elapsed
276 // since the last report.
277 void UpdateStats(base::TimeTicks now_ticks, base::Time now_wall_time);
278
279 // Invoked periodically by |update_stats_timeout_id_| to call UpdateStats().
Steve Funge86591e2014-12-01 13:38:21 -0800280 void HandleUpdateStatsTimeout();
Daniel Eratc83975a2014-04-04 08:53:44 -0700281
Luigi Semenzato96360192014-06-04 10:53:35 -0700282 // Reports zram statistics.
283 bool ReportZram(const base::FilePath& zram_dir);
284
Ben Chanf05ab402014-08-07 00:54:59 -0700285 // Reads a string from a file and converts it to uint64_t.
286 static bool ReadFileToUint64(const base::FilePath& path, uint64_t* value);
Luigi Semenzato96360192014-06-04 10:53:35 -0700287
288 // VARIABLES
289
Darin Petkov2ccef012010-05-05 16:06:37 -0700290 // Test mode.
Darin Petkov41e06232010-05-03 16:45:37 -0700291 bool testing_;
Darin Petkov65b01462010-04-14 13:32:20 -0700292
Steve Funge86591e2014-12-01 13:38:21 -0800293 // Whether the uploader is enabled or disabled.
294 bool uploader_active_;
295
Bertrand SIMONNET71a62ef2014-10-07 11:26:25 -0700296 // Root of the configuration files to use.
297 std::string config_root_;
298
Darin Petkovfc91b422010-05-12 13:05:45 -0700299 // The metrics library handle.
300 MetricsLibraryInterface* metrics_lib_;
301
Darin Petkovf27f0362010-06-04 13:14:19 -0700302 // Timestamps last network state update. This timestamp is used to
303 // sample the time from the network going online to going offline so
304 // TimeTicks ensures a monotonically increasing TimeDelta.
305 base::TimeTicks network_state_last_;
Darin Petkov65b01462010-04-14 13:32:20 -0700306
Daniel Eratc83975a2014-04-04 08:53:44 -0700307 // The last time that UpdateStats() was called.
308 base::TimeTicks last_update_stats_time_;
Darin Petkov41e06232010-05-03 16:45:37 -0700309
Luigi Semenzato0d9a9c92013-12-05 15:55:12 -0800310 // End time of current memuse stat collection interval.
311 double memuse_final_time_;
Luigi Semenzato8accd332011-05-17 16:37:18 -0700312
313 // Selects the wait time for the next memory use callback.
314 unsigned int memuse_interval_index_;
315
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700316 // Contain the most recent disk and vm cumulative stats.
Ben Chanf05ab402014-08-07 00:54:59 -0700317 uint64_t read_sectors_;
318 uint64_t write_sectors_;
Sonny Rao4b8aebb2013-07-31 23:18:31 -0700319 struct VmstatRecord vmstats_;
Luigi Semenzatoc88e42d2011-02-17 10:21:16 -0800320
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700321 StatsState stats_state_;
322 double stats_initial_time_;
323
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700324 // The system "HZ", or frequency of ticks. Some system data uses ticks as a
325 // unit, and this is used to convert to standard time units.
Ben Chanf05ab402014-08-07 00:54:59 -0700326 uint32_t ticks_per_second_;
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700327 // Used internally by GetIncrementalCpuUse() to return the CPU utilization
328 // between calls.
Ben Chanf05ab402014-08-07 00:54:59 -0700329 uint64_t latest_cpu_use_ticks_;
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700330
331 // Persistent values and accumulators for crash statistics.
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800332 scoped_ptr<PersistentInteger> daily_cycle_;
333 scoped_ptr<PersistentInteger> weekly_cycle_;
334 scoped_ptr<PersistentInteger> version_cycle_;
335
Luigi Semenzatoe5883fa2014-04-18 17:00:35 -0700336 // Active use accumulated in a day.
337 scoped_ptr<PersistentInteger> daily_active_use_;
338 // Active use accumulated since the latest version update.
339 scoped_ptr<PersistentInteger> version_cumulative_active_use_;
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800340
Luigi Semenzatoba0c65d2014-03-17 12:28:38 -0700341 // The CPU time accumulator. This contains the CPU time, in milliseconds,
342 // used by the system since the most recent OS version update.
343 scoped_ptr<PersistentInteger> version_cumulative_cpu_use_;
344
Luigi Semenzato2fd51cc2014-02-26 11:53:16 -0800345 scoped_ptr<PersistentInteger> user_crash_interval_;
346 scoped_ptr<PersistentInteger> kernel_crash_interval_;
347 scoped_ptr<PersistentInteger> unclean_shutdown_interval_;
348
349 scoped_ptr<PersistentInteger> any_crashes_daily_count_;
350 scoped_ptr<PersistentInteger> any_crashes_weekly_count_;
351 scoped_ptr<PersistentInteger> user_crashes_daily_count_;
352 scoped_ptr<PersistentInteger> user_crashes_weekly_count_;
353 scoped_ptr<PersistentInteger> kernel_crashes_daily_count_;
354 scoped_ptr<PersistentInteger> kernel_crashes_weekly_count_;
355 scoped_ptr<PersistentInteger> kernel_crashes_version_count_;
356 scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_;
357 scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
358
Luigi Semenzato0f132bb2011-02-28 11:17:43 -0800359 std::string diskstats_path_;
Luigi Semenzato5bd764f2011-10-14 12:03:35 -0700360 std::string vmstats_path_;
Luigi Semenzatofb3a8212013-05-07 16:55:00 -0700361 std::string scaling_max_freq_path_;
362 std::string cpuinfo_max_freq_path_;
Bertrand SIMONNET46b49da2014-06-25 14:38:07 -0700363
Bertrand SIMONNETcac74e12014-10-09 10:14:13 -0700364 base::TimeDelta upload_interval_;
Steve Fung67906c62014-10-06 15:15:30 -0700365 std::string server_;
366 std::string metrics_file_;
367
Bertrand SIMONNET46b49da2014-06-25 14:38:07 -0700368 scoped_ptr<UploadService> upload_service_;
Darin Petkov65b01462010-04-14 13:32:20 -0700369};
370
Luigi Semenzato4a6c9422014-06-30 18:12:28 -0700371#endif // METRICS_METRICS_DAEMON_H_