The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

ProcfsSensorGroup.h 2.73 KB
Newer Older
Alessio Netti's avatar
Alessio Netti committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * ProcfsSensorGroup.h
 *
 *  Created on: 10.17.2018
 *      Author: Alessio Netti
 */

#ifndef PROCFSSENSORGROUP_H_
#define PROCFSSENSORGROUP_H_

#include "ProcfsParser.h"
#include "../../includes/SensorGroupTemplate.h"

/**
 *  The ProcfsSensorGroup manages all sensors related to metrics in the same file.
 *  This is done in order to reduce parsing overhead, as all metrics are sampled
 *  in one reading pass.
 *
 */
class ProcfsSensorGroup : public SensorGroupTemplate<ProcfsSensorBase> {
Alessio Netti's avatar
Alessio Netti committed
21

Alessio Netti's avatar
Alessio Netti committed
22
23
public:
    // Constructor and destructor
24
    ProcfsSensorGroup(const std::string& name) : SensorGroupTemplate(name) { this->_parser = NULL; this->_htVal=0; }
Alessio Netti's avatar
Alessio Netti committed
25
    ProcfsSensorGroup& operator=(const ProcfsSensorGroup& other);
Alessio Netti's avatar
Alessio Netti committed
26
    virtual ~ProcfsSensorGroup();
Alessio Netti's avatar
Alessio Netti committed
27
28
29
30
    
    // Methods inherited from SensorGroupTemplate
    void start()    override;
    void stop()     override;
Alessio Netti's avatar
Alessio Netti committed
31

Alessio Netti's avatar
Alessio Netti committed
32
    // Setters and getters
33
    void setHtVal(int htVal)              { this->_htVal = htVal; }
34
35
36
37
38
39
    void setParser(ProcfsParser *parser)  { this->_parser = parser; }
    void setType(std::string t)           { this->_type = t; }
    void setPath(std::string p)           { this->_path = p; }
    void setMqttStart(std::string m)      { this->_mqttStart = m; }
    void setCpuSet(std::set<int> s)       { this->_cpuSet = s; }

40
    int getHtVal()                        { return this->_htVal; }
41
42
43
44
45
    ProcfsParser *getParser()             { return this->_parser; }
    std::string getType()                 { return this->_type; }
    std::string getPath()                 { return this->_path; }
    std::string getMqttStart()            { return this->_mqttStart; }
    std::set<int> *getCpuSet()            { return &this->_cpuSet; }
Alessio Netti's avatar
Alessio Netti committed
46

Alessio Netti's avatar
Alessio Netti committed
47
    // Method to get the internal sensor vector used by the sensor group (different from getSensors)
48
    std::vector<ProcfsSBPtr>& getDerivedSensors() { return this->_sensors; }
49
    void replaceSensors(std::vector<ProcfsSBPtr> *newSensors);
Alessio Netti's avatar
Alessio Netti committed
50

51
52
    void printConfig(LOG_LEVEL ll) override;

Alessio Netti's avatar
Alessio Netti committed
53
54
55
56
private:
    // Methods inherited from SensorGroupTemplate
    void read()         override;
    void readAsync()    override;
Alessio Netti's avatar
Alessio Netti committed
57

Alessio Netti's avatar
Alessio Netti committed
58
59
60
61
    // ProcfsParser object to be used to extract metrics' values and names
    ProcfsParser *_parser;
    // Type of the ProcfsSensorGroup (i.e. vmstat, meminfo, procstat), currently unused
    std::string _type;
62
63
64
65
    // Path to the parsed file
    std::string _path;
    // Start MQTT part to use when building sensors automatically
    std::string _mqttStart;
66
67
    // Aggregation value for hyperthreading cores
    int _htVal;
68
69
    // Set of cpu ids read during configuration
    std::set<int> _cpuSet;
Alessio Netti's avatar
Alessio Netti committed
70

Alessio Netti's avatar
Alessio Netti committed
71
72
    std::vector<reading_t> *_readingVector;
    reading_t _readingBuffer;
Alessio Netti's avatar
Alessio Netti committed
73
74
};

75
76
using ProcfsSGPtr = std::shared_ptr<ProcfsSensorGroup>;

Alessio Netti's avatar
Alessio Netti committed
77
#endif /* PROCFSSENSORGROUP_H_ */