ProcfsSensorGroup.h 3.62 KB
Newer Older
1
2
3
//================================================================================
// Name        : ProcfsSensorGroup.h
// Author      : Alessio Netti
Micha Müller's avatar
Micha Müller committed
4
// Contact     : info@dcdb.it
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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
27
28
29
30
31

#ifndef PROCFSSENSORGROUP_H_
#define PROCFSSENSORGROUP_H_

#include "../../includes/SensorGroupTemplate.h"
32
#include "ProcfsParser.h"
Alessio Netti's avatar
Alessio Netti committed
33
34

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

45
46
47
48
49
50
      public:
	// Constructor and destructor
	ProcfsSensorGroup(const std::string &name)
	    : SensorGroupTemplate(name) {
		_parser = NULL;
		_htVal = 0;
51
		_sarMax = 1000000;
52
53
54
55
56
57
	}
	ProcfsSensorGroup &operator=(const ProcfsSensorGroup &other);
	virtual ~ProcfsSensorGroup();

	// Methods inherited from SensorGroupTemplate
	bool execOnStart() final override;
Alessio Netti's avatar
Alessio Netti committed
58

59
	// Setters and getters
60
	void setParser(ProcfsParser *parser);
61
62
63
64
	void setHtVal(int htVal) { this->_htVal = htVal; }
	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; }
65
	void setSarMax(uint64_t sf) {
66
		if (sf > 0)
67
			this->_sarMax = sf;
68
	}
69

70
71
72
73
74
	int            getHtVal() { return this->_htVal; }
	ProcfsParser * getParser() { return this->_parser; }
	std::string    getType() { return this->_type; }
	std::string    getPath() { return this->_path; }
	std::set<int> *getCpuSet() { return &this->_cpuSet; }
75
	uint64_t       getSarMax() { return this->_sarMax; }
76
	
77
	void printGroupConfig(LOG_LEVEL ll, unsigned leadingSpaces = 16) final override;
78

79
80
81
      private:
	// Methods inherited from SensorGroupTemplate
	void read() final override;
Alessio Netti's avatar
Alessio Netti committed
82

83
84
85
86
87
88
89
90
91
92
93
	// 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;
	// Path to the parsed file
	std::string _path;
	// Aggregation value for hyperthreading cores
	int _htVal;
	// Set of cpu ids read during configuration
	std::set<int> _cpuSet;
	// Scaling factor to be used for ratio metrics
94
	uint64_t _sarMax;
Alessio Netti's avatar
Alessio Netti committed
95

96
97
	std::vector<ureading_t> *_readingVector;
	ureading_t               _readingBuffer;
Alessio Netti's avatar
Alessio Netti committed
98
99
};

100
101
using ProcfsSGPtr = std::shared_ptr<ProcfsSensorGroup>;

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