Commit 88f3104f authored by Alessio Netti's avatar Alessio Netti
Browse files

PrintConfig functionality added to Data Analytics Framework

- Added some more indentation to make the configurations more readable
- Fixed one more warning in dcdbquery
parent abf6af19
...@@ -193,5 +193,5 @@ void MSRSensorGroup::printConfig(LOG_LEVEL ll) { ...@@ -193,5 +193,5 @@ void MSRSensorGroup::printConfig(LOG_LEVEL ll) {
separator = ", "; separator = ", ";
} }
LOG_VAR(ll) << " CPUs: " << ss.str(); LOG_VAR(ll) << " CPUs: " << ss.str();
} }
...@@ -65,7 +65,8 @@ public: ...@@ -65,7 +65,8 @@ public:
void setCounterData(int counterData) { _counterData = static_cast<PORT_COUNTER_DATA>(counterData); } void setCounterData(int counterData) { _counterData = static_cast<PORT_COUNTER_DATA>(counterData); }
void printConfig(LOG_LEVEL ll, LOGGER& lg) { void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
std::string cntData("unknown"); std::string cntData("unknown");
switch (_counterData) { switch (_counterData) {
case portXmitData: case portXmitData:
...@@ -150,7 +151,7 @@ public: ...@@ -150,7 +151,7 @@ public:
cntData = "uncorrectableErrors"; cntData = "uncorrectableErrors";
break; break;
} }
LOG_VAR(ll) << " Counter data: " << cntData; LOG_VAR(ll) << leading << " Counter data: " << cntData;
} }
protected: protected:
......
...@@ -199,6 +199,6 @@ void OpaSensorGroup::readAsync() { ...@@ -199,6 +199,6 @@ void OpaSensorGroup::readAsync() {
} }
void OpaSensorGroup::printConfig(LOG_LEVEL ll) { void OpaSensorGroup::printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " HFI Num: " << _hfiNum; LOG_VAR(ll) << " HFI Num: " << _hfiNum;
LOG_VAR(ll) << " Port Num: " << _portNum; LOG_VAR(ll) << " Port Num: " << _portNum;
} }
...@@ -106,8 +106,9 @@ public: ...@@ -106,8 +106,9 @@ public:
} }
} }
void printConfig(LOG_LEVEL ll, LOGGER& lg) { void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
LOG_VAR(ll) << " XML Path: " << getXMLPathString(); std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << " XML Path: " << getXMLPathString();
} }
protected: protected:
......
...@@ -152,9 +152,9 @@ void PDUSensorGroup::readAsync() { ...@@ -152,9 +152,9 @@ void PDUSensorGroup::readAsync() {
void PDUSensorGroup::printConfig(LOG_LEVEL ll) { void PDUSensorGroup::printConfig(LOG_LEVEL ll) {
if (_pdu) { if (_pdu) {
LOG_VAR(ll) << " PDU Unit: " << _pdu->getHost(); LOG_VAR(ll) << " PDU Unit: " << _pdu->getHost();
} else { } else {
LOG_VAR(ll) << " No Host set!"; LOG_VAR(ll) << " No Host set!";
} }
LOG_VAR(ll) << " Request: " << _request; LOG_VAR(ll) << " Request: " << _request;
} }
...@@ -44,9 +44,10 @@ public: ...@@ -44,9 +44,10 @@ public:
void setType(unsigned type) { _type = type; } void setType(unsigned type) { _type = type; }
void setConfig(unsigned config) { _config = config; } void setConfig(unsigned config) { _config = config; }
void printConfig(LOG_LEVEL ll, LOGGER& lg) { void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
LOG_VAR(ll) << " Type: " << _type; std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << " Config: " << _config; LOG_VAR(ll) << leading << " Type: " << _type;
LOG_VAR(ll) << leading << " Config: " << _config;
} }
protected: protected:
......
...@@ -275,9 +275,9 @@ uint64_t PerfSensorGroup::calculateIntervalValue(uint64_t previous, uint64_t cur ...@@ -275,9 +275,9 @@ uint64_t PerfSensorGroup::calculateIntervalValue(uint64_t previous, uint64_t cur
void PerfSensorGroup::printConfig(LOG_LEVEL ll) { void PerfSensorGroup::printConfig(LOG_LEVEL ll) {
if (_sensorGroupLeader) { if (_sensorGroupLeader) {
LOG_VAR(ll) << " This is a Leader Group"; LOG_VAR(ll) << " This is a Leader Group";
} else { } else {
LOG_VAR(ll) << " This is a Non-Leader Group"; LOG_VAR(ll) << " This is a Non-Leader Group";
} }
LOG_VAR(ll) << " CPU Id: " << _cpuId; LOG_VAR(ll) << " CPU Id: " << _cpuId;
} }
...@@ -47,14 +47,11 @@ public: ...@@ -47,14 +47,11 @@ public:
void setCPUId(int i) { this->_cpuId = i; } void setCPUId(int i) { this->_cpuId = i; }
int getCPUId() { return this->_cpuId; } int getCPUId() { return this->_cpuId; }
void printConfig(LOG_LEVEL ll, LOGGER& lg) { void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
LOG_VAR(ll) << " Metric: " << _metric; std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << " CPU Id: " << _cpuId; LOG_VAR(ll) << leading << " Metric: " << _metric;
if (_perCPU) { LOG_VAR(ll) << leading << " CPU Id: " << _cpuId;
LOG_VAR(ll) << " perCPU: true"; LOG_VAR(ll) << leading << " PerCPU: " << (_perCPU ? "enabled" : "disabled");
} else {
LOG_VAR(ll) << " perCPU: false";
}
} }
protected: protected:
......
...@@ -148,11 +148,11 @@ void ProcfsSensorGroup::readAsync() { ...@@ -148,11 +148,11 @@ void ProcfsSensorGroup::readAsync() {
void ProcfsSensorGroup::printConfig(LOG_LEVEL ll) { void ProcfsSensorGroup::printConfig(LOG_LEVEL ll) {
if (_parser) { if (_parser) {
LOG_VAR(ll) << " Parser set"; LOG_VAR(ll) << " Parser set";
} else { } else {
LOG_VAR(ll) << " No Parser set!"; LOG_VAR(ll) << " No Parser set!";
} }
LOG_VAR(ll) << " Type: " << _type; LOG_VAR(ll) << " Type: " << _type;
LOG_VAR(ll) << " Path: " << _path; LOG_VAR(ll) << " Path: " << _path;
LOG_VAR(ll) << " MQTT start: " << _mqttStart; LOG_VAR(ll) << " MQTT start: " << _mqttStart;
} }
...@@ -67,8 +67,9 @@ public: ...@@ -67,8 +67,9 @@ public:
} }
const std::string getOIDSuffix() const { return _oidSuffix; } const std::string getOIDSuffix() const { return _oidSuffix; }
void printConfig(LOG_LEVEL ll, LOGGER& lg) { void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
LOG_VAR(ll) << " OID: " << getOIDString(); std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << " OID: " << getOIDString();
} }
......
...@@ -88,8 +88,8 @@ void SNMPSensorGroup::readAsync() { ...@@ -88,8 +88,8 @@ void SNMPSensorGroup::readAsync() {
void SNMPSensorGroup::printConfig(LOG_LEVEL ll) { void SNMPSensorGroup::printConfig(LOG_LEVEL ll) {
if (_connection) { if (_connection) {
LOG_VAR(ll) << " Connection: " << _connection->getHost(); LOG_VAR(ll) << " Connection: " << _connection->getHost();
} else { } else {
LOG_VAR(ll) << " No Connection set!"; LOG_VAR(ll) << " No Connection set!";
} }
} }
...@@ -64,12 +64,13 @@ public: ...@@ -64,12 +64,13 @@ public:
void setRegex(boost::regex regx) { _regx = regx; } void setRegex(boost::regex regx) { _regx = regx; }
void setSubstitution(const std::string& substitution) { _substitution = substitution; } void setSubstitution(const std::string& substitution) { _substitution = substitution; }
void printConfig(LOG_LEVEL ll, LOGGER& lg) { void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) {
std::string leading(leadingSpaces, ' ');
if (_filter) { if (_filter) {
LOG_VAR(ll) << " Using regular expression as filter"; LOG_VAR(ll) << leading << " Using regular expression as filter";
LOG_VAR(ll) << " Substitution: " << _substitution; LOG_VAR(ll) << leading << " Substitution: " << _substitution;
} else { } else {
LOG_VAR(ll) << " Not using any filter"; LOG_VAR(ll) << leading << " Not using any filter";
} }
} }
......
...@@ -119,5 +119,5 @@ void SysfsSensorGroup::readAsync() { ...@@ -119,5 +119,5 @@ void SysfsSensorGroup::readAsync() {
} }
void SysfsSensorGroup::printConfig(LOG_LEVEL ll) { void SysfsSensorGroup::printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " File path: " << _path; LOG_VAR(ll) << " File path: " << _path;
} }
...@@ -16,7 +16,7 @@ public: ...@@ -16,7 +16,7 @@ public:
TesterSensorBase(const std::string& name) : SensorBase(name) {} TesterSensorBase(const std::string& name) : SensorBase(name) {}
virtual ~TesterSensorBase() {} virtual ~TesterSensorBase() {}
void printConfig(LOG_LEVEL ll, LOGGER& lg) { /* nothing to print */ } void printConfig(LOG_LEVEL ll, LOGGER& lg, unsigned leadingSpaces=16) { /* nothing to print */ }
}; };
#endif /* TESTER_TESTERSENSORBASE_H_ */ #endif /* TESTER_TESTERSENSORBASE_H_ */
...@@ -83,7 +83,7 @@ void TesterSensorGroup::readAsync() { ...@@ -83,7 +83,7 @@ void TesterSensorGroup::readAsync() {
} }
void TesterSensorGroup::printConfig(LOG_LEVEL ll) { void TesterSensorGroup::printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " Value: " << _value; LOG_VAR(ll) << " Value: " << _value;
LOG_VAR(ll) << " Num Sensors: " << _numSensors; LOG_VAR(ll) << " Num Sensors: " << _numSensors;
LOG_VAR(ll) << " MQTT start: " << _mqttStart; LOG_VAR(ll) << " MQTT start: " << _mqttStart;
} }
...@@ -106,7 +106,7 @@ void DCDBQuery::genOutput(std::list<DCDB::SensorDataStoreReading> &results, quer ...@@ -106,7 +106,7 @@ void DCDBQuery::genOutput(std::list<DCDB::SensorDataStoreReading> &results, quer
} }
std::cout << std::endl; std::cout << std::endl;
int64_t prevValue; int64_t prevValue=0;
DCDB::TimeStamp prevT((uint64_t) 0); DCDB::TimeStamp prevT((uint64_t) 0);
for (std::list<DCDB::SensorDataStoreReading>::iterator reading = results.begin(); reading != results.end(); reading++) { for (std::list<DCDB::SensorDataStoreReading>::iterator reading = results.begin(); reading != results.end(); reading++) {
int64_t value = (*reading).value; int64_t value = (*reading).value;
......
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