Commit 966d4401 authored by lu43jih's avatar lu43jih

Fixing msr bugs

parent a6818d68
......@@ -6,6 +6,7 @@
*/
#include "MSRConfigurator.h"
#include <iomanip>
MSRConfigurator::MSRConfigurator() {
_groupName = "group";
......@@ -17,7 +18,9 @@ MSRConfigurator::~MSRConfigurator() {}
void MSRConfigurator::sensorBase(MSRSensorBase& s, CFG_VAL config) {
ADD {
if (boost::iequals(val.first, "metric")){
s.setMetric(std::stoull(val.second.data(),nullptr,16));
//TODO try catch...
uint64_t metric = std::stoull(val.second.data(),nullptr,16);
s.setMetric(metric);
}
}
}
......@@ -184,7 +187,11 @@ void MSRConfigurator::customizeAndStore(SG_Ptr g) {
} else {
for (auto s: original) {
auto s_otherCPUs = std::make_shared<MSRSensorBase>(s->getName());
s_otherCPUs->setName(s->getName(), cpu);
std::size_t found = s->getName().find_first_of(".");
if( found != std::string::npos){
found++; //to skip the point
s_otherCPUs->setName(s->getName().substr(found), cpu);
}
s_otherCPUs->setCpu(cpu);
s_otherCPUs->setMetric(s->getMetric());
auto size = s->getMqtt().size();
......
......@@ -42,9 +42,9 @@ public:
}
void printConfig(LOG_LEVEL ll, LOGGER& lg) {
LOG_VAR(ll) << " CPU: " << _cpu;
LOG_VAR(ll) << " Metric: " << _metric;
}
LOG_VAR(ll) << " CPU: " << _cpu;
LOG_VAR(ll) << " Metric: " << _metric;
}
protected:
unsigned int _cpu;
......
......@@ -42,8 +42,6 @@ void MSRSensorGroup::start() {
return;
}
program_fixed();
for (auto &kv : cpuToFd) {
int cpu = kv.first;
char * path = new char[200];
......@@ -62,6 +60,8 @@ void MSRSensorGroup::start() {
cpuToFd[cpu] = handle;
}
program_fixed();
_keepRunning = 1;
_pendingTasks++;
_timer->async_wait(std::bind(&MSRSensorGroup::readAsync, this));
......@@ -85,11 +85,13 @@ void MSRSensorGroup::read() {
try {
for(auto s : _sensors) {
msr_read(s->getMetric(), &reading.value, s->getCpu());
s->storeReading(reading);
auto ret_val = msr_read(s->getMetric(), &reading.value, s->getCpu());
if(ret_val != -1){
s->storeReading(reading);
#ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
#endif
}
}
} catch (const std::exception& e) {
LOG(error) << "Sensorgroup" << _groupName << " could not read value: " << e.what();
......@@ -136,6 +138,7 @@ void MSRSensorGroup::program_fixed(){
&& ctrl_reg.fields.usr1 && ctrl_reg.fields.os2
&& ctrl_reg.fields.usr2) {
//yes! Free running counters were set by someone else => we don't need to program them, just read them.
LOG(debug) << "CPU" << kv.first << " has free running counter, so there will be no fixed counter programming";
continue;
}
//not all of them (or none) are enabled => we program them again
......
......@@ -37,7 +37,7 @@ private:
void program_fixed();
std::map<unsigned int,int> cpuToFd;
int32_t msr_read(uint64_t msr_number, uint64_t * value, unsigned int cpu);
int32_t msr_read(uint64_t msr_number, uint64_t *value, unsigned int cpu);
int32_t msr_write(uint64_t msr_number, uint64_t value, unsigned int cpu);
};
......
Append to PLUGINS variable: msr
Append at end of Makefile:
libdcdbplugin_msr.$(LIBEXT): src/sensors/msr/MSRSensorGroup.o src/sensors/msr/MSRConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system
NOTE: Probably you will have to append further libraries to the linker for your plugin to compile
;comments in config files are indicated by a semicolon
global {
mqttPrefix /FF112233445566778899AABB
;add here other global attributes for your plugin
}
template_group def1 {
;define template groups by appending "template_"
interval 1000
minValues 3
groupAtt 1234
;add other attributes your plugin requires for a sensor group
;define sensors belonging to the group below
sensor temp1 {
sensorAtt 5678
;add other attributes your plugin requires for a sensor
}
}
single_sensor sens1 {
;if you want a group with only one sensor you can use a single_sensor
default temp1
mqttsuffix 0001
;add other attributes your plugin requires for a sensor
}
group g1 {
interval 1000
mqttprefix 01
default def1
;sensor temp1 is taken from def1 and does not need to be redefined
sensor gSens {
mqttsuffix 00
}
}
global {
mqttPrefix /FF112233445566778899AABBFFFF
;add here other global attributes for your plugin
}
group g1 {
interval 1000
mqttprefix 01
cpus 0-95
sensor Instructions {
mqttsuffix 00
metric 0x309
}
sensor Cycles {
mqttsuffix 01
metric 0x30A
}
sensor RefCycles {
mqttsuffix 02
metric 0x30B
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment