17 #include <ros_monitoring_msgs/MetricData.h> 18 #include <sys/sysinfo.h> 26 #define MEGA (1048576.0) 32 struct sysinfo si = {0};
35 AddMetric(
"system_uptime", si.uptime, MetricData::UNIT_SEC);
36 AddMetric(
"free_ram", si.freeram * si.mem_unit /
MEGA, MetricData::UNIT_MEGABYTES);
37 AddMetric(
"total_ram", si.totalram * si.mem_unit /
MEGA, MetricData::UNIT_MEGABYTES);
38 AddMetric(
"process_count", si.procs, MetricData::UNIT_NONE);
42 const std::string & unit)
44 ros_monitoring_msgs::MetricData md = mgr_.CreateMetric();
45 md.metric_name = name;
void AddMetric(const std::string &name, const double value, const std::string &unit)
void Collect() overridefinal
callback for collecting metrics.