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
This commit is contained in:
Bertrand SIMONNET 2015-08-04 14:21:05 -07:00
parent d16e9c254e
commit eeb7ef0284
3 changed files with 0 additions and 82 deletions

View file

@ -220,7 +220,6 @@ bool MetricsDaemon::IsOnOfficialBuild() const {
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 @@ void MetricsDaemon::Init(bool testing,
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 @@ int MetricsDaemon::OnInit() {
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 @@ int MetricsDaemon::OnInit() {
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 @@ void MetricsDaemon::ScheduleStatsCallback(int wait) {
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

View file

@ -32,7 +32,6 @@ class MetricsDaemon : public chromeos::DBusDaemon {
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 @@ class MetricsDaemon : public chromeos::DBusDaemon {
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_;

View file

@ -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 kScalingMaxFreqPath[] =
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 @@ int main(int argc, char** argv) {
daemon.Init(FLAGS_uploader_test,
FLAGS_uploader | FLAGS_uploader_test,
&metrics_lib,
MetricsMainDiskStatsPath(),
"/proc/vmstat",
kScalingMaxFreqPath,
kCpuinfoMaxFreqPath,