Commit c94e3e18 authored by Alessio Netti's avatar Alessio Netti
Browse files

Minor changes to NVML plugin

- Fixing warnings here and there
parent ffc43863
...@@ -72,11 +72,14 @@ nvmlSensorGroup& nvmlSensorGroup::operator=(const nvmlSensorGroup& other) { ...@@ -72,11 +72,14 @@ nvmlSensorGroup& nvmlSensorGroup::operator=(const nvmlSensorGroup& other) {
} }
void nvmlSensorGroup::execOnInit() { void nvmlSensorGroup::execOnInit() {
nvmlReturn_t err; nvmlReturn_t err;
err = nvmlInit(); err = nvmlInit();
err = nvmlDeviceGetHandleByIndex(0,&(env.device)); err = nvmlDeviceGetHandleByIndex(0,&(env.device));
err = nvmlDeviceGetTotalEnergyConsumption(env.device,&(counters.energy_initial)); err = nvmlDeviceGetTotalEnergyConsumption(env.device,&(counters.energy_initial));
if(err != NVML_SUCCESS) {
LOG(warning) << "Sensorgroup " << _groupName << ": NVML error during initialization!";
}
} }
bool nvmlSensorGroup::execOnStart() { bool nvmlSensorGroup::execOnStart() {
...@@ -92,7 +95,7 @@ void nvmlSensorGroup::read() { ...@@ -92,7 +95,7 @@ void nvmlSensorGroup::read() {
reading_t reading; reading_t reading;
reading.timestamp = getTimestamp(); reading.timestamp = getTimestamp();
reading.value = 0; reading.value = 0;
nvmlReturn_t err; nvmlReturn_t err = NVML_SUCCESS;
unsigned long long temp; unsigned long long temp;
try { try {
for(auto s : _sensors) { for(auto s : _sensors) {
...@@ -173,14 +176,14 @@ void nvmlSensorGroup::read() { ...@@ -173,14 +176,14 @@ void nvmlSensorGroup::read() {
if(err == NVML_SUCCESS) { if(err == NVML_SUCCESS) {
s->storeReading(reading); s->storeReading(reading);
} else { } else {
LOG(error) << "Sensorgroup" << _groupName << " could not read " << s->getName() << ": NVML error!"; LOG(error) << "Sensorgroup " << _groupName << " could not read " << s->getName() << ": NVML error!";
} }
#ifdef DEBUG #ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\""; LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
#endif #endif
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
LOG(error) << "Sensorgroup" << _groupName << " could not read value: " << e.what(); LOG(error) << "Sensorgroup " << _groupName << " could not read value: " << e.what();
} }
} }
......
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