Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
d7c31f24
Commit
d7c31f24
authored
Jun 10, 2020
by
Alessio Netti
Browse files
ProcFS: better logging when checking CPU sets
parent
87ef2d25
Changes
5
Hide whitespace changes
Inline
Side-by-side
dcdbpusher/sensors/procfs/ProcfsConfigurator.cpp
View file @
d7c31f24
...
...
@@ -124,6 +124,5 @@ void ProcfsConfigurator::sensorGroup(ProcfsSensorGroup &sGroup, CFG_VAL config)
LOG
(
debug
)
<<
" Number of metrics found: "
<<
numMetrics
;
// We assign the final sensor objects as parsed in the target file, and assign the parser object
sGroup
.
replaceSensors
(
parser
->
getSensors
());
sGroup
.
setParser
(
parser
);
}
dcdbpusher/sensors/procfs/ProcfsParser.cpp
View file @
d7c31f24
...
...
@@ -167,6 +167,7 @@ std::vector<ureading_t> *ProcfsParser::readSensors() {
* @return true if successful, false otherwise
*/
bool
MeminfoParser
::
_readNames
(
std
::
map
<
std
::
string
,
ProcfsSBPtr
>
*
sensorMap
,
std
::
set
<
int
>
*
cpuSet
)
{
_foundCPUs
.
clear
();
if
(
_sensors
==
NULL
)
{
bool
memUsedEnabled
=
sensorMap
!=
NULL
&&
!
sensorMap
->
empty
()
&&
sensorMap
->
find
(
_memUsedToken
)
!=
sensorMap
->
end
();
_memFreeLine
=
-
1
;
...
...
@@ -333,6 +334,7 @@ bool MeminfoParser::_readMetrics() {
* @return true if successful, false otherwise
*/
bool
ProcstatParser
::
_readNames
(
std
::
map
<
std
::
string
,
ProcfsSBPtr
>
*
sensorMap
,
std
::
set
<
int
>
*
cpuSet
)
{
_foundCPUs
.
clear
();
if
(
_sensors
==
NULL
)
{
_numMetrics
=
0
;
_numInternalMetrics
=
0
;
...
...
@@ -419,6 +421,8 @@ bool ProcstatParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, s
}
colCtr
++
;
}
if
(
currCPU
!=-
1
)
_foundCPUs
.
insert
(
currCPU
);
}
// The line is flagged as skippable if no columns should be read from it. This can happen in two cases:
// - The cpu in said line is not part of the input CPU set
...
...
dcdbpusher/sensors/procfs/ProcfsParser.h
View file @
d7c31f24
...
...
@@ -65,6 +65,7 @@ class ProcfsParser {
virtual
void
close
();
// Setters and getters
std
::
set
<
int
>&
getFoundCPUs
()
{
return
_foundCPUs
;
}
std
::
string
getPath
()
{
return
_path
;
}
int
getHtVal
()
{
return
_htVal
;
}
unsigned
int
getNumMetrics
()
{
return
_numMetrics
;
}
...
...
@@ -104,18 +105,19 @@ class ProcfsParser {
std
::
vector
<
char
>
_skipColumn
;
// Internal variables
bool
_initialized
;
uint64_t
_scalingFactor
;
unsigned
int
_cacheIndex
;
unsigned
int
_numMetrics
;
unsigned
int
_numInternalMetrics
;
unsigned
int
_numCPUs
;
int
_htVal
;
bool
_htAggr
;
std
::
string
_path
;
FILE
*
_metricsFile
;
char
*
_stringBuffer
;
size_t
_chars_read
;
std
::
set
<
int
>
_foundCPUs
;
bool
_initialized
;
uint64_t
_scalingFactor
;
unsigned
int
_cacheIndex
;
unsigned
int
_numMetrics
;
unsigned
int
_numInternalMetrics
;
unsigned
int
_numCPUs
;
int
_htVal
;
bool
_htAggr
;
std
::
string
_path
;
FILE
*
_metricsFile
;
char
*
_stringBuffer
;
size_t
_chars_read
;
// C string containing the delimiters used to split single lines during parsing
const
char
*
LINE_SEP
;
};
...
...
dcdbpusher/sensors/procfs/ProcfsSensorGroup.cpp
View file @
d7c31f24
...
...
@@ -54,21 +54,25 @@ ProcfsSensorGroup::~ProcfsSensorGroup() {
}
/**
*
Replaces all sensor objects stored in the group with those contained in newSensor
s
*
Assigns a new parser and replaces the internal sensor object
s
*
* Old sensors are deleted and cleared, therefore make sure th
at newSensors
does not contain any object previously used
* Old sensors are deleted and cleared, therefore make sure th
e parser
does not contain any object previously used
* by the sensor group.
*
* @param
newSensors: Vector of ProcfsSensorBa
se object
s to replace the old set
* @param
parser: Pointer to a ProcfsPar
se
r
object
*
*/
void
ProcfsSensorGroup
::
replaceSensors
(
std
::
vector
<
ProcfsSBPtr
>
*
newSensors
)
{
void
ProcfsSensorGroup
::
setParser
(
ProcfsParser
*
parser
)
{
if
(
parser
)
_parser
=
parser
;
else
return
;
std
::
set
<
std
::
string
>
sensorSet
=
std
::
set
<
std
::
string
>
();
std
::
set
<
int
>
effCpuSet
;
for
(
const
auto
&
s_new
:
*
newSensors
)
{
for
(
const
auto
&
s_new
:
*
parser
->
getSensors
())
{
sensorSet
.
insert
(
s_new
->
getMetric
());
effCpuSet
.
insert
(
s_new
->
getCPUId
());
}
std
::
set
<
int
>
&
effCpuSet
=
parser
->
getFoundCPUs
();
for
(
const
auto
&
s
:
_sensors
)
if
(
sensorSet
.
find
(
s
->
getMetric
())
==
sensorSet
.
end
())
...
...
@@ -81,7 +85,7 @@ void ProcfsSensorGroup::replaceSensors(std::vector<ProcfsSBPtr> *newSensors) {
effCpuSet
.
clear
();
_sensors
.
clear
();
_baseSensors
.
clear
();
for
(
auto
s
:
*
new
Sensors
)
for
(
auto
s
:
*
parser
->
get
Sensors
()
)
pushBackSensor
(
std
::
make_shared
<
ProcfsSensorBase
>
(
*
s
));
}
...
...
dcdbpusher/sensors/procfs/ProcfsSensorGroup.h
View file @
d7c31f24
...
...
@@ -57,8 +57,8 @@ class ProcfsSensorGroup : public SensorGroupTemplate<ProcfsSensorBase> {
bool
execOnStart
()
final
override
;
// Setters and getters
void
setParser
(
ProcfsParser
*
parser
);
void
setHtVal
(
int
htVal
)
{
this
->
_htVal
=
htVal
;
}
void
setParser
(
ProcfsParser
*
parser
)
{
this
->
_parser
=
parser
;
}
void
setType
(
std
::
string
t
)
{
this
->
_type
=
t
;
}
void
setPath
(
std
::
string
p
)
{
this
->
_path
=
p
;
}
void
setCpuSet
(
std
::
set
<
int
>
s
)
{
this
->
_cpuSet
=
s
;
}
...
...
@@ -73,9 +73,7 @@ class ProcfsSensorGroup : public SensorGroupTemplate<ProcfsSensorBase> {
std
::
string
getPath
()
{
return
this
->
_path
;
}
std
::
set
<
int
>
*
getCpuSet
()
{
return
&
this
->
_cpuSet
;
}
uint64_t
getScalingFactor
()
{
return
this
->
_scalingFactor
;
}
void
replaceSensors
(
std
::
vector
<
ProcfsSBPtr
>
*
newSensors
);
void
printGroupConfig
(
LOG_LEVEL
ll
,
unsigned
leadingSpaces
=
16
)
final
override
;
private:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment