ProcfsSensorGroup.h 3.78 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//================================================================================
// Name        : ProcfsSensorGroup.h
// Author      : Alessio Netti
// Copyright   : Leibniz Supercomputing Centre
// Description : Header file for Procfs sensor group class.
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2018-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//================================================================================
Alessio Netti's avatar
Alessio Netti committed
26
27
28
29
30
31
32
33

#ifndef PROCFSSENSORGROUP_H_
#define PROCFSSENSORGROUP_H_

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

/**
34
 * @brief SensorGroupTemplate specialization for this plugin.
Alessio Netti's avatar
Alessio Netti committed
35
 *
36
37
38
 * @details 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.
Alessio Netti's avatar
Alessio Netti committed
39
 *
40
 * @ingroup procfs
Alessio Netti's avatar
Alessio Netti committed
41
42
 */
class ProcfsSensorGroup : public SensorGroupTemplate<ProcfsSensorBase> {
Alessio Netti's avatar
Alessio Netti committed
43

Alessio Netti's avatar
Alessio Netti committed
44
45
public:
    // Constructor and destructor
46
    ProcfsSensorGroup(const std::string& name) : SensorGroupTemplate(name) { this->_parser = NULL; this->_htVal=0; }
Alessio Netti's avatar
Alessio Netti committed
47
    ProcfsSensorGroup& operator=(const ProcfsSensorGroup& other);
Alessio Netti's avatar
Alessio Netti committed
48
    virtual ~ProcfsSensorGroup();
Alessio Netti's avatar
Alessio Netti committed
49
50
    
    // Methods inherited from SensorGroupTemplate
51
    bool execOnStart() final override;
Alessio Netti's avatar
Alessio Netti committed
52

Alessio Netti's avatar
Alessio Netti committed
53
    // Setters and getters
54
    void setHtVal(int htVal)              { this->_htVal = htVal; }
55
56
57
58
59
    void setParser(ProcfsParser *parser)  { this->_parser = parser; }
    void setType(std::string t)           { this->_type = t; }
    void setPath(std::string p)           { this->_path = p; }
    void setCpuSet(std::set<int> s)       { this->_cpuSet = s; }

60
    int getHtVal()                        { return this->_htVal; }
61
62
63
64
    ProcfsParser *getParser()             { return this->_parser; }
    std::string getType()                 { return this->_type; }
    std::string getPath()                 { return this->_path; }
    std::set<int> *getCpuSet()            { return &this->_cpuSet; }
Alessio Netti's avatar
Alessio Netti committed
65

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

70
    void printGroupConfig(LOG_LEVEL ll) final override;
71

Alessio Netti's avatar
Alessio Netti committed
72
73
private:
    // Methods inherited from SensorGroupTemplate
74
    void read() final override;
Alessio Netti's avatar
Alessio Netti committed
75

Alessio Netti's avatar
Alessio Netti committed
76
77
78
79
    // 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;
80
81
    // Path to the parsed file
    std::string _path;
82
83
    // Aggregation value for hyperthreading cores
    int _htVal;
84
85
    // Set of cpu ids read during configuration
    std::set<int> _cpuSet;
Alessio Netti's avatar
Alessio Netti committed
86

87
88
    std::vector<ureading_t> *_readingVector;
    ureading_t _readingBuffer;
Alessio Netti's avatar
Alessio Netti committed
89
90
};

91
92
using ProcfsSGPtr = std::shared_ptr<ProcfsSensorGroup>;

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