26 #include <string_view> 40 static constexpr std::string_view filePath =
"/proc/stat"sv;
42 static constexpr std::string_view sourcePrefix =
"cpu"sv;
43 static constexpr std::string_view fieldNameOtherPrefix =
"other"sv;
44 static constexpr std::string_view fieldNameAllCoresPrefix =
"all"sv;
45 static constexpr std::string_view fieldNameCorePrefix =
"core"sv;
46 static constexpr std::string_view fieldNameCoreDescription =
"cpuID"sv;
47 static constexpr std::string_view fieldNameCoreAll =
"*"sv;
48 static constexpr std::string_view cpuField =
"cpu"sv;
49 static constexpr
size_t cpuFieldCount = 10;
50 static constexpr std::array<std::string_view, cpuFieldCount> cpuFieldNames = {
"user"sv,
"nice"sv,
"system"sv,
"idle"sv,
"iowait"sv,
"irq"sv,
"softirq"sv,
"steal"sv,
"guest"sv,
"guestNice"sv};
51 static constexpr std::string_view percentUnit =
"%"sv;
52 static constexpr std::string_view defaultUnit =
""sv;
71 size_t fieldCount() const noexcept override final;
72 const
std::vector<
size_t> indexesOfFieldName(const
FieldName& fieldName,
Interests* interests =
nullptr) const noexcept override final;
73 const
std::
string fieldNameSourcePrefix() const noexcept override final;
74 const
FieldInfo fieldInfoAtIndex(
size_t index) const noexcept override final;
75 const
std::vector<
FieldInfo> allFieldsInfo() const noexcept override final;
77 void fetchData(const
Interests& interests, DataArray::
Iterator current) override final;
Object used to describe a field (or metric)
std::vector< std::string > FieldName
Type used for field names (an array of strings)
Namespace for sources of metrics objects and operations.
std::vector< DataValueType >::const_iterator ConstIterator
Const iterator type of MetricsDataArray.
Sources of CPU metrics extracted from the file /proc/stat.
Boolean array to keep track of which fields a source has to fetch metrics for.
std::vector< char > buffer_
Buffer to put file contents into.
Singleton abstract class, base class of all metric sources classes.
std::vector< std::string > otherFieldNames_
Names of other CPU metrics.
std::vector< DataValueType >::iterator Iterator
Iterator type of MetricsDataArray.
size_t cpuCount_
Number of CPUs.
std::ifstream file_
File descriptor.