MetroCollect  2.3.4
MetroCollect::MetricsSource Namespace Reference

Namespace for sources of metrics objects and operations. More...

Namespaces

 DataArray
 Namespace holding MetricsDataArray iterator types for metric sources.
 
 DiffArray
 Namespace holding MetricsDiffArray iterator types for metric sources.
 

Classes

struct  FieldInfo
 Object used to describe a field (or metric) More...
 
struct  Interests
 Boolean array to keep track of which fields a source has to fetch metrics for. More...
 
struct  KeyUnit
 Stuct to associate a field name containing a certain key with a unit. More...
 
struct  MetricsSourceArray
 Simple struct to hold references to each source singleton. More...
 
class  SourceBase
 Singleton abstract class, base class of all metric sources classes. More...
 
class  SourceEthtool
 Sources of network metrics extracted from Ethtool interface. More...
 
class  SourceProcMeminfo
 Sources of memory metrics extracted from the file /proc/meminfo. More...
 
class  SourceProcNetDev
 Sources of network metrics extracted from the file /proc/net/dev. More...
 
class  SourceProcStat
 Sources of CPU metrics extracted from the file /proc/stat. More...
 

Typedefs

using FieldName = std::vector< std::string >
 Type used for field names (an array of strings) More...
 
using SourceInterests = std::shared_ptr< std::vector< MetricsSource::Interests > >
 Type used to store and share interests of multiple sources. More...
 

Functions

SourceInterests makeSourceInterests (bool value=false)
 Construct a new shared pointer to a SourceInterests object. More...
 
bool resetFile (std::ifstream &file, std::vector< char > &buffer, const std::string_view &path)
 Attempts to open a file and set buffer size accordingly. More...
 
bool readFile (std::ifstream &file, std::vector< char > &buffer, const std::string_view &path)
 Attempts to read file into buffer. More...
 
int alphanumCompare (const char *l, const char *r)
 Alphanumeric string comparison. More...
 
uint64_t parseUint (const char *&buffer) noexcept
 Fast and unsafe unsigned integer parser. More...
 
template<size_t N>
std::string findUnit (const std::string &name, const std::array< KeyUnit, N > &keyUnitAssociation, const std::string_view &defaultUnit)
 Tries to associate a field name with a unit, falling back on the default unit if none matches. More...
 

Detailed Description

Namespace for sources of metrics objects and operations.

Typedef Documentation

◆ FieldName

using MetroCollect::MetricsSource::FieldName = typedef std::vector<std::string>

Type used for field names (an array of strings)

Definition at line 31 of file SourceField.h.

◆ SourceInterests

using MetroCollect::MetricsSource::SourceInterests = typedef std::shared_ptr<std::vector<MetricsSource::Interests> >

Type used to store and share interests of multiple sources.

Definition at line 149 of file SourceInterests.h.

Function Documentation

◆ alphanumCompare()

int MetroCollect::MetricsSource::alphanumCompare ( const char *  l,
const char *  r 
)

Alphanumeric string comparison.

Inspired from http://www.davekoelle.com/alphanum.html

Parameters
lpointer to first character string
rpointer to second character string
Returns
negative value if l appears before r, in alphanumerical order
zero if both character sequences compare equivalent
positive value if l appears after r, in alphanumerical order

License

Released under the MIT License - https://opensource.org/licenses/MIT

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 70 of file SourceTools.cc.

Here is the caller graph for this function:

◆ findUnit()

template<size_t N>
std::string MetroCollect::MetricsSource::findUnit ( const std::string &  name,
const std::array< KeyUnit, N > &  keyUnitAssociation,
const std::string_view &  defaultUnit 
)

Tries to associate a field name with a unit, falling back on the default unit if none matches.

Template Parameters
NSize of the key/unit association array
Parameters
namefield name to find a unit for
keyUnitAssociationarray of keys and unit association. Keys are searched in the field name, the first match determines the key
defaultUnitdefault unit to use if no key matches
Returns
the best match unit

Definition at line 96 of file SourceTools.h.

Here is the caller graph for this function:

◆ makeSourceInterests()

SourceInterests MetroCollect::MetricsSource::makeSourceInterests ( bool  value = false)

Construct a new shared pointer to a SourceInterests object.

Parameters
valuethe default source interests value
Returns
the newly built shared pointer

Definition at line 33 of file MetricsSourceArray.cc.

Here is the caller graph for this function:

◆ parseUint()

uint64_t MetroCollect::MetricsSource::parseUint ( const char *&  buffer)
inlinenoexcept

Fast and unsafe unsigned integer parser.

Parameters
bufferreference to a character string buffer with an unsigned integer to parse
Returns
the parsed value

Definition at line 40 of file SourceTools.h.

Here is the caller graph for this function:

◆ readFile()

bool MetroCollect::MetricsSource::readFile ( std::ifstream &  file,
std::vector< char > &  buffer,
const std::string_view &  path 
)

Attempts to read file into buffer.

Parameters
filefile to open
bufferbuffer to read file into
pathfile path to read
Returns
true if file was read correctly
false otherwise

Definition at line 55 of file SourceTools.cc.

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

◆ resetFile()

bool MetroCollect::MetricsSource::resetFile ( std::ifstream &  file,
std::vector< char > &  buffer,
const std::string_view &  path 
)

Attempts to open a file and set buffer size accordingly.

Parameters
filefile to open
bufferbuffer to read file into
pathfile path to open
Returns
true if file was opened correctly
false otherwise

Definition at line 25 of file SourceTools.cc.

Here is the caller graph for this function: