Added a warning in the log when the cpu metrics are not registered due

to the number cpu cores is greater than supported.
This commit is contained in:
AlaiaL 2021-03-24 09:59:02 +01:00 committed by AlaiaL
parent c9d1c77e8c
commit bbaebd1274
5 changed files with 13 additions and 3 deletions

View File

@ -17,7 +17,7 @@
namespace srsran { namespace srsran {
constexpr uint32_t metrics_max_supported_cpu = 32; constexpr uint32_t metrics_max_supported_cpu = 32u;
/// Metrics of cpu usage, memory consumption and number of thread used by the process. /// Metrics of cpu usage, memory consumption and number of thread used by the process.
struct sys_metrics_t { struct sys_metrics_t {

View File

@ -13,6 +13,7 @@
#ifndef SRSRAN_SYS_METRICS_PROCESSOR_H #ifndef SRSRAN_SYS_METRICS_PROCESSOR_H
#define SRSRAN_SYS_METRICS_PROCESSOR_H #define SRSRAN_SYS_METRICS_PROCESSOR_H
#include "srsran/srslog/logger.h"
#include "srsran/system/sys_metrics.h" #include "srsran/system/sys_metrics.h"
#include <chrono> #include <chrono>
#include <string> #include <string>
@ -55,6 +56,7 @@ class sys_metrics_processor
}; };
public: public:
explicit sys_metrics_processor(srslog::basic_logger& log);
/// Measures and returns the system metrics. /// Measures and returns the system metrics.
sys_metrics_t get_metrics(); sys_metrics_t get_metrics();
@ -76,6 +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;
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();

View File

@ -21,6 +21,13 @@ 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)
{
if (cpu_count > metrics_max_supported_cpu) {
log.warning("Number of cpu is greater than supported. CPU metrics will be disabled.");
}
}
sys_metrics_processor::proc_stats_info::proc_stats_info() sys_metrics_processor::proc_stats_info::proc_stats_info()
{ {
std::string line; std::string line;

View File

@ -23,7 +23,7 @@
namespace srsenb { namespace srsenb {
enb::enb(srslog::sink& log_sink) : enb::enb(srslog::sink& log_sink) :
started(false), log_sink(log_sink), enb_log(srslog::fetch_basic_logger("ENB", log_sink, false)) started(false), log_sink(log_sink), enb_log(srslog::fetch_basic_logger("ENB", log_sink, false)), sys_proc(enb_log)
{ {
// print build info // print build info
std::cout << std::endl << get_build_string() << std::endl << std::endl; std::cout << std::endl << get_build_string() << std::endl << std::endl;

View File

@ -29,7 +29,7 @@ using namespace srsran;
namespace srsue { namespace srsue {
ue::ue() : logger(srslog::fetch_basic_logger("UE", false)) ue::ue() : logger(srslog::fetch_basic_logger("UE", false)), sys_proc(logger)
{ {
// print build info // print build info
std::cout << std::endl << get_build_string() << std::endl << std::endl; std::cout << std::endl << get_build_string() << std::endl << std::endl;