Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 1 | // 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 | |
| 5 | #ifndef METRICS_DAEMON_H_ |
| 6 | #define METRICS_DAEMON_H_ |
| 7 | |
Darin Petkov | 703ec97 | 2010-04-27 11:02:18 -0700 | [diff] [blame] | 8 | #include <dbus/dbus.h> |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 9 | #include <glib.h> |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 10 | #include <map> |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 11 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 12 | #include <base/file_path.h> |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 13 | #include <base/scoped_ptr.h> |
| 14 | #include <base/time.h> |
| 15 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 16 | |
Darin Petkov | fc91b42 | 2010-05-12 13:05:45 -0700 | [diff] [blame] | 17 | #include "metrics_library.h" |
| 18 | |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 19 | namespace chromeos_metrics { |
| 20 | class FrequencyCounter; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 21 | class TaggedCounter; |
| 22 | class TaggedCounterReporter; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 23 | } |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 24 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 25 | class MetricsDaemon { |
| 26 | |
| 27 | public: |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 28 | MetricsDaemon(); |
| 29 | ~MetricsDaemon(); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 30 | |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 31 | // Initializes. |
Luigi Semenzato | c88e42d | 2011-02-17 10:21:16 -0800 | [diff] [blame^] | 32 | void Init(bool testing, MetricsLibraryInterface* metrics_lib, |
| 33 | const char* diskstats_path); |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 34 | |
Darin Petkov | 703ec97 | 2010-04-27 11:02:18 -0700 | [diff] [blame] | 35 | // Does all the work. If |run_as_daemon| is true, daemonizes by |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 36 | // forking. |
| 37 | void Run(bool run_as_daemon); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 38 | |
| 39 | private: |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 40 | friend class MetricsDaemonTest; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 41 | FRIEND_TEST(MetricsDaemonTest, CheckSystemCrash); |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 42 | FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoCurrent); |
| 43 | FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoLast); |
| 44 | FRIEND_TEST(MetricsDaemonTest, GetHistogramPath); |
| 45 | FRIEND_TEST(MetricsDaemonTest, IsNewEpoch); |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 46 | FRIEND_TEST(MetricsDaemonTest, LookupPowerState); |
| 47 | FRIEND_TEST(MetricsDaemonTest, LookupScreenSaverState); |
| 48 | FRIEND_TEST(MetricsDaemonTest, LookupSessionState); |
Darin Petkov | e579d66 | 2010-05-05 16:19:39 -0700 | [diff] [blame] | 49 | FRIEND_TEST(MetricsDaemonTest, MessageFilter); |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 50 | FRIEND_TEST(MetricsDaemonTest, PowerStateChanged); |
Darin Petkov | 38d5cb0 | 2010-06-24 12:10:26 -0700 | [diff] [blame] | 51 | FRIEND_TEST(MetricsDaemonTest, ProcessKernelCrash); |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 52 | FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown); |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 53 | FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash); |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 54 | FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency); |
| 55 | FRIEND_TEST(MetricsDaemonTest, ReportDailyUse); |
Luigi Semenzato | c88e42d | 2011-02-17 10:21:16 -0800 | [diff] [blame^] | 56 | FRIEND_TEST(MetricsDaemonTest, ReportDiskStats); |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 57 | FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval); |
| 58 | FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval); |
| 59 | FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval); |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 60 | FRIEND_TEST(MetricsDaemonTest, ScreenSaverStateChanged); |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 61 | FRIEND_TEST(MetricsDaemonTest, SendMetric); |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 62 | FRIEND_TEST(MetricsDaemonTest, SessionStateChanged); |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 63 | FRIEND_TEST(MetricsDaemonTest, SetUserActiveState); |
Darin Petkov | f27f036 | 2010-06-04 13:14:19 -0700 | [diff] [blame] | 64 | FRIEND_TEST(MetricsDaemonTest, SetUserActiveStateTimeJump); |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 65 | |
Darin Petkov | 703ec97 | 2010-04-27 11:02:18 -0700 | [diff] [blame] | 66 | // The power states (see power_states.h). |
| 67 | enum PowerState { |
| 68 | kUnknownPowerState = -1, // Initial/unknown power state. |
| 69 | #define STATE(name, capname) kPowerState ## capname, |
| 70 | #include "power_states.h" |
| 71 | kNumberPowerStates |
| 72 | }; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 73 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 74 | // The user session states (see session_states.h). |
| 75 | enum SessionState { |
| 76 | kUnknownSessionState = -1, // Initial/unknown user session state. |
| 77 | #define STATE(name, capname) kSessionState ## capname, |
| 78 | #include "session_states.h" |
| 79 | kNumberSessionStates |
| 80 | }; |
| 81 | |
Luigi Semenzato | c88e42d | 2011-02-17 10:21:16 -0800 | [diff] [blame^] | 82 | // State for disk stats collector callback. |
| 83 | enum DiskStatsState { |
| 84 | kDiskStatsShort, // short wait before short interval collection |
| 85 | kDiskStatsLong, // final wait before new collection |
| 86 | }; |
| 87 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 88 | // Data record for aggregating daily usage. |
| 89 | class UseRecord { |
| 90 | public: |
| 91 | UseRecord() : day_(0), seconds_(0) {} |
| 92 | int day_; |
| 93 | int seconds_; |
| 94 | }; |
| 95 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 96 | typedef std::map<std::string, chromeos_metrics::FrequencyCounter*> |
| 97 | FrequencyCounters; |
| 98 | |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 99 | // Metric parameters. |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 100 | static const char kMetricAnyCrashesDailyName[]; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 101 | static const char kMetricAnyCrashesWeeklyName[]; |
| 102 | static const char kMetricCrashFrequencyBuckets; |
| 103 | static const char kMetricCrashFrequencyMax; |
| 104 | static const char kMetricCrashFrequencyMin; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 105 | static const int kMetricCrashIntervalBuckets; |
| 106 | static const int kMetricCrashIntervalMax; |
| 107 | static const int kMetricCrashIntervalMin; |
| 108 | static const int kMetricDailyUseTimeBuckets; |
| 109 | static const int kMetricDailyUseTimeMax; |
| 110 | static const int kMetricDailyUseTimeMin; |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 111 | static const char kMetricDailyUseTimeName[]; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 112 | static const char kMetricKernelCrashesDailyName[]; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 113 | static const char kMetricKernelCrashesWeeklyName[]; |
Darin Petkov | 38d5cb0 | 2010-06-24 12:10:26 -0700 | [diff] [blame] | 114 | static const char kMetricKernelCrashIntervalName[]; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 115 | static const char kMetricsPath[]; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 116 | static const char kMetricUncleanShutdownIntervalName[]; |
| 117 | static const char kMetricUncleanShutdownsDailyName[]; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 118 | static const char kMetricUncleanShutdownsWeeklyName[]; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 119 | static const char kMetricUserCrashesDailyName[]; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 120 | static const char kMetricUserCrashesWeeklyName[]; |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 121 | static const char kMetricUserCrashIntervalName[]; |
Luigi Semenzato | c88e42d | 2011-02-17 10:21:16 -0800 | [diff] [blame^] | 122 | static const char kMetricReadSectorsLongName[]; |
| 123 | static const char kMetricReadSectorsShortName[]; |
| 124 | static const char kMetricWriteSectorsLongName[]; |
| 125 | static const char kMetricWriteSectorsShortName[]; |
| 126 | static const int kMetricDiskStatsShortInterval; |
| 127 | static const int kMetricDiskStatsLongInterval; |
| 128 | static const int kMetricSectorsIOMax; |
| 129 | static const int kMetricSectorsBuckets; |
| 130 | static const char kMetricsDiskStatsPath[]; |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 131 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 132 | // D-Bus message match strings. |
| 133 | static const char* kDBusMatches_[]; |
| 134 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 135 | // Array of power states. |
| 136 | static const char* kPowerStates_[kNumberPowerStates]; |
| 137 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 138 | // Array of user session states. |
| 139 | static const char* kSessionStates_[kNumberSessionStates]; |
| 140 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 141 | // Clears and deletes the data contained in frequency_counters_. |
| 142 | void DeleteFrequencyCounters(); |
| 143 | |
| 144 | // Configures the given crash interval reporter. |
| 145 | void ConfigureCrashIntervalReporter( |
| 146 | const char* histogram_name, |
| 147 | scoped_ptr<chromeos_metrics::TaggedCounterReporter>* reporter); |
| 148 | |
| 149 | // Configures the given frequency counter reporter. |
| 150 | void ConfigureCrashFrequencyReporter(const char* histogram_name); |
| 151 | |
| 152 | // Returns file path to persistent file for generating given histogram. |
| 153 | FilePath GetHistogramPath(const char* histogram_name); |
| 154 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 155 | // Creates the event loop and enters it. |
| 156 | void Loop(); |
| 157 | |
Darin Petkov | 703ec97 | 2010-04-27 11:02:18 -0700 | [diff] [blame] | 158 | // D-Bus filter callback. |
| 159 | static DBusHandlerResult MessageFilter(DBusConnection* connection, |
| 160 | DBusMessage* message, |
| 161 | void* user_data); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 162 | |
Darin Petkov | 703ec97 | 2010-04-27 11:02:18 -0700 | [diff] [blame] | 163 | // Processes power state change. |
Darin Petkov | f27f036 | 2010-06-04 13:14:19 -0700 | [diff] [blame] | 164 | void PowerStateChanged(const char* state_name, base::Time now); |
Darin Petkov | 703ec97 | 2010-04-27 11:02:18 -0700 | [diff] [blame] | 165 | |
| 166 | // Given the state name, returns the state id. |
| 167 | PowerState LookupPowerState(const char* state_name); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 168 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 169 | // Processes user session state change. |
Darin Petkov | f27f036 | 2010-06-04 13:14:19 -0700 | [diff] [blame] | 170 | void SessionStateChanged(const char* state_name, base::Time now); |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 171 | |
| 172 | // Given the state name, returns the state id. |
| 173 | SessionState LookupSessionState(const char* state_name); |
| 174 | |
| 175 | // Updates the user-active state to |active| and logs the usage data |
| 176 | // since the last update. If the user has just become active, |
| 177 | // reschedule the daily use monitor for more frequent updates -- |
| 178 | // this is followed by an exponential back-off (see UseMonitor). |
Darin Petkov | f27f036 | 2010-06-04 13:14:19 -0700 | [diff] [blame] | 179 | // While in active use, this method should be called at intervals no |
| 180 | // longer than kUseMonitorIntervalMax otherwise new use time will be |
| 181 | // discarded. |
| 182 | void SetUserActiveState(bool active, base::Time now); |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 183 | |
| 184 | // Updates the daily usage file, if necessary, by adding |seconds| |
| 185 | // of active use to the |day| since Epoch. If there's usage data for |
| 186 | // day in the past in the usage file, that data is sent to UMA and |
| 187 | // removed from the file. If there's already usage data for |day| in |
| 188 | // the usage file, the |seconds| are accumulated. |
| 189 | void LogDailyUseRecord(int day, int seconds); |
| 190 | |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 191 | // Updates the active use time and logs time between user-space |
| 192 | // process crashes. |
| 193 | void ProcessUserCrash(); |
| 194 | |
Darin Petkov | 38d5cb0 | 2010-06-24 12:10:26 -0700 | [diff] [blame] | 195 | // Updates the active use time and logs time between kernel crashes. |
| 196 | void ProcessKernelCrash(); |
| 197 | |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 198 | // Updates the active use time and logs time between unclean shutdowns. |
| 199 | void ProcessUncleanShutdown(); |
| 200 | |
| 201 | // Checks if a kernel crash has been detected and returns true if |
| 202 | // so. The method assumes that a kernel crash has happened if |
| 203 | // |crash_file| exists. It removes the file immediately if it |
| 204 | // exists, so it must not be called more than once. |
| 205 | bool CheckSystemCrash(const std::string& crash_file); |
Darin Petkov | 38d5cb0 | 2010-06-24 12:10:26 -0700 | [diff] [blame] | 206 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 207 | // Callbacks for the daily use monitor. The daily use monitor uses |
| 208 | // LogDailyUseRecord to aggregate current usage data and send it to |
| 209 | // UMA, if necessary. It also reschedules itself using an |
| 210 | // exponentially bigger interval (up to a certain maximum) -- so |
| 211 | // usage is monitored less frequently with longer active use. |
| 212 | static gboolean UseMonitorStatic(gpointer data); |
| 213 | bool UseMonitor(); |
| 214 | |
| 215 | // Schedules or reschedules a daily use monitor for |interval| |
| 216 | // seconds from now. |backoff| mode is used by the use monitor to |
| 217 | // reschedule itself. If there's a monitor scheduled already and |
| 218 | // |backoff| is false, unschedules it first. Doesn't schedule a |
| 219 | // monitor for more than kUseMonitorIntervalMax seconds in the |
| 220 | // future (see metrics_daemon.cc). Returns true if a new use monitor |
| 221 | // was scheduled, false otherwise (note that if |backoff| is false a |
| 222 | // new use monitor will always be scheduled). |
| 223 | bool ScheduleUseMonitor(int interval, bool backoff); |
| 224 | |
| 225 | // Unschedules a scheduled use monitor, if any. |
| 226 | void UnscheduleUseMonitor(); |
| 227 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 228 | // Report daily use through UMA. |
| 229 | static void ReportDailyUse(void* handle, int tag, int count); |
| 230 | |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 231 | // Sends a regular (exponential) histogram sample to Chrome for |
| 232 | // transport to UMA. See MetricsLibrary::SendToUMA in |
| 233 | // metrics_library.h for a description of the arguments. |
| 234 | void SendMetric(const std::string& name, int sample, |
| 235 | int min, int max, int nbuckets); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 236 | |
Luigi Semenzato | c88e42d | 2011-02-17 10:21:16 -0800 | [diff] [blame^] | 237 | // Initializes disk stats reporting. |
| 238 | void DiskStatsReporterInit(); |
| 239 | |
| 240 | // Schedules a callback for the next disk stats collection. |
| 241 | void ScheduleDiskStatsCallback(int wait); |
| 242 | |
| 243 | // Reads cumulative disk statistics from sysfs. |
| 244 | void DiskStatsReadStats(long int* read_sectors, long int* write_sectors); |
| 245 | |
| 246 | // Reports disk statistics (static version for glib). Arguments are a glib |
| 247 | // artifact. |
| 248 | static gboolean DiskStatsCallbackStatic(void* handle); |
| 249 | |
| 250 | // Reports disk statistics. |
| 251 | void DiskStatsCallback(); |
| 252 | |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 253 | // Test mode. |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 254 | bool testing_; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 255 | |
Darin Petkov | fc91b42 | 2010-05-12 13:05:45 -0700 | [diff] [blame] | 256 | // The metrics library handle. |
| 257 | MetricsLibraryInterface* metrics_lib_; |
| 258 | |
Darin Petkov | f27f036 | 2010-06-04 13:14:19 -0700 | [diff] [blame] | 259 | // Timestamps last network state update. This timestamp is used to |
| 260 | // sample the time from the network going online to going offline so |
| 261 | // TimeTicks ensures a monotonically increasing TimeDelta. |
| 262 | base::TimeTicks network_state_last_; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 263 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 264 | // Current power state. |
| 265 | PowerState power_state_; |
| 266 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 267 | // Current user session state. |
| 268 | SessionState session_state_; |
| 269 | |
| 270 | // Is the user currently active: power is on, user session has |
| 271 | // started, screen is not locked. |
| 272 | bool user_active_; |
| 273 | |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 274 | // Timestamps last user active update. Active use time is aggregated |
| 275 | // each day before sending to UMA so using time since the epoch as |
| 276 | // the timestamp. |
Darin Petkov | f27f036 | 2010-06-04 13:14:19 -0700 | [diff] [blame] | 277 | base::Time user_active_last_; |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 278 | |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 279 | // Daily active use time in seconds. |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 280 | scoped_ptr<chromeos_metrics::TaggedCounter> daily_use_; |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 281 | |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 282 | // Active use time between user-space process crashes. |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 283 | scoped_ptr<chromeos_metrics::TaggedCounterReporter> user_crash_interval_; |
Darin Petkov | 1bb904e | 2010-06-16 15:58:06 -0700 | [diff] [blame] | 284 | |
Darin Petkov | 38d5cb0 | 2010-06-24 12:10:26 -0700 | [diff] [blame] | 285 | // Active use time between kernel crashes. |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 286 | scoped_ptr<chromeos_metrics::TaggedCounterReporter> kernel_crash_interval_; |
Darin Petkov | 38d5cb0 | 2010-06-24 12:10:26 -0700 | [diff] [blame] | 287 | |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 288 | // Active use time between unclean shutdowns crashes. |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 289 | scoped_ptr<chromeos_metrics::TaggedCounterReporter> |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 290 | unclean_shutdown_interval_; |
| 291 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 292 | // Map of all frequency counters, to simplify flushing them. |
| 293 | FrequencyCounters frequency_counters_; |
Ken Mixter | ccd84c0 | 2010-08-16 19:57:13 -0700 | [diff] [blame] | 294 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 295 | // Sleep period until the next daily usage aggregation performed by |
| 296 | // the daily use monitor (see ScheduleUseMonitor). |
| 297 | int usemon_interval_; |
| 298 | |
| 299 | // Scheduled daily use monitor source (see ScheduleUseMonitor). |
| 300 | GSource* usemon_source_; |
Luigi Semenzato | c88e42d | 2011-02-17 10:21:16 -0800 | [diff] [blame^] | 301 | |
| 302 | // Contains the most recent disk stats. |
| 303 | long int read_sectors_; |
| 304 | long int write_sectors_; |
| 305 | |
| 306 | DiskStatsState diskstats_state_; |
| 307 | const char* diskstats_path_; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | #endif // METRICS_DAEMON_H_ |