Commit 55fbc652 authored by Alessio Netti's avatar Alessio Netti
Browse files

Fixes to ProcFS HT aggregation

- Fixed a couple minor bugs arising when only one column is selected
in the stat file
- Fixed a bug in the SAR parser
parent 5e727ec0
......@@ -153,6 +153,7 @@ bool MeminfoParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, st
ProcLine line;
line.cpuID = -1;
line.columns = 1;
line.multi = false;
// Closing and re-opening a ProcFS file at each sampling time incurs overhead, but solves issues with certain
// files not showing updated values
......@@ -384,6 +385,7 @@ bool ProcstatParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, s
line.skip = parsedCols==0;
line.cpuID = currCPU;
line.columns = parsedCols;
line.multi = true;
line.dest = _sensors->size()-parsedCols;
}
// If the metric is not cpu core-related, it is simply pushed to the _metricsNames vector
......@@ -402,6 +404,7 @@ bool ProcstatParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, s
_numInternalMetrics++;
}
line.columns = 1;
line.multi = false;
line.cpuID = -1;
line.dest = _sensors->size()-1;
}
......@@ -454,7 +457,7 @@ bool ProcstatParser::_readMetrics() {
// First token is discarded, represents the metric's name
if (lineToken == NULL) return false;
// We check whether the line is CPU core-related or not (see _readNames)
if (_l->columns>1) {
if (_l->multi) {
colCtr = 0;
parsedCols = 0;
// We iterate over the line and capture all of the CPU core-related metrics
......@@ -519,9 +522,9 @@ bool SARParser::_readMetrics() {
if ( _readings == NULL ) {
_readings = new std::vector<reading_t>(_numMetrics);
_columnRawReadings = new unsigned long long[DEFAULTMETRICS * _lines.size()]();
int accumSize = _htAggr ? _numCPUs%_htVal + 1 : _numCPUs + 1;
int accumSize = _htAggr ? _htVal + 1 : _numCPUs + 1;
_accumulators = new unsigned long long[accumSize]();
for(int idx=0; idx<=accumSize; idx++) _accumulators[idx] = 1;
for(int idx=0; idx<accumSize; idx++) _accumulators[idx] = 1;
}
//fseek(_metricsFile, 0, SEEK_SET);
......@@ -546,7 +549,7 @@ bool SARParser::_readMetrics() {
// First token is discarded, represents the metric's name
if(lineToken == NULL) return false;
// We check whether the line is CPU core-related or not (see _readNames)
if(_l->columns>1) {
if(_l->multi) {
colCtr = 0;
parsedCols = 0;
accIdx = (_htAggr && _l->cpuID>=0) ? _l->cpuID%_htVal + 1 : _l->cpuID + 1;
......@@ -583,7 +586,7 @@ bool SARParser::_readMetrics() {
// Computing percentages in SAR style
for(auto& l : _lines)
if(!l.skip && l.columns>1 && (!_htAggr || l.cpuID<_htVal)) {
if(!l.skip && l.multi && (!_htAggr || l.cpuID<_htVal)) {
for (colCtr = 0; colCtr < (unsigned)l.columns; colCtr++)
_readings->at(l.dest + colCtr).value = _readings->at(l.dest + colCtr).value * 1000 / _accumulators[l.cpuID + 1];
_accumulators[l.cpuID + 1] = 1;
......
......@@ -29,6 +29,7 @@ public:
struct ProcLine {
bool skip;
bool multi;
char columns;
int dest;
int cpuID;
......
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