MSRSensorBase.h 2.62 KB
Newer Older
1
2
3
//================================================================================
// Name        : MSRSensorBase.h
// Author      : Carla Guillen
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 : Sensor base class for MSR plugin.
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2019-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.
//================================================================================
27

28
29
30
31
32
33
34
/**
 * @defgroup msr MSR plugin
 * @ingroup  pusherplugins
 *
 * @brief Retrieve data from model-specific registers (MSRs).
 */

35
36
37
#ifndef MSR_MSRSENSORBASE_H_
#define MSR_MSRSENSORBASE_H_

38
#include "sensorbase.h"
39

40
41
42
43
44
/**
 * @brief SensorBase specialization for this plugin.
 *
 * @ingroup msr
 */
45
class MSRSensorBase : public SensorBase {
46
      public:
47
48
49

	static constexpr uint64_t MSR_MAXIMUM_SIZE = 281474976710656; //2^48
	
50
51
52
53
	MSRSensorBase(const std::string &name)
	    : SensorBase(name), _cpu(0), _metric(0) {
		//default delta to true, as msr has only monotonic sensors usually
		_delta = true;
54
		_deltaMax = MSR_MAXIMUM_SIZE;
55
	}
56
57

	MSRSensorBase(const MSRSensorBase &other) = default;
58
59
60

	virtual ~MSRSensorBase() {
	}
61
62

	MSRSensorBase &operator=(const MSRSensorBase &other) = default;
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

	unsigned int getCpu() const {
		return _cpu;
	}

	void setCpu(unsigned int cpu) {
		_cpu = cpu;
	}

	uint64_t getMetric() const {
		return _metric;
	}

	void setMetric(uint64_t metric) {
		_metric = metric;
	}

80
81
82
83
84
	void printConfig(LOG_LEVEL ll, LOGGER &lg, unsigned leadingSpaces = 16) {
		std::string leading(leadingSpaces, ' ');
		LOG_VAR(ll) << leading << "    CPU:    " << _cpu;
		LOG_VAR(ll) << leading << "    Metric: " << _metric;
	}
85

86
      protected:
87
	unsigned int _cpu;
88
	uint64_t     _metric;
89
90
91
};

#endif /* MSR_MSRSENSORBASE_H_ */