am 38f55079: Merge "metrics: Disable stat collection."
* commit '38f55079aaefd339ce7b851323be4c9d7f0c01b8': metrics: Disable stat collection.
This commit is contained in:
commit
73e5c7680a
3 changed files with 0 additions and 82 deletions
|
|
@ -220,7 +220,6 @@ bool MetricsDaemon::IsOnOfficialBuild() const {
|
||||||
void MetricsDaemon::Init(bool testing,
|
void MetricsDaemon::Init(bool testing,
|
||||||
bool uploader_active,
|
bool uploader_active,
|
||||||
MetricsLibraryInterface* metrics_lib,
|
MetricsLibraryInterface* metrics_lib,
|
||||||
const string& diskstats_path,
|
|
||||||
const string& vmstats_path,
|
const string& vmstats_path,
|
||||||
const string& scaling_max_freq_path,
|
const string& scaling_max_freq_path,
|
||||||
const string& cpuinfo_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"));
|
weekly_cycle_.reset(new PersistentInteger("weekly.cycle"));
|
||||||
version_cycle_.reset(new PersistentInteger("version.cycle"));
|
version_cycle_.reset(new PersistentInteger("version.cycle"));
|
||||||
|
|
||||||
diskstats_path_ = diskstats_path;
|
|
||||||
vmstats_path_ = vmstats_path;
|
vmstats_path_ = vmstats_path;
|
||||||
scaling_max_freq_path_ = scaling_max_freq_path;
|
scaling_max_freq_path_ = scaling_max_freq_path;
|
||||||
cpuinfo_max_freq_path_ = cpuinfo_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() {
|
int MetricsDaemon::OnInit() {
|
||||||
|
|
@ -294,13 +288,6 @@ int MetricsDaemon::OnInit() {
|
||||||
if (return_code != EX_OK)
|
if (return_code != EX_OK)
|
||||||
return return_code;
|
return return_code;
|
||||||
|
|
||||||
StatsReporterInit();
|
|
||||||
|
|
||||||
// Start collecting meminfo stats.
|
|
||||||
ScheduleMeminfoCallback(kMetricMeminfoInterval);
|
|
||||||
memuse_final_time_ = GetActiveTime() + kMemuseIntervals[0];
|
|
||||||
ScheduleMemuseCallback(kMemuseIntervals[0]);
|
|
||||||
|
|
||||||
if (testing_)
|
if (testing_)
|
||||||
return EX_OK;
|
return EX_OK;
|
||||||
|
|
||||||
|
|
@ -329,11 +316,6 @@ int MetricsDaemon::OnInit() {
|
||||||
return EX_UNAVAILABLE;
|
return EX_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
|
|
||||||
base::Bind(&MetricsDaemon::HandleUpdateStatsTimeout,
|
|
||||||
base::Unretained(this)),
|
|
||||||
base::TimeDelta::FromMilliseconds(kUpdateStatsIntervalMs));
|
|
||||||
|
|
||||||
if (uploader_active_) {
|
if (uploader_active_) {
|
||||||
if (IsOnOfficialBuild()) {
|
if (IsOnOfficialBuild()) {
|
||||||
LOG(INFO) << "uploader enabled";
|
LOG(INFO) << "uploader enabled";
|
||||||
|
|
@ -520,41 +502,6 @@ void MetricsDaemon::ScheduleStatsCallback(int wait) {
|
||||||
base::TimeDelta::FromSeconds(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,
|
bool MetricsDaemon::VmStatsParseStats(const char* stats,
|
||||||
struct VmstatRecord* record) {
|
struct VmstatRecord* record) {
|
||||||
// a mapping of string name to field in VmstatRecord and whether we found it
|
// a mapping of string name to field in VmstatRecord and whether we found it
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ class MetricsDaemon : public chromeos::DBusDaemon {
|
||||||
void Init(bool testing,
|
void Init(bool testing,
|
||||||
bool uploader_active,
|
bool uploader_active,
|
||||||
MetricsLibraryInterface* metrics_lib,
|
MetricsLibraryInterface* metrics_lib,
|
||||||
const std::string& diskstats_path,
|
|
||||||
const std::string& vmstats_path,
|
const std::string& vmstats_path,
|
||||||
const std::string& cpuinfo_max_freq_path,
|
const std::string& cpuinfo_max_freq_path,
|
||||||
const std::string& scaling_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_daily_count_;
|
||||||
scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
|
scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
|
||||||
|
|
||||||
std::string diskstats_path_;
|
|
||||||
std::string vmstats_path_;
|
std::string vmstats_path_;
|
||||||
std::string scaling_max_freq_path_;
|
std::string scaling_max_freq_path_;
|
||||||
std::string cpuinfo_max_freq_path_;
|
std::string cpuinfo_max_freq_path_;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
#include <base/strings/string_util.h>
|
#include <base/strings/string_util.h>
|
||||||
#include <chromeos/flag_helper.h>
|
#include <chromeos/flag_helper.h>
|
||||||
#include <chromeos/syslog_logging.h>
|
#include <chromeos/syslog_logging.h>
|
||||||
#include <rootdev/rootdev.h>
|
|
||||||
|
|
||||||
#include "metrics_daemon.h"
|
#include "metrics_daemon.h"
|
||||||
|
|
||||||
|
|
@ -17,31 +16,6 @@ const char kScalingMaxFreqPath[] =
|
||||||
const char kCpuinfoMaxFreqPath[] =
|
const char kCpuinfoMaxFreqPath[] =
|
||||||
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
|
"/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) {
|
int main(int argc, char** argv) {
|
||||||
DEFINE_bool(daemon, true, "run as daemon (use -nodaemon for debugging)");
|
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,
|
daemon.Init(FLAGS_uploader_test,
|
||||||
FLAGS_uploader | FLAGS_uploader_test,
|
FLAGS_uploader | FLAGS_uploader_test,
|
||||||
&metrics_lib,
|
&metrics_lib,
|
||||||
MetricsMainDiskStatsPath(),
|
|
||||||
"/proc/vmstat",
|
"/proc/vmstat",
|
||||||
kScalingMaxFreqPath,
|
kScalingMaxFreqPath,
|
||||||
kCpuinfoMaxFreqPath,
|
kCpuinfoMaxFreqPath,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue