AnyCollect  1.1.2
AnyCollect::Controller Class Reference

#include <Controller.h>

Collaboration diagram for AnyCollect::Controller:

Public Member Functions

 Controller (ControllerDelegate &delegate) noexcept
 Construct a new Controller object. More...
 
ControllerDelegatedelegate () const noexcept
 Returns the controller's delegate. More...
 
bool isCollecting () const noexcept
 Returns whether the controller is collecting metrics. More...
 
std::chrono::seconds samplingInterval () const noexcept
 Returns the metrics sampling interval. More...
 
void loadConfigFromFile (const std::string &configPath)
 Configures sources, expressions and matchers according to config file. More...
 
void setSamplingInterval (std::chrono::seconds interval) noexcept
 Sets the metrics sampling interval. More...
 
std::vector< const Metric * > availableMetrics () noexcept
 Returns the array of all currently matching metrics on the system, without their values. More...
 
void collectMetrics () noexcept
 Launch metric collection loop. More...
 

Static Public Attributes

static constexpr std::chrono::seconds defaultSamplingInterval = 10s
 Default parameter option. More...
 

Protected Member Functions

void updateSources () noexcept
 Updates sources (fetches file contents and executes commands) More...
 
void computeMatches () noexcept
 For each line of each source, executes the source's expressions to find matches. More...
 
void parseData (const Source &source, const std::cmatch &match, const Matcher &matcher) noexcept
 Updates metrics from a match. More...
 

Protected Attributes

ControllerDelegatedelegate_
 Delegate to alert when something happens. More...
 
bool isCollecting_
 Whether the receiver is collecting metrics. More...
 
std::chrono::seconds samplingInterval_
 Metrics sampling interval. More...
 
double unitsPerSecondFactor_
 Factor to convert metric differences to units per second. More...
 
size_t roundKey_
 Metric collection iteration unique identifier. More...
 
std::vector< std::shared_ptr< Source > > sources_
 Array of sources. More...
 
std::vector< std::shared_ptr< Expression > > expressions_
 Array of expressions. More...
 
std::vector< std::shared_ptr< Matcher > > matchers_
 Array of matchers. More...
 
std::map< size_t, Metricmetrics_
 Map associating keys to their metric. More...
 
std::vector< const Metric * > updatedMetrics_
 Array of pointers to the iteration's metrics. More...
 

Detailed Description

Definition at line 43 of file Controller.h.

Constructor & Destructor Documentation

◆ Controller()

AnyCollect::Controller::Controller ( ControllerDelegate delegate)
noexcept

Construct a new Controller object.

Parameters
delegatethe controller's delegate

Definition at line 32 of file Controller.cc.

Member Function Documentation

◆ availableMetrics()

std::vector< const Metric * > AnyCollect::Controller::availableMetrics ( )
noexcept

Returns the array of all currently matching metrics on the system, without their values.

Returns
metrics currently available on the system

Definition at line 108 of file Controller.cc.

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

◆ collectMetrics()

void AnyCollect::Controller::collectMetrics ( )
noexcept

Launch metric collection loop.

Definition at line 128 of file Controller.cc.

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

◆ computeMatches()

void AnyCollect::Controller::computeMatches ( )
protectednoexcept

For each line of each source, executes the source's expressions to find matches.

Definition at line 170 of file Controller.cc.

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

◆ delegate()

ControllerDelegate & AnyCollect::Controller::delegate ( ) const
noexcept

Returns the controller's delegate.

Definition at line 40 of file Controller.cc.

◆ isCollecting()

bool AnyCollect::Controller::isCollecting ( ) const
noexcept

Returns whether the controller is collecting metrics.

Definition at line 45 of file Controller.cc.

◆ loadConfigFromFile()

void AnyCollect::Controller::loadConfigFromFile ( const std::string &  configPath)

Configures sources, expressions and matchers according to config file.

Parameters
configPaththe config file path

Definition at line 54 of file Controller.cc.

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

◆ parseData()

void AnyCollect::Controller::parseData ( const Source source,
const std::cmatch &  match,
const Matcher matcher 
)
protectednoexcept

Updates metrics from a match.

Parameters
sourcethe Matcher's source
matchthe results of the expression's matching
matcherthe Matcher object to create a metric from

Definition at line 193 of file Controller.cc.

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

◆ samplingInterval()

std::chrono::seconds AnyCollect::Controller::samplingInterval ( ) const
noexcept

Returns the metrics sampling interval.

Definition at line 49 of file Controller.cc.

◆ setSamplingInterval()

void AnyCollect::Controller::setSamplingInterval ( std::chrono::seconds  interval)
noexcept

Sets the metrics sampling interval.

Definition at line 96 of file Controller.cc.

Here is the caller graph for this function:

◆ updateSources()

void AnyCollect::Controller::updateSources ( )
protectednoexcept

Updates sources (fetches file contents and executes commands)

Definition at line 165 of file Controller.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ defaultSamplingInterval

constexpr std::chrono::seconds AnyCollect::Controller::defaultSamplingInterval = 10s
static

Default parameter option.

Definition at line 48 of file Controller.h.

◆ delegate_

ControllerDelegate& AnyCollect::Controller::delegate_
protected

Delegate to alert when something happens.

Definition at line 52 of file Controller.h.

◆ expressions_

std::vector<std::shared_ptr<Expression> > AnyCollect::Controller::expressions_
protected

Array of expressions.

Definition at line 60 of file Controller.h.

◆ isCollecting_

bool AnyCollect::Controller::isCollecting_
protected

Whether the receiver is collecting metrics.

Definition at line 54 of file Controller.h.

◆ matchers_

std::vector<std::shared_ptr<Matcher> > AnyCollect::Controller::matchers_
protected

Array of matchers.

Definition at line 61 of file Controller.h.

◆ metrics_

std::map<size_t, Metric> AnyCollect::Controller::metrics_
protected

Map associating keys to their metric.

Definition at line 62 of file Controller.h.

◆ roundKey_

size_t AnyCollect::Controller::roundKey_
protected

Metric collection iteration unique identifier.

Definition at line 57 of file Controller.h.

◆ samplingInterval_

std::chrono::seconds AnyCollect::Controller::samplingInterval_
protected

Metrics sampling interval.

Definition at line 55 of file Controller.h.

◆ sources_

std::vector<std::shared_ptr<Source> > AnyCollect::Controller::sources_
protected

Array of sources.

Definition at line 59 of file Controller.h.

◆ unitsPerSecondFactor_

double AnyCollect::Controller::unitsPerSecondFactor_
protected

Factor to convert metric differences to units per second.

Definition at line 56 of file Controller.h.

◆ updatedMetrics_

std::vector<const Metric*> AnyCollect::Controller::updatedMetrics_
protected

Array of pointers to the iteration's metrics.

Definition at line 63 of file Controller.h.


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