MetroCollect  2.3.4
MetroCollect::MetricsSource::SourceProcMeminfo Class Reference

Sources of memory metrics extracted from the file /proc/meminfo. More...

#include <SourceProcMeminfo.h>

Inheritance diagram for MetroCollect::MetricsSource::SourceProcMeminfo:
Collaboration diagram for MetroCollect::MetricsSource::SourceProcMeminfo:

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< FieldInfoallFieldsInfo () 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 SourceProcMeminfoget ()
 Get the Instance object. More...
 

Protected Member Functions

 SourceProcMeminfo ()
 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

std::ifstream file_
 File descriptor. More...
 
std::vector< char > buffer_
 Buffer to put file contents into. More...
 
std::vector< std::string > fieldNames_
 Metrics names. More...
 

Static Protected Attributes

static constexpr std::string_view filePath = "/proc/meminfo"sv
 Memory metrics file path. More...
 
static constexpr std::string_view sourcePrefix = "memory"sv
 Metrics name source prefix. More...
 
static constexpr std::array fieldUnitsAssociation = { KeyUnit{"huge_pages_"sv, ""sv} }
 Metric units associations. More...
 
static constexpr std::string_view defaultUnit = "bytes"sv
 Metric unit. More...
 

Detailed Description

Sources of memory metrics extracted from the file /proc/meminfo.

Definition at line 38 of file SourceProcMeminfo.h.

Constructor & Destructor Documentation

◆ SourceProcMeminfo()

MetroCollect::MetricsSource::SourceProcMeminfo::SourceProcMeminfo ( )
protected

Private default constructor.

Definition at line 28 of file SourceProcMeminfo.cc.

Here is the call graph for this function:

Member Function Documentation

◆ allFieldsInfo()

const std::vector< FieldInfo > MetroCollect::MetricsSource::SourceProcMeminfo::allFieldsInfo ( ) const
finaloverridevirtualnoexcept

Get all fields details, field which share a common name should appear only once.

Returns
all fields details

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 103 of file SourceProcMeminfo.cc.

◆ computeDiff()

void MetroCollect::MetricsSource::SourceProcMeminfo::computeDiff ( const Interests interests,
DiffArray::Iterator  diff,
DataArray::ConstIterator  current,
DataArray::ConstIterator  previous,
double  factor = 1 
)
finaloverridevirtualnoexcept

Compute the variation (in appropriate unit) of metrics.

Parameters
interestsinterests boolean array to know for which fields metrics variation should be computed
diffiterator to write metrics variation to
currentiterator to read latest metrics from
previousiterator to read previous metrics from
factorfactor to convert to unit per second, if relevant

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 155 of file SourceProcMeminfo.cc.

◆ fetchData()

void MetroCollect::MetricsSource::SourceProcMeminfo::fetchData ( const Interests interests,
DataArray::Iterator  current 
)
finaloverridevirtual

Fetch the latest metrics.

Parameters
interestsboolean array to know for which fields metrics should be fetched
currentiterator to write metrics to

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 111 of file SourceProcMeminfo.cc.

Here is the call graph for this function:

◆ fieldCount()

size_t MetroCollect::MetricsSource::SourceProcMeminfo::fieldCount ( ) const
finaloverridevirtualnoexcept

Get the number of field the source has.

Returns
Number of fields of the source

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 76 of file SourceProcMeminfo.cc.

Here is the caller graph for this function:

◆ fieldInfoAtIndex()

const FieldInfo MetroCollect::MetricsSource::SourceProcMeminfo::fieldInfoAtIndex ( size_t  index) const
finaloverridevirtualnoexcept

Get details about a specific field.

Parameters
indexindex of the field to get details of
Returns
details of the field

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 97 of file SourceProcMeminfo.cc.

Here is the call graph for this function:

◆ fieldNameSourcePrefix()

const std::string MetroCollect::MetricsSource::SourceProcMeminfo::fieldNameSourcePrefix ( ) const
finaloverridevirtualnoexcept

Get the prefix by which all field names should begin with.

Returns
the source's names prefix

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 93 of file SourceProcMeminfo.cc.

◆ get()

static SourceProcMeminfo& MetroCollect::MetricsSource::SourceProcMeminfo::get ( )
inlinestatic

Get the Instance object.

Definition at line 57 of file SourceProcMeminfo.h.

◆ indexesOfFieldName()

const std::vector< size_t > MetroCollect::MetricsSource::SourceProcMeminfo::indexesOfFieldName ( const FieldName fieldName,
Interests interests = nullptr 
) const
finaloverridevirtualnoexcept

Search for fields associated to a specific name.

Parameters
fieldNamethe name of the fields to search
interestsif the pointer is not nullptr, the interest bit corresponding to the fields will be set
Returns
the indexes associated with the field name

Implements MetroCollect::MetricsSource::SourceBase.

Definition at line 80 of file SourceProcMeminfo.cc.

◆ parseFields()

void MetroCollect::MetricsSource::SourceProcMeminfo::parseFields ( )
protected

File parser function.

Definition at line 34 of file SourceProcMeminfo.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ buffer_

std::vector<char> MetroCollect::MetricsSource::SourceProcMeminfo::buffer_
protected

Buffer to put file contents into.

Definition at line 47 of file SourceProcMeminfo.h.

◆ defaultUnit

constexpr std::string_view MetroCollect::MetricsSource::SourceProcMeminfo::defaultUnit = "bytes"sv
staticprotected

Metric unit.

Definition at line 44 of file SourceProcMeminfo.h.

◆ fieldNames_

std::vector<std::string> MetroCollect::MetricsSource::SourceProcMeminfo::fieldNames_
protected

Metrics names.

Definition at line 48 of file SourceProcMeminfo.h.

◆ fieldUnitsAssociation

constexpr std::array MetroCollect::MetricsSource::SourceProcMeminfo::fieldUnitsAssociation = { KeyUnit{"huge_pages_"sv, ""sv} }
staticprotected

Metric units associations.

Definition at line 43 of file SourceProcMeminfo.h.

◆ file_

std::ifstream MetroCollect::MetricsSource::SourceProcMeminfo::file_
protected

File descriptor.

Definition at line 46 of file SourceProcMeminfo.h.

◆ filePath

constexpr std::string_view MetroCollect::MetricsSource::SourceProcMeminfo::filePath = "/proc/meminfo"sv
staticprotected

Memory metrics file path.

Definition at line 40 of file SourceProcMeminfo.h.

◆ sourcePrefix

constexpr std::string_view MetroCollect::MetricsSource::SourceProcMeminfo::sourcePrefix = "memory"sv
staticprotected

Metrics name source prefix.

Definition at line 42 of file SourceProcMeminfo.h.


The documentation for this class was generated from the following files: