metrics: Disable stat collection.
The statistics collected might not be correct on android.
We should make sure that the values reported have the right meaning.
BUG: 22879597
BUG: 22953719
Change-Id: I9fb066333a07f43096bd54a16fcc83816248cc29
diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc
index 39af67b..2881f69 100644
--- a/metrics/metrics_daemon.cc
+++ b/metrics/metrics_daemon.cc
@@ -220,7 +220,6 @@
void MetricsDaemon::Init(bool testing,
bool uploader_active,
MetricsLibraryInterface* metrics_lib,
- const string& diskstats_path,
const string& vmstats_path,
const string& scaling_max_freq_path,
const string& cpuinfo_max_freq_path,
@@ -279,14 +278,9 @@
weekly_cycle_.reset(new PersistentInteger("weekly.cycle"));
version_cycle_.reset(new PersistentInteger("version.cycle"));
- diskstats_path_ = diskstats_path;
vmstats_path_ = vmstats_path;
scaling_max_freq_path_ = scaling_max_freq_path;
cpuinfo_max_freq_path_ = cpuinfo_max_freq_path;
-
- // If testing, initialize Stats Reporter without connecting DBus
- if (testing_)
- StatsReporterInit();
}
int MetricsDaemon::OnInit() {
@@ -294,13 +288,6 @@
if (return_code != EX_OK)
return return_code;
- StatsReporterInit();
-
- // Start collecting meminfo stats.
- ScheduleMeminfoCallback(kMetricMeminfoInterval);
- memuse_final_time_ = GetActiveTime() + kMemuseIntervals[0];
- ScheduleMemuseCallback(kMemuseIntervals[0]);
-
if (testing_)
return EX_OK;
@@ -329,11 +316,6 @@
return EX_UNAVAILABLE;
}
- base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
- base::Bind(&MetricsDaemon::HandleUpdateStatsTimeout,
- base::Unretained(this)),
- base::TimeDelta::FromMilliseconds(kUpdateStatsIntervalMs));
-
if (uploader_active_) {
if (IsOnOfficialBuild()) {
LOG(INFO) << "uploader enabled";
@@ -520,41 +502,6 @@
base::TimeDelta::FromSeconds(wait));
}
-bool MetricsDaemon::DiskStatsReadStats(uint64_t* read_sectors,
- uint64_t* write_sectors) {
- int nchars;
- int nitems;
- bool success = false;
- char line[200];
- if (diskstats_path_.empty()) {
- return false;
- }
- int file = HANDLE_EINTR(open(diskstats_path_.c_str(), O_RDONLY));
- if (file < 0) {
- PLOG(WARNING) << "cannot open " << diskstats_path_;
- return false;
- }
- nchars = HANDLE_EINTR(read(file, line, sizeof(line)));
- if (nchars < 0) {
- PLOG(WARNING) << "cannot read from " << diskstats_path_;
- return false;
- } else {
- LOG_IF(WARNING, nchars == sizeof(line))
- << "line too long in " << diskstats_path_;
- line[nchars] = '\0';
- nitems = sscanf(line, "%*d %*d %" PRIu64 " %*d %*d %*d %" PRIu64,
- read_sectors, write_sectors);
- if (nitems == 2) {
- success = true;
- } else {
- LOG(WARNING) << "found " << nitems << " items in "
- << diskstats_path_ << ", expected 2";
- }
- }
- IGNORE_EINTR(close(file));
- return success;
-}
-
bool MetricsDaemon::VmStatsParseStats(const char* stats,
struct VmstatRecord* record) {
// a mapping of string name to field in VmstatRecord and whether we found it
diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h
index 04c40e5..bcfec14 100644
--- a/metrics/metrics_daemon.h
+++ b/metrics/metrics_daemon.h
@@ -32,7 +32,6 @@
void Init(bool testing,
bool uploader_active,
MetricsLibraryInterface* metrics_lib,
- const std::string& diskstats_path,
const std::string& vmstats_path,
const std::string& cpuinfo_max_freq_path,
const std::string& scaling_max_freq_path,
@@ -356,7 +355,6 @@
scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_;
scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
- std::string diskstats_path_;
std::string vmstats_path_;
std::string scaling_max_freq_path_;
std::string cpuinfo_max_freq_path_;
diff --git a/metrics/metrics_daemon_main.cc b/metrics/metrics_daemon_main.cc
index 4a603e4..392f12a 100644
--- a/metrics/metrics_daemon_main.cc
+++ b/metrics/metrics_daemon_main.cc
@@ -8,7 +8,6 @@
#include <base/strings/string_util.h>
#include <chromeos/flag_helper.h>
#include <chromeos/syslog_logging.h>
-#include <rootdev/rootdev.h>
#include "metrics_daemon.h"
@@ -17,31 +16,6 @@
const char kCpuinfoMaxFreqPath[] =
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
-// Returns the path to the disk stats in the sysfs. Returns the null string if
-// it cannot find the disk stats file.
-static
-const std::string MetricsMainDiskStatsPath() {
- char dev_path_cstr[PATH_MAX];
- std::string dev_prefix = "/dev/";
- std::string dev_path;
- std::string dev_name;
-
- int ret = rootdev(dev_path_cstr, sizeof(dev_path_cstr), true, true);
- if (ret != 0) {
- LOG(WARNING) << "error " << ret << " determining root device";
- return "";
- }
- dev_path = dev_path_cstr;
- // Check that rootdev begins with "/dev/".
- if (!base::StartsWithASCII(dev_path, dev_prefix, false)) {
- LOG(WARNING) << "unexpected root device " << dev_path;
- return "";
- }
- // Get the device name, e.g. "sda" from "/dev/sda".
- dev_name = dev_path.substr(dev_prefix.length());
- return "/sys/class/block/" + dev_name + "/stat";
-}
-
int main(int argc, char** argv) {
DEFINE_bool(daemon, true, "run as daemon (use -nodaemon for debugging)");
@@ -84,7 +58,6 @@
daemon.Init(FLAGS_uploader_test,
FLAGS_uploader | FLAGS_uploader_test,
&metrics_lib,
- MetricsMainDiskStatsPath(),
"/proc/vmstat",
kScalingMaxFreqPath,
kCpuinfoMaxFreqPath,