Commit 2a62c4b4 authored by Micha Mueller's avatar Micha Mueller
Browse files

Add new config-option to IPMI-plugin: factor

parent 4700fd8c
......@@ -195,6 +195,7 @@ hosts {
sensor recordSens {
recordId 4321
factor 1.5
mqttsuffix 11223345
}
......@@ -207,7 +208,7 @@ hosts {
}
}
```
Explanation of the values specific for the PDU plugin:
Explanation of the values specific for the IPMI plugin:
| Value                   | Explanation |
|:----- |:----------- |
......@@ -220,6 +221,7 @@ Explanation of the values specific for the PDU plugin:
| start | Required if raw command is sent
| stop | Required if raw command is sent
| recordId | Define the record-ID of the sensor to be read. One can look up the corresponding record-IDs for every sensor with the "ipmi-sensors" command line tool (ships with the freeipmi-library). Alternatively, one can define a raw IPMI-command (see above).
| factor | One can specify a factor to scale the read value before it is stored in the database (to adjust precision).
## Perf-event
......
......@@ -7,6 +7,7 @@ global {
templateSensors {
sensor energy {
; type raw
factor 0.001
interval 1000
cmd "0x00 0x2e 0x81 0x4d 0x4f 0x00 0x00 0x01 0x82 0x00 0x08"
start 5
......@@ -28,6 +29,7 @@ hosts {
sensor recordSens {
recordId 4321
factor 1000
mqttsuffix 11223345
}
}
......
......@@ -143,6 +143,8 @@ bool IPMIConfigurator::readSensor(DCDB::IPMISensor& sensor, boost::property_tree
sensor.setStop(stoi(val.second.data()));
} else if (boost::iequals(val.first, ("recordId"))) {
sensor.setRecordId(stoul(val.second.data()));
} else if (boost::iequals(val.first, ("factor"))) {
sensor.setFactor(std::stod(val.second.data()));
} else if (boost::iequals(val.first, "default")) {
//avoid unnecessary "Value not recognized" message
} else {
......@@ -153,6 +155,7 @@ bool IPMIConfigurator::readSensor(DCDB::IPMISensor& sensor, boost::property_tree
LOG(debug) << " MQTTSuffix:" << sensor.getMqtt();
LOG(debug) << " Interval : " << sensor.getInterval();
LOG(debug) << " minValues: " << sensor.getMinValues();
LOG(debug) << " factor : " << sensor.getFactor();
if (sensor.getRecordId() != 0) {
LOG(debug) << " RecordID : " << sensor.getRecordId();
} else {
......
......@@ -171,7 +171,7 @@ uint64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
return val;
}
uint64_t IPMIHost::readSensor_recordId(uint16_t recordId) {
double IPMIHost::readSensor_recordId(uint16_t recordId) {
if (!_ipmiCtx) {
try {
connect();
......
......@@ -24,7 +24,7 @@ namespace DCDB {
/* Send raw command to BMC. Returns sensor reading as responded by BMC. */
uint64_t sendRawCmd(const std::vector<uint8_t>& rawCmd, uint16_t start, uint16_t stop);
/* Read the sensor specified by its record id. Returns sensor reading. */
uint64_t readSensor_recordId(uint16_t recordId);
double readSensor_recordId(uint16_t recordId);
void increaseErrorCount();
const uint64_t getDelayFactor() const;
......
......@@ -26,6 +26,7 @@ namespace DCDB {
IPMISensor::IPMISensor(const std::string& name) :
Sensor(name) {
_recordId = 0;
_factor = 1;
_start = 0;
_stop = 0;
_host = NULL;
......@@ -40,9 +41,9 @@ namespace DCDB {
reading.timestamp = getTimestamp();
try {
if (_recordId != 0) { /* recordId was set */
reading.value = _host->readSensor_recordId(_recordId);
reading.value = _host->readSensor_recordId(_recordId) * _factor;
} else { /* use raw command */
reading.value = _host->sendRawCmd(_rawCmd, _start, _stop);
reading.value = _host->sendRawCmd(_rawCmd, _start, _stop) * _factor;
}
}
catch (const std::exception& e) {
......
......@@ -30,6 +30,14 @@ namespace DCDB {
return _recordId;
}
void setFactor(double factor) {
_factor = factor;
}
double getFactor() const {
return _factor;
}
uint8_t getStart() const {
return _start;
}
......@@ -66,6 +74,7 @@ namespace DCDB {
private:
uint16_t _recordId;
double _factor;
std::vector<uint8_t> _rawCmd;
uint8_t _start;
......
Supports Markdown
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