- Renamed log to logger.

- Added a log entry in the metrics when skipping a measurement due to
time constrains
master
AlaiaL 4 years ago committed by AlaiaL
parent bbaebd1274
commit fd3c2b855e

@ -56,7 +56,7 @@ class sys_metrics_processor
}; };
public: public:
explicit sys_metrics_processor(srslog::basic_logger& log); explicit sys_metrics_processor(srslog::basic_logger& logger);
/// Measures and returns the system metrics. /// Measures and returns the system metrics.
sys_metrics_t get_metrics(); sys_metrics_t get_metrics();
@ -78,7 +78,7 @@ private:
cpu_metrics_t read_cpu_idle_from_line(const std::string& line) const; cpu_metrics_t read_cpu_idle_from_line(const std::string& line) const;
private: private:
srslog::basic_logger& log; srslog::basic_logger& logger;
proc_stats_info last_query = {}; proc_stats_info last_query = {};
cpu_metrics_t last_cpu_thread[metrics_max_supported_cpu] = {}; cpu_metrics_t last_cpu_thread[metrics_max_supported_cpu] = {};
std::chrono::time_point<std::chrono::steady_clock> last_query_time = std::chrono::steady_clock::now(); std::chrono::time_point<std::chrono::steady_clock> last_query_time = std::chrono::steady_clock::now();

@ -21,10 +21,10 @@ using namespace srsran;
static const uint32_t cpu_count = ::sysconf(_SC_NPROCESSORS_CONF); static const uint32_t cpu_count = ::sysconf(_SC_NPROCESSORS_CONF);
static const float ticks_per_second = ::sysconf(_SC_CLK_TCK); static const float ticks_per_second = ::sysconf(_SC_CLK_TCK);
sys_metrics_processor::sys_metrics_processor(srslog::basic_logger& log) : log(log) sys_metrics_processor::sys_metrics_processor(srslog::basic_logger& logger) : logger(logger)
{ {
if (cpu_count > metrics_max_supported_cpu) { if (cpu_count > metrics_max_supported_cpu) {
log.warning("Number of cpu is greater than supported. CPU metrics will be disabled."); logger.warning("Number of cpu is greater than supported. CPU metrics will be disabled.");
} }
} }
@ -57,6 +57,7 @@ sys_metrics_t sys_metrics_processor::get_metrics()
// The time elapsed between 2 measures must be greater that 100 milliseconds. // The time elapsed between 2 measures must be greater that 100 milliseconds.
if (measure_interval_ms < 100u) { if (measure_interval_ms < 100u) {
logger.warning("Interval less that 100ms, skipping measurement.");
return {}; return {};
} }

Loading…
Cancel
Save