MetroCollect  2.3.4
MetroCollect::MetricsSource::SourceProcNetDev Class Reference

Sources of network metrics extracted from the file /proc/net/dev. More...

#include <SourceProcNetDev.h>

Inheritance diagram for MetroCollect::MetricsSource::SourceProcNetDev:
Collaboration diagram for MetroCollect::MetricsSource::SourceProcNetDev:

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

Protected Member Functions

 SourceProcNetDev ()
 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 > interfaces_
 Network interfaces names. More...
 
std::vector< std::string > rxFieldNames_
 Reception metric names. More...
 
std::vector< std::string > txFieldNames_
 Transmission metric names. More...
 

Static Protected Attributes

static constexpr std::string_view filePath = "/proc/1/net/dev"sv
 Network metrics file path. More...
 
static constexpr std::string_view sourcePrefix = "network"sv
 Metrics name source prefix. More...
 
static constexpr std::string_view fieldNameInterfaceDescription = "interface"sv
 Metrics name category description. More...
 
static constexpr std::string_view fieldRecieve = "rx"sv
 Metrics name category. More...
 
static constexpr std::string_view fieldTransmit = "tx"sv
 Metrics name category. More...
 
static constexpr std::string_view fieldNameAll = "*"sv
 Metrics name wildcard. More...
 
static constexpr std::array fieldUnitsAssociation = { KeyUnit{"bytes"sv, "bytes"sv}, KeyUnit{"packets"sv, "packets"sv}, KeyUnit{"compressed"sv, "packets"sv}, KeyUnit{"multicast"sv, "packets"sv} }
 Metric units associations. More...
 
static constexpr std::string_view defaultUnit = "errors"sv
 Metric unit. More...
 

Detailed Description

Sources of network metrics extracted from the file /proc/net/dev.

Definition at line 38 of file SourceProcNetDev.h.

Constructor & Destructor Documentation

◆ SourceProcNetDev()

MetroCollect::MetricsSource::SourceProcNetDev::SourceProcNetDev ( )
protected

Private default constructor.

Definition at line 28 of file SourceProcNetDev.cc.

Here is the call graph for this function:

Member Function Documentation

◆ allFieldsInfo()

const std::vector< FieldInfo > MetroCollect::MetricsSource::SourceProcNetDev::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 142 of file SourceProcNetDev.cc.

Here is the call graph for this function:

◆ computeDiff()

void MetroCollect::MetricsSource::SourceProcNetDev::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 183 of file SourceProcNetDev.cc.

◆ fetchData()

void MetroCollect::MetricsSource::SourceProcNetDev::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 152 of file SourceProcNetDev.cc.

Here is the call graph for this function:

◆ fieldCount()

size_t MetroCollect::MetricsSource::SourceProcNetDev::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 82 of file SourceProcNetDev.cc.

Here is the caller graph for this function:

◆ fieldInfoAtIndex()

const FieldInfo MetroCollect::MetricsSource::SourceProcNetDev::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 129 of file SourceProcNetDev.cc.

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

◆ fieldNameSourcePrefix()

const std::string MetroCollect::MetricsSource::SourceProcNetDev::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 125 of file SourceProcNetDev.cc.

◆ get()

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

Get the Instance object.

Definition at line 63 of file SourceProcNetDev.h.

◆ indexesOfFieldName()

const std::vector< size_t > MetroCollect::MetricsSource::SourceProcNetDev::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 86 of file SourceProcNetDev.cc.

◆ parseFields()

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

File parser function.

Definition at line 34 of file SourceProcNetDev.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::SourceProcNetDev::buffer_
protected

Buffer to put file contents into.

Definition at line 51 of file SourceProcNetDev.h.

◆ defaultUnit

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::defaultUnit = "errors"sv
staticprotected

Metric unit.

Definition at line 48 of file SourceProcNetDev.h.

◆ fieldNameAll

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::fieldNameAll = "*"sv
staticprotected

Metrics name wildcard.

Definition at line 46 of file SourceProcNetDev.h.

◆ fieldNameInterfaceDescription

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::fieldNameInterfaceDescription = "interface"sv
staticprotected

Metrics name category description.

Definition at line 43 of file SourceProcNetDev.h.

◆ fieldRecieve

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::fieldRecieve = "rx"sv
staticprotected

Metrics name category.

Definition at line 44 of file SourceProcNetDev.h.

◆ fieldTransmit

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::fieldTransmit = "tx"sv
staticprotected

Metrics name category.

Definition at line 45 of file SourceProcNetDev.h.

◆ fieldUnitsAssociation

constexpr std::array MetroCollect::MetricsSource::SourceProcNetDev::fieldUnitsAssociation = { KeyUnit{"bytes"sv, "bytes"sv}, KeyUnit{"packets"sv, "packets"sv}, KeyUnit{"compressed"sv, "packets"sv}, KeyUnit{"multicast"sv, "packets"sv} }
staticprotected

Metric units associations.

Definition at line 47 of file SourceProcNetDev.h.

◆ file_

std::ifstream MetroCollect::MetricsSource::SourceProcNetDev::file_
protected

File descriptor.

Definition at line 50 of file SourceProcNetDev.h.

◆ filePath

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::filePath = "/proc/1/net/dev"sv
staticprotected

Network metrics file path.

Definition at line 40 of file SourceProcNetDev.h.

◆ interfaces_

std::vector<std::string> MetroCollect::MetricsSource::SourceProcNetDev::interfaces_
protected

Network interfaces names.

Definition at line 52 of file SourceProcNetDev.h.

◆ rxFieldNames_

std::vector<std::string> MetroCollect::MetricsSource::SourceProcNetDev::rxFieldNames_
protected

Reception metric names.

Definition at line 53 of file SourceProcNetDev.h.

◆ sourcePrefix

constexpr std::string_view MetroCollect::MetricsSource::SourceProcNetDev::sourcePrefix = "network"sv
staticprotected

Metrics name source prefix.

Definition at line 42 of file SourceProcNetDev.h.

◆ txFieldNames_

std::vector<std::string> MetroCollect::MetricsSource::SourceProcNetDev::txFieldNames_
protected

Transmission metric names.

Definition at line 54 of file SourceProcNetDev.h.


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