2015-08-11 06:18:00 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2014-07-01 09:12:28 +08:00
|
|
|
#ifndef METRICS_METRICS_DAEMON_H_
|
|
|
|
#define METRICS_METRICS_DAEMON_H_
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2014-08-07 15:54:59 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2010-08-27 09:35:06 +08:00
|
|
|
#include <map>
|
2014-07-01 09:12:28 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2014-02-06 15:26:25 +08:00
|
|
|
#include <base/files/file_path.h>
|
2011-05-13 05:14:48 +08:00
|
|
|
#include <base/memory/scoped_ptr.h>
|
2014-02-06 15:26:25 +08:00
|
|
|
#include <base/time/time.h>
|
2014-12-02 05:38:21 +08:00
|
|
|
#include <chromeos/daemons/dbus_daemon.h>
|
2010-06-11 06:59:53 +08:00
|
|
|
#include <gtest/gtest_prod.h> // for FRIEND_TEST
|
|
|
|
|
2014-07-01 09:12:28 +08:00
|
|
|
#include "metrics/metrics_library.h"
|
2015-07-29 06:38:14 +08:00
|
|
|
#include "persistent_integer.h"
|
2014-06-26 05:38:07 +08:00
|
|
|
#include "uploader/upload_service.h"
|
2010-05-13 04:05:45 +08:00
|
|
|
|
2014-02-27 03:53:16 +08:00
|
|
|
using chromeos_metrics::PersistentInteger;
|
2010-05-06 07:06:37 +08:00
|
|
|
|
2014-12-02 05:38:21 +08:00
|
|
|
class MetricsDaemon : public chromeos::DBusDaemon {
|
2010-04-15 04:32:20 +08:00
|
|
|
public:
|
2010-06-11 06:59:53 +08:00
|
|
|
MetricsDaemon();
|
|
|
|
~MetricsDaemon();
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2014-12-02 05:38:21 +08:00
|
|
|
// Initializes metrics class variables.
|
2014-06-26 05:38:07 +08:00
|
|
|
void Init(bool testing,
|
|
|
|
bool uploader_active,
|
2015-08-06 07:04:14 +08:00
|
|
|
bool dbus_enabled,
|
2014-06-26 05:38:07 +08:00
|
|
|
MetricsLibraryInterface* metrics_lib,
|
2013-05-08 07:55:00 +08:00
|
|
|
const std::string& vmstats_path,
|
|
|
|
const std::string& cpuinfo_max_freq_path,
|
2014-10-07 06:15:30 +08:00
|
|
|
const std::string& scaling_max_freq_path,
|
2014-10-10 01:14:13 +08:00
|
|
|
const base::TimeDelta& upload_interval,
|
2014-10-07 06:15:30 +08:00
|
|
|
const std::string& server,
|
2014-10-08 02:26:25 +08:00
|
|
|
const std::string& metrics_file,
|
|
|
|
const std::string& config_root);
|
2010-05-19 02:00:59 +08:00
|
|
|
|
2014-12-02 05:38:21 +08:00
|
|
|
// Initializes DBus and MessageLoop variables before running the MessageLoop.
|
|
|
|
int OnInit() override;
|
|
|
|
|
|
|
|
// Clean up data set up in OnInit before shutting down message loop.
|
|
|
|
void OnShutdown(int* return_code) override;
|
|
|
|
|
|
|
|
// Does all the work.
|
|
|
|
int Run() override;
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2014-06-26 05:38:07 +08:00
|
|
|
// Triggers an upload event and exit. (Used to test UploadService)
|
|
|
|
void RunUploaderTest();
|
|
|
|
|
2014-06-05 01:53:35 +08:00
|
|
|
protected:
|
|
|
|
// Used also by the unit tests.
|
|
|
|
static const char kComprDataSizeName[];
|
|
|
|
static const char kOrigDataSizeName[];
|
|
|
|
static const char kZeroPagesName[];
|
|
|
|
|
2010-04-15 04:32:20 +08:00
|
|
|
private:
|
2010-05-06 07:06:37 +08:00
|
|
|
friend class MetricsDaemonTest;
|
2010-08-17 10:57:13 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, CheckSystemCrash);
|
2010-08-27 09:35:06 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoCurrent);
|
|
|
|
FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoLast);
|
|
|
|
FRIEND_TEST(MetricsDaemonTest, GetHistogramPath);
|
|
|
|
FRIEND_TEST(MetricsDaemonTest, IsNewEpoch);
|
2010-05-06 07:19:39 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, MessageFilter);
|
2011-10-15 03:03:35 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ParseVmStats);
|
2010-06-25 03:10:26 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ProcessKernelCrash);
|
2011-04-13 05:12:35 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo);
|
|
|
|
FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo2);
|
2010-08-17 10:57:13 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown);
|
2010-06-17 06:58:06 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash);
|
2010-08-17 10:57:13 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency);
|
2013-05-08 07:55:00 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ReadFreqToInt);
|
2011-02-18 02:21:16 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ReportDiskStats);
|
2010-08-17 10:57:13 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval);
|
|
|
|
FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval);
|
|
|
|
FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval);
|
2014-02-27 03:53:16 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, SendSample);
|
2013-05-08 07:55:00 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, SendCpuThrottleMetrics);
|
2014-06-05 01:53:35 +08:00
|
|
|
FRIEND_TEST(MetricsDaemonTest, SendZramMetrics);
|
2010-05-04 07:45:37 +08:00
|
|
|
|
2011-02-18 02:21:16 +08:00
|
|
|
// State for disk stats collector callback.
|
2011-10-15 03:03:35 +08:00
|
|
|
enum StatsState {
|
|
|
|
kStatsShort, // short wait before short interval collection
|
|
|
|
kStatsLong, // final wait before new collection
|
2011-02-18 02:21:16 +08:00
|
|
|
};
|
|
|
|
|
2010-05-04 07:45:37 +08:00
|
|
|
// Data record for aggregating daily usage.
|
|
|
|
class UseRecord {
|
|
|
|
public:
|
|
|
|
UseRecord() : day_(0), seconds_(0) {}
|
|
|
|
int day_;
|
|
|
|
int seconds_;
|
|
|
|
};
|
|
|
|
|
2013-02-05 11:50:45 +08:00
|
|
|
// Type of scale to use for meminfo histograms. For most of them we use
|
|
|
|
// percent of total RAM, but for some we use absolute numbers, usually in
|
|
|
|
// megabytes, on a log scale from 0 to 4000, and 0 to 8000 for compressed
|
|
|
|
// swap (since it can be larger than total RAM).
|
2013-02-13 05:17:07 +08:00
|
|
|
enum MeminfoOp {
|
|
|
|
kMeminfoOp_HistPercent = 0,
|
|
|
|
kMeminfoOp_HistLog,
|
|
|
|
kMeminfoOp_SwapTotal,
|
|
|
|
kMeminfoOp_SwapFree,
|
2013-02-05 11:50:45 +08:00
|
|
|
};
|
|
|
|
|
2011-05-18 07:37:18 +08:00
|
|
|
// Record for retrieving and reporting values from /proc/meminfo.
|
|
|
|
struct MeminfoRecord {
|
2013-02-05 11:50:45 +08:00
|
|
|
const char* name; // print name
|
|
|
|
const char* match; // string to match in output of /proc/meminfo
|
2013-02-13 05:17:07 +08:00
|
|
|
MeminfoOp op; // histogram scale selector, or other operator
|
2013-02-05 11:50:45 +08:00
|
|
|
int value; // value from /proc/meminfo
|
2011-05-18 07:37:18 +08:00
|
|
|
};
|
|
|
|
|
2013-08-01 14:18:31 +08:00
|
|
|
// Record for retrieving and reporting values from /proc/vmstat
|
|
|
|
struct VmstatRecord {
|
|
|
|
uint64_t page_faults_; // major faults
|
|
|
|
uint64_t swap_in_; // pages swapped in
|
|
|
|
uint64_t swap_out_; // pages swapped out
|
|
|
|
};
|
|
|
|
|
2010-05-06 07:06:37 +08:00
|
|
|
// Metric parameters.
|
2011-02-18 02:21:16 +08:00
|
|
|
static const char kMetricReadSectorsLongName[];
|
|
|
|
static const char kMetricReadSectorsShortName[];
|
|
|
|
static const char kMetricWriteSectorsLongName[];
|
|
|
|
static const char kMetricWriteSectorsShortName[];
|
2011-10-15 03:03:35 +08:00
|
|
|
static const char kMetricPageFaultsShortName[];
|
|
|
|
static const char kMetricPageFaultsLongName[];
|
2013-08-01 14:18:31 +08:00
|
|
|
static const char kMetricSwapInLongName[];
|
|
|
|
static const char kMetricSwapInShortName[];
|
|
|
|
static const char kMetricSwapOutLongName[];
|
|
|
|
static const char kMetricSwapOutShortName[];
|
2013-05-08 07:55:00 +08:00
|
|
|
static const char kMetricScaledCpuFrequencyName[];
|
2011-10-15 03:03:35 +08:00
|
|
|
static const int kMetricStatsShortInterval;
|
|
|
|
static const int kMetricStatsLongInterval;
|
2011-04-13 05:12:35 +08:00
|
|
|
static const int kMetricMeminfoInterval;
|
2011-02-18 02:21:16 +08:00
|
|
|
static const int kMetricSectorsIOMax;
|
|
|
|
static const int kMetricSectorsBuckets;
|
2011-10-15 03:03:35 +08:00
|
|
|
static const int kMetricPageFaultsMax;
|
|
|
|
static const int kMetricPageFaultsBuckets;
|
2011-02-18 02:21:16 +08:00
|
|
|
static const char kMetricsDiskStatsPath[];
|
2011-10-15 03:03:35 +08:00
|
|
|
static const char kMetricsVmStatsPath[];
|
2014-03-18 03:28:38 +08:00
|
|
|
static const char kMetricsProcStatFileName[];
|
|
|
|
static const int kMetricsProcStatFirstLineItemsCount;
|
2010-05-06 07:06:37 +08:00
|
|
|
|
2011-05-18 07:37:18 +08:00
|
|
|
// Returns the active time since boot (uptime minus sleep time) in seconds.
|
|
|
|
double GetActiveTime();
|
|
|
|
|
2010-04-28 02:02:18 +08:00
|
|
|
// D-Bus filter callback.
|
|
|
|
static DBusHandlerResult MessageFilter(DBusConnection* connection,
|
|
|
|
DBusMessage* message,
|
|
|
|
void* user_data);
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2010-05-04 07:45:37 +08:00
|
|
|
// Updates the daily usage file, if necessary, by adding |seconds|
|
|
|
|
// of active use to the |day| since Epoch. If there's usage data for
|
|
|
|
// day in the past in the usage file, that data is sent to UMA and
|
|
|
|
// removed from the file. If there's already usage data for |day| in
|
|
|
|
// the usage file, the |seconds| are accumulated.
|
|
|
|
void LogDailyUseRecord(int day, int seconds);
|
|
|
|
|
2010-06-17 06:58:06 +08:00
|
|
|
// Updates the active use time and logs time between user-space
|
|
|
|
// process crashes.
|
|
|
|
void ProcessUserCrash();
|
|
|
|
|
2010-06-25 03:10:26 +08:00
|
|
|
// Updates the active use time and logs time between kernel crashes.
|
|
|
|
void ProcessKernelCrash();
|
|
|
|
|
2010-08-17 10:57:13 +08:00
|
|
|
// Updates the active use time and logs time between unclean shutdowns.
|
|
|
|
void ProcessUncleanShutdown();
|
|
|
|
|
|
|
|
// Checks if a kernel crash has been detected and returns true if
|
|
|
|
// so. The method assumes that a kernel crash has happened if
|
|
|
|
// |crash_file| exists. It removes the file immediately if it
|
|
|
|
// exists, so it must not be called more than once.
|
|
|
|
bool CheckSystemCrash(const std::string& crash_file);
|
2010-06-25 03:10:26 +08:00
|
|
|
|
2010-05-19 02:00:59 +08:00
|
|
|
// Sends a regular (exponential) histogram sample to Chrome for
|
|
|
|
// transport to UMA. See MetricsLibrary::SendToUMA in
|
|
|
|
// metrics_library.h for a description of the arguments.
|
2014-02-27 03:53:16 +08:00
|
|
|
void SendSample(const std::string& name, int sample,
|
2010-05-19 02:00:59 +08:00
|
|
|
int min, int max, int nbuckets);
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2011-04-13 05:12:35 +08:00
|
|
|
// Sends a linear histogram sample to Chrome for transport to UMA. See
|
|
|
|
// MetricsLibrary::SendToUMA in metrics_library.h for a description of the
|
|
|
|
// arguments.
|
2014-02-27 03:53:16 +08:00
|
|
|
void SendLinearSample(const std::string& name, int sample,
|
2011-04-13 05:12:35 +08:00
|
|
|
int max, int nbuckets);
|
|
|
|
|
2014-03-18 03:28:38 +08:00
|
|
|
// Sends various cumulative kernel crash-related stats, for instance the
|
|
|
|
// total number of kernel crashes since the last version update.
|
2014-04-19 08:00:35 +08:00
|
|
|
void SendKernelCrashesCumulativeCountStats();
|
2014-03-18 03:28:38 +08:00
|
|
|
|
|
|
|
// Returns the total (system-wide) CPU usage between the time of the most
|
|
|
|
// recent call to this function and now.
|
|
|
|
base::TimeDelta GetIncrementalCpuUse();
|
2014-02-27 03:53:16 +08:00
|
|
|
|
2014-04-19 08:00:35 +08:00
|
|
|
// Sends a sample representing the number of seconds of active use
|
|
|
|
// for a 24-hour period.
|
|
|
|
void SendDailyUseSample(const scoped_ptr<PersistentInteger>& use);
|
|
|
|
|
2014-02-27 03:53:16 +08:00
|
|
|
// Sends a sample representing a time interval between two crashes of the
|
|
|
|
// same type.
|
|
|
|
void SendCrashIntervalSample(const scoped_ptr<PersistentInteger>& interval);
|
|
|
|
|
|
|
|
// Sends a sample representing a frequency of crashes of some type.
|
|
|
|
void SendCrashFrequencySample(const scoped_ptr<PersistentInteger>& frequency);
|
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
// Initializes vm and disk stats reporting.
|
|
|
|
void StatsReporterInit();
|
2011-02-18 02:21:16 +08:00
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
// Schedules a callback for the next vm and disk stats collection.
|
|
|
|
void ScheduleStatsCallback(int wait);
|
2011-02-18 02:21:16 +08:00
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
// Reads cumulative disk statistics from sysfs. Returns true for success.
|
2014-08-07 15:54:59 +08:00
|
|
|
bool DiskStatsReadStats(uint64_t* read_sectors, uint64_t* write_sectors);
|
2011-02-18 02:21:16 +08:00
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
// Reads cumulative vm statistics from procfs. Returns true for success.
|
2013-08-01 14:18:31 +08:00
|
|
|
bool VmStatsReadStats(struct VmstatRecord* stats);
|
2011-10-15 03:03:35 +08:00
|
|
|
|
|
|
|
// Parse cumulative vm statistics from a C string. Returns true for success.
|
2013-08-01 14:18:31 +08:00
|
|
|
bool VmStatsParseStats(const char* stats, struct VmstatRecord* record);
|
2011-02-18 02:21:16 +08:00
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
// Reports disk and vm statistics.
|
|
|
|
void StatsCallback();
|
2011-02-18 02:21:16 +08:00
|
|
|
|
2011-04-13 05:12:35 +08:00
|
|
|
// Schedules meminfo collection callback.
|
|
|
|
void ScheduleMeminfoCallback(int wait);
|
|
|
|
|
2014-12-02 05:38:21 +08:00
|
|
|
// Reports memory statistics. Reschedules callback on success.
|
|
|
|
void MeminfoCallback(base::TimeDelta wait);
|
2011-04-13 05:12:35 +08:00
|
|
|
|
|
|
|
// Parses content of /proc/meminfo and sends fields of interest to UMA.
|
2011-05-18 07:37:18 +08:00
|
|
|
// Returns false on errors. |meminfo_raw| contains the content of
|
|
|
|
// /proc/meminfo.
|
2011-10-15 03:03:35 +08:00
|
|
|
bool ProcessMeminfo(const std::string& meminfo_raw);
|
2011-05-18 07:37:18 +08:00
|
|
|
|
|
|
|
// Parses meminfo data from |meminfo_raw|. |fields| is a vector containing
|
|
|
|
// the fields of interest. The order of the fields must be the same in which
|
|
|
|
// /proc/meminfo prints them. The result of parsing fields[i] is placed in
|
|
|
|
// fields[i].value.
|
2011-10-15 03:03:35 +08:00
|
|
|
bool FillMeminfo(const std::string& meminfo_raw,
|
|
|
|
std::vector<MeminfoRecord>* fields);
|
2011-05-18 07:37:18 +08:00
|
|
|
|
2013-12-06 07:55:12 +08:00
|
|
|
// Schedule a memory use callback in |interval| seconds.
|
|
|
|
void ScheduleMemuseCallback(double interval);
|
2011-05-18 07:37:18 +08:00
|
|
|
|
|
|
|
// Calls MemuseCallbackWork, and possibly schedules next callback, if enough
|
|
|
|
// active time has passed. Otherwise reschedules itself to simulate active
|
|
|
|
// time callbacks (i.e. wall clock time minus sleep time).
|
|
|
|
void MemuseCallback();
|
|
|
|
|
|
|
|
// Reads /proc/meminfo and sends total anonymous memory usage to UMA.
|
2011-10-15 03:03:35 +08:00
|
|
|
bool MemuseCallbackWork();
|
2011-05-18 07:37:18 +08:00
|
|
|
|
2013-05-08 07:55:00 +08:00
|
|
|
// Parses meminfo data and sends it to UMA.
|
2011-10-15 03:03:35 +08:00
|
|
|
bool ProcessMemuse(const std::string& meminfo_raw);
|
2011-04-13 05:12:35 +08:00
|
|
|
|
2013-05-08 07:55:00 +08:00
|
|
|
// Sends stats for thermal CPU throttling.
|
|
|
|
void SendCpuThrottleMetrics();
|
|
|
|
|
|
|
|
// Reads an integer CPU frequency value from sysfs.
|
|
|
|
bool ReadFreqToInt(const std::string& sysfs_file_name, int* value);
|
|
|
|
|
2014-02-06 07:33:19 +08:00
|
|
|
// Reads the current OS version from /etc/lsb-release and hashes it
|
|
|
|
// to a unsigned 32-bit int.
|
2014-08-07 15:54:59 +08:00
|
|
|
uint32_t GetOsVersionHash();
|
2014-02-06 07:33:19 +08:00
|
|
|
|
2014-04-04 23:53:44 +08:00
|
|
|
// Updates stats, additionally sending them to UMA if enough time has elapsed
|
|
|
|
// since the last report.
|
|
|
|
void UpdateStats(base::TimeTicks now_ticks, base::Time now_wall_time);
|
|
|
|
|
|
|
|
// Invoked periodically by |update_stats_timeout_id_| to call UpdateStats().
|
2014-12-02 05:38:21 +08:00
|
|
|
void HandleUpdateStatsTimeout();
|
2014-04-04 23:53:44 +08:00
|
|
|
|
2014-06-05 01:53:35 +08:00
|
|
|
// Reports zram statistics.
|
|
|
|
bool ReportZram(const base::FilePath& zram_dir);
|
|
|
|
|
2014-08-07 15:54:59 +08:00
|
|
|
// Reads a string from a file and converts it to uint64_t.
|
|
|
|
static bool ReadFileToUint64(const base::FilePath& path, uint64_t* value);
|
2014-06-05 01:53:35 +08:00
|
|
|
|
|
|
|
// VARIABLES
|
|
|
|
|
2010-05-06 07:06:37 +08:00
|
|
|
// Test mode.
|
2010-05-04 07:45:37 +08:00
|
|
|
bool testing_;
|
2010-04-15 04:32:20 +08:00
|
|
|
|
2014-12-02 05:38:21 +08:00
|
|
|
// Whether the uploader is enabled or disabled.
|
|
|
|
bool uploader_active_;
|
|
|
|
|
2015-08-06 07:04:14 +08:00
|
|
|
// Whether or not dbus should be used.
|
|
|
|
// If disabled, we will not collect the frequency of crashes.
|
|
|
|
bool dbus_enabled_;
|
|
|
|
|
2014-10-08 02:26:25 +08:00
|
|
|
// Root of the configuration files to use.
|
|
|
|
std::string config_root_;
|
|
|
|
|
2010-05-13 04:05:45 +08:00
|
|
|
// The metrics library handle.
|
|
|
|
MetricsLibraryInterface* metrics_lib_;
|
|
|
|
|
2010-06-05 04:14:19 +08:00
|
|
|
// Timestamps last network state update. This timestamp is used to
|
|
|
|
// sample the time from the network going online to going offline so
|
|
|
|
// TimeTicks ensures a monotonically increasing TimeDelta.
|
|
|
|
base::TimeTicks network_state_last_;
|
2010-05-04 07:45:37 +08:00
|
|
|
|
2014-04-04 23:53:44 +08:00
|
|
|
// The last time that UpdateStats() was called.
|
|
|
|
base::TimeTicks last_update_stats_time_;
|
2010-05-04 07:45:37 +08:00
|
|
|
|
2013-12-06 07:55:12 +08:00
|
|
|
// End time of current memuse stat collection interval.
|
|
|
|
double memuse_final_time_;
|
2011-05-18 07:37:18 +08:00
|
|
|
|
|
|
|
// Selects the wait time for the next memory use callback.
|
|
|
|
unsigned int memuse_interval_index_;
|
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
// Contain the most recent disk and vm cumulative stats.
|
2014-08-07 15:54:59 +08:00
|
|
|
uint64_t read_sectors_;
|
|
|
|
uint64_t write_sectors_;
|
2013-08-01 14:18:31 +08:00
|
|
|
struct VmstatRecord vmstats_;
|
2011-10-15 03:03:35 +08:00
|
|
|
|
|
|
|
StatsState stats_state_;
|
|
|
|
double stats_initial_time_;
|
2011-02-18 02:21:16 +08:00
|
|
|
|
2014-03-18 03:28:38 +08:00
|
|
|
// The system "HZ", or frequency of ticks. Some system data uses ticks as a
|
|
|
|
// unit, and this is used to convert to standard time units.
|
2014-08-07 15:54:59 +08:00
|
|
|
uint32_t ticks_per_second_;
|
2014-03-18 03:28:38 +08:00
|
|
|
// Used internally by GetIncrementalCpuUse() to return the CPU utilization
|
|
|
|
// between calls.
|
2014-08-07 15:54:59 +08:00
|
|
|
uint64_t latest_cpu_use_ticks_;
|
2014-03-18 03:28:38 +08:00
|
|
|
|
|
|
|
// Persistent values and accumulators for crash statistics.
|
2014-02-27 03:53:16 +08:00
|
|
|
scoped_ptr<PersistentInteger> daily_cycle_;
|
|
|
|
scoped_ptr<PersistentInteger> weekly_cycle_;
|
|
|
|
scoped_ptr<PersistentInteger> version_cycle_;
|
|
|
|
|
2014-04-19 08:00:35 +08:00
|
|
|
// Active use accumulated in a day.
|
|
|
|
scoped_ptr<PersistentInteger> daily_active_use_;
|
|
|
|
// Active use accumulated since the latest version update.
|
|
|
|
scoped_ptr<PersistentInteger> version_cumulative_active_use_;
|
2014-02-27 03:53:16 +08:00
|
|
|
|
2014-03-18 03:28:38 +08:00
|
|
|
// The CPU time accumulator. This contains the CPU time, in milliseconds,
|
|
|
|
// used by the system since the most recent OS version update.
|
|
|
|
scoped_ptr<PersistentInteger> version_cumulative_cpu_use_;
|
|
|
|
|
2014-02-27 03:53:16 +08:00
|
|
|
scoped_ptr<PersistentInteger> user_crash_interval_;
|
|
|
|
scoped_ptr<PersistentInteger> kernel_crash_interval_;
|
|
|
|
scoped_ptr<PersistentInteger> unclean_shutdown_interval_;
|
|
|
|
|
|
|
|
scoped_ptr<PersistentInteger> any_crashes_daily_count_;
|
|
|
|
scoped_ptr<PersistentInteger> any_crashes_weekly_count_;
|
|
|
|
scoped_ptr<PersistentInteger> user_crashes_daily_count_;
|
|
|
|
scoped_ptr<PersistentInteger> user_crashes_weekly_count_;
|
|
|
|
scoped_ptr<PersistentInteger> kernel_crashes_daily_count_;
|
|
|
|
scoped_ptr<PersistentInteger> kernel_crashes_weekly_count_;
|
|
|
|
scoped_ptr<PersistentInteger> kernel_crashes_version_count_;
|
|
|
|
scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_;
|
|
|
|
scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
|
|
|
|
|
2011-10-15 03:03:35 +08:00
|
|
|
std::string vmstats_path_;
|
2013-05-08 07:55:00 +08:00
|
|
|
std::string scaling_max_freq_path_;
|
|
|
|
std::string cpuinfo_max_freq_path_;
|
2014-06-26 05:38:07 +08:00
|
|
|
|
2014-10-10 01:14:13 +08:00
|
|
|
base::TimeDelta upload_interval_;
|
2014-10-07 06:15:30 +08:00
|
|
|
std::string server_;
|
|
|
|
std::string metrics_file_;
|
|
|
|
|
2014-06-26 05:38:07 +08:00
|
|
|
scoped_ptr<UploadService> upload_service_;
|
2010-04-15 04:32:20 +08:00
|
|
|
};
|
|
|
|
|
2014-07-01 09:12:28 +08:00
|
|
|
#endif // METRICS_METRICS_DAEMON_H_
|