Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: metrics_daemon.h

Issue 6486021: Collect some disk statistics. (Closed) Base URL: http://git.chromium.org/git/metrics.git@master
Patch Set: Change metrix prefix Filesystem back to Platform Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | metrics_daemon.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: metrics_daemon.h
diff --git a/metrics_daemon.h b/metrics_daemon.h
index 5f2e7868a9aed95793ea023f1863f2503326ccde..dd613227de02984802e338a6115cf6cc6f7b8f6c 100644
--- a/metrics_daemon.h
+++ b/metrics_daemon.h
@@ -29,7 +29,8 @@ class MetricsDaemon {
~MetricsDaemon();
// Initializes.
- void Init(bool testing, MetricsLibraryInterface* metrics_lib);
+ void Init(bool testing, MetricsLibraryInterface* metrics_lib,
+ const char* diskstats_path);
// Does all the work. If |run_as_daemon| is true, daemonizes by
// forking.
@@ -52,6 +53,7 @@ class MetricsDaemon {
FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash);
FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency);
FRIEND_TEST(MetricsDaemonTest, ReportDailyUse);
+ FRIEND_TEST(MetricsDaemonTest, ReportDiskStats);
FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval);
FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval);
FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval);
@@ -77,6 +79,12 @@ class MetricsDaemon {
kNumberSessionStates
};
+ // State for disk stats collector callback.
+ enum DiskStatsState {
+ kDiskStatsShort, // short wait before short interval collection
+ kDiskStatsLong, // final wait before new collection
+ };
+
// Data record for aggregating daily usage.
class UseRecord {
public:
@@ -111,6 +119,15 @@ class MetricsDaemon {
static const char kMetricUserCrashesDailyName[];
static const char kMetricUserCrashesWeeklyName[];
static const char kMetricUserCrashIntervalName[];
+ static const char kMetricReadSectorsLongName[];
+ static const char kMetricReadSectorsShortName[];
+ static const char kMetricWriteSectorsLongName[];
+ static const char kMetricWriteSectorsShortName[];
+ static const int kMetricDiskStatsShortInterval;
+ static const int kMetricDiskStatsLongInterval;
+ static const int kMetricSectorsIOMax;
+ static const int kMetricSectorsBuckets;
+ static const char kMetricsDiskStatsPath[];
// D-Bus message match strings.
static const char* kDBusMatches_[];
@@ -217,6 +234,22 @@ class MetricsDaemon {
void SendMetric(const std::string& name, int sample,
int min, int max, int nbuckets);
+ // Initializes disk stats reporting.
+ void DiskStatsReporterInit();
+
+ // Schedules a callback for the next disk stats collection.
+ void ScheduleDiskStatsCallback(int wait);
+
+ // Reads cumulative disk statistics from sysfs.
+ void DiskStatsReadStats(long int* read_sectors, long int* write_sectors);
+
+ // Reports disk statistics (static version for glib). Arguments are a glib
+ // artifact.
+ static gboolean DiskStatsCallbackStatic(void* handle);
+
+ // Reports disk statistics.
+ void DiskStatsCallback();
+
// Test mode.
bool testing_;
@@ -265,6 +298,13 @@ class MetricsDaemon {
// Scheduled daily use monitor source (see ScheduleUseMonitor).
GSource* usemon_source_;
+
+ // Contains the most recent disk stats.
+ long int read_sectors_;
+ long int write_sectors_;
+
+ DiskStatsState diskstats_state_;
+ const char* diskstats_path_;
};
#endif // METRICS_DAEMON_H_
« no previous file with comments | « no previous file | metrics_daemon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698