|
MetroCollect
2.3.4
|
Sources of CPU metrics extracted from the file /proc/stat. More...
#include <SourceProcStat.h>


Public Member Functions | |
| size_t | fieldCount () const noexcept override final |
| Get the number of field the source has. More... | |
| const std::vector< size_t > | indexesOfFieldName (const FieldName &fieldName, Interests *interests=nullptr) const noexcept override final |
| Search for fields associated to a specific name. More... | |
| const std::string | fieldNameSourcePrefix () const noexcept override final |
| Get the prefix by which all field names should begin with. More... | |
| const FieldInfo | fieldInfoAtIndex (size_t index) const noexcept override final |
| Get details about a specific field. More... | |
| const std::vector< FieldInfo > | allFieldsInfo () const noexcept override final |
| Get all fields details, field which share a common name should appear only once. More... | |
| void | fetchData (const Interests &interests, DataArray::Iterator current) override final |
| Fetch the latest metrics. More... | |
| void | computeDiff (const Interests &interests, DiffArray::Iterator diff, DataArray::ConstIterator current, DataArray::ConstIterator previous, double factor=1) noexcept override final |
| Compute the variation (in appropriate unit) of metrics. More... | |
Public Member Functions inherited from MetroCollect::MetricsSource::SourceBase | |
| SourceBase (const SourceBase &)=delete | |
| Deleted copy constructor. More... | |
| void | operator= (const SourceBase &)=delete |
| Deleted copy operator. More... | |
Static Public Member Functions | |
| static SourceProcStat & | get () |
| Get the Instance object. More... | |
Protected Member Functions | |
| SourceProcStat () | |
| Private default constructor. More... | |
| void | parseFields () |
| File parser function. More... | |
Protected Member Functions inherited from MetroCollect::MetricsSource::SourceBase | |
| SourceBase () | |
| Protected default constructor. More... | |
| ~SourceBase () | |
| Protected default destructor. More... | |
Protected Attributes | |
| size_t | cpuCount_ |
| Number of CPUs. More... | |
| std::vector< std::string > | otherFieldNames_ |
| Names of other CPU metrics. More... | |
| std::ifstream | file_ |
| File descriptor. More... | |
| std::vector< char > | buffer_ |
| Buffer to put file contents into. More... | |
Static Protected Attributes | |
| static constexpr std::string_view | filePath = "/proc/stat"sv |
| CPU metrics file path. More... | |
| static constexpr std::string_view | sourcePrefix = "cpu"sv |
| Metrics name source prefix. More... | |
| static constexpr std::string_view | fieldNameOtherPrefix = "other"sv |
| Metrics name category. More... | |
| static constexpr std::string_view | fieldNameAllCoresPrefix = "all"sv |
| Metrics name category. More... | |
| static constexpr std::string_view | fieldNameCorePrefix = "core"sv |
| Metrics name category. More... | |
| static constexpr std::string_view | fieldNameCoreDescription = "cpuID"sv |
| Metrics name category description. More... | |
| static constexpr std::string_view | fieldNameCoreAll = "*"sv |
| Metrics name wildcard. More... | |
| static constexpr std::string_view | cpuField = "cpu"sv |
| Metrics name category. More... | |
| static constexpr size_t | cpuFieldCount = 10 |
| Number of fields for each CPU. More... | |
| 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} |
| CPU states names. More... | |
| static constexpr std::string_view | percentUnit = "%"sv |
| Metric unit. More... | |
| static constexpr std::string_view | defaultUnit = ""sv |
| Metric unit. More... | |
Sources of CPU metrics extracted from the file /proc/stat.
Definition at line 38 of file SourceProcStat.h.
|
protected |
Private default constructor.
Definition at line 29 of file SourceProcStat.cc.

|
finaloverridevirtualnoexcept |
Get all fields details, field which share a common name should appear only once.
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 139 of file SourceProcStat.cc.

|
finaloverridevirtualnoexcept |
Compute the variation (in appropriate unit) of metrics.
| interests | interests boolean array to know for which fields metrics variation should be computed |
| diff | iterator to write metrics variation to |
| current | iterator to read latest metrics from |
| previous | iterator to read previous metrics from |
| factor | factor to convert to unit per second, if relevant |
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 202 of file SourceProcStat.cc.
|
finaloverridevirtual |
Fetch the latest metrics.
| interests | boolean array to know for which fields metrics should be fetched |
| current | iterator to write metrics to |
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 151 of file SourceProcStat.cc.

|
finaloverridevirtualnoexcept |
Get the number of field the source has.
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 63 of file SourceProcStat.cc.

|
finaloverridevirtualnoexcept |
Get details about a specific field.
| index | index of the field to get details of |
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 124 of file SourceProcStat.cc.

|
finaloverridevirtualnoexcept |
Get the prefix by which all field names should begin with.
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 120 of file SourceProcStat.cc.
|
inlinestatic |
Get the Instance object.
Definition at line 66 of file SourceProcStat.h.
|
finaloverridevirtualnoexcept |
Search for fields associated to a specific name.
| fieldName | the name of the fields to search |
| interests | if the pointer is not nullptr, the interest bit corresponding to the fields will be set |
Implements MetroCollect::MetricsSource::SourceBase.
Definition at line 67 of file SourceProcStat.cc.
|
protected |
File parser function.
Definition at line 35 of file SourceProcStat.cc.


|
protected |
Buffer to put file contents into.
Definition at line 57 of file SourceProcStat.h.
|
protected |
Number of CPUs.
Definition at line 54 of file SourceProcStat.h.
|
staticprotected |
Metrics name category.
Definition at line 48 of file SourceProcStat.h.
|
staticprotected |
Number of fields for each CPU.
Definition at line 49 of file SourceProcStat.h.
|
staticprotected |
CPU states names.
Definition at line 50 of file SourceProcStat.h.
|
staticprotected |
Metric unit.
Definition at line 52 of file SourceProcStat.h.
|
staticprotected |
Metrics name category.
Definition at line 44 of file SourceProcStat.h.
|
staticprotected |
Metrics name wildcard.
Definition at line 47 of file SourceProcStat.h.
|
staticprotected |
Metrics name category description.
Definition at line 46 of file SourceProcStat.h.
|
staticprotected |
Metrics name category.
Definition at line 45 of file SourceProcStat.h.
|
staticprotected |
Metrics name category.
Definition at line 43 of file SourceProcStat.h.
|
protected |
File descriptor.
Definition at line 56 of file SourceProcStat.h.
|
staticprotected |
CPU metrics file path.
Definition at line 40 of file SourceProcStat.h.
|
protected |
Names of other CPU metrics.
Definition at line 55 of file SourceProcStat.h.
|
staticprotected |
Metric unit.
Definition at line 51 of file SourceProcStat.h.
|
staticprotected |
Metrics name source prefix.
Definition at line 42 of file SourceProcStat.h.