Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
f8b30b59
Commit
f8b30b59
authored
Aug 13, 2018
by
Micha Mueller
Browse files
Rename PerfCounter --> PerfSensor
parent
381100b8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
f8b30b59
...
...
@@ -75,7 +75,7 @@ src/sensors/%.o: CXXFLAGS+= $(PLUGINFLAGS) -I$(DCDBDEPSPATH)/bacnet-stack-$(BACN
libdcdbplugin_sysfs.$(LIBEXT)
:
src/Sensor.o src/sensors/sysfs/SysfsSensor.o src/sensors/sysfs/SysfsConfigurator.o
$(CXX)
$(LIBFLAGS)$@
-o
$@
$^
-L
$(DCDBDEPLOYPATH)
/lib/
-lboost_log
-lboost_system
libdcdbplugin_perfevent.$(LIBEXT)
:
src/sensors/perfevent/Perf
Counte
r.o src/sensors/perfevent/PerfeventConfigurator.o src/sensors/perfevent/Perf
Counte
rGroup.o
libdcdbplugin_perfevent.$(LIBEXT)
:
src/sensors/perfevent/Perf
Senso
r.o src/sensors/perfevent/PerfeventConfigurator.o src/sensors/perfevent/Perf
Senso
rGroup.o
$(CXX)
$(LIBFLAGS)$@
-o
$@
$^
-L
$(DCDBDEPLOYPATH)
/lib/
-lboost_log
-lboost_system
libdcdbplugin_ipmi.$(LIBEXT)
:
src/Sensor.o src/sensors/ipmi/IPMISensor.o src/sensors/ipmi/IPMIHost.o src/sensors/ipmi/IPMIConfigurator.o
...
...
src/sensors/perfevent/Perf
Counte
r.cpp
→
src/sensors/perfevent/Perf
Senso
r.cpp
View file @
f8b30b59
/*
* Perf
Counte
r.cpp
* Perf
Senso
r.cpp
*
* Created on: 11.12.2017
* Author: Micha Mueller
*/
#include
"PerfCounter.h"
#include
"PerfSensor.h"
#include
"timestamp.h"
#include
<unistd.h>
#include
<sys/ioctl.h>
...
...
@@ -15,12 +16,12 @@
#include
<functional>
#include
<limits.h>
Perf
Counte
r
::
Perf
Counte
r
(
const
std
::
string
&
name
)
:
Perf
Senso
r
::
Perf
Senso
r
(
const
std
::
string
&
name
)
:
SensorBase
(
name
),
PerfSensorBase
(
name
),
SingleSensor
(
name
)
{}
Perf
Counte
r
::~
Perf
Counte
r
()
{}
Perf
Senso
r
::~
Perf
Senso
r
()
{}
void
Perf
Counte
r
::
start
()
{
void
Perf
Senso
r
::
start
()
{
if
(
_keepRunning
)
{
//we have been started already
LOG
(
info
)
<<
"Sensor "
<<
_name
<<
" already running."
;
...
...
@@ -51,11 +52,11 @@ void PerfCounter::start() {
_keepRunning
=
1
;
_pendingTasks
++
;
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Counte
r
::
readAsync
,
this
));
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Senso
r
::
readAsync
,
this
));
LOG
(
info
)
<<
"Sensor "
<<
_name
<<
" started."
;
}
void
Perf
Counte
r
::
stop
()
{
void
Perf
Senso
r
::
stop
()
{
_keepRunning
=
0
;
if
(
_fd
!=
-
1
)
{
close
(
_fd
);
...
...
@@ -64,7 +65,7 @@ void PerfCounter::stop() {
LOG
(
info
)
<<
"Sensor "
<<
_name
<<
" stopped."
;
}
void
Perf
Counte
r
::
storeReading
(
reading_t
reading
,
unsigned
cacheIndex
)
{
void
Perf
Senso
r
::
storeReading
(
reading_t
reading
,
unsigned
cacheIndex
)
{
_readingQueue
->
push
(
reading
);
_cache
[
_cacheIndex
]
=
reading
;
_cacheIndex
=
(
_cacheIndex
+
1
)
%
_cacheSize
;
...
...
@@ -77,7 +78,7 @@ void PerfCounter::storeReading(reading_t reading, unsigned cacheIndex) {
_latestValue
.
timestamp
=
reading
.
timestamp
;
}
void
Perf
Counte
r
::
read
()
{
void
Perf
Senso
r
::
read
()
{
reading_t
reading
;
reading
.
timestamp
=
getTimestamp
();
...
...
@@ -101,14 +102,14 @@ void PerfCounter::read() {
storeReading
(
reading
,
_cacheIndex
);
}
void
Perf
Counte
r
::
readAsync
()
{
void
Perf
Senso
r
::
readAsync
()
{
uint64_t
now
=
getTimestamp
();
read
();
if
(
_timer
!=
NULL
&&
_keepRunning
)
{
uint64_t
next
=
now
+
MS_TO_NS
(
_interval
);
_timer
->
expires_at
(
timestamp2ptime
(
next
));
_pendingTasks
++
;
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Counte
r
::
readAsync
,
this
));
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Senso
r
::
readAsync
,
this
));
}
_pendingTasks
--
;
}
src/sensors/perfevent/Perf
Counte
r.h
→
src/sensors/perfevent/Perf
Senso
r.h
View file @
f8b30b59
/*
* Perf
Counte
r.h
* Perf
Senso
r.h
*
* Created on: 11.12.2017
* Author: Micha Mueller
*/
#ifndef PERF
COUNTE
R_H_
#define PERF
COUNTE
R_H_
#ifndef PERF
SENSO
R_H_
#define PERF
SENSO
R_H_
#include
"PerfSensorBase.h"
#include
"../../headers/SingleSensor.h"
class
Perf
Counte
r
:
public
PerfSensorBase
,
public
PerfAttributes
,
public
SingleSensor
{
class
Perf
Senso
r
:
public
PerfSensorBase
,
public
PerfAttributes
,
public
SingleSensor
{
public:
Perf
Counte
r
(
const
std
::
string
&
name
);
virtual
~
Perf
Counte
r
();
Perf
Senso
r
(
const
std
::
string
&
name
);
virtual
~
Perf
Senso
r
();
void
start
()
override
;
void
stop
()
override
;
...
...
@@ -26,4 +26,4 @@ private:
void
readAsync
()
override
;
};
#endif
/* PERF
COUNTE
R_H_ */
#endif
/* PERF
SENSO
R_H_ */
src/sensors/perfevent/Perf
Counte
rGroup.cpp
→
src/sensors/perfevent/Perf
Senso
rGroup.cpp
View file @
f8b30b59
/*
* Perf
Counte
rGroup.cpp
* Perf
Senso
rGroup.cpp
*
* Created on: 04.08.2018
* Author: Micha Mueller
*/
#include
"PerfCounterGroup.h"
#include
"PerfSensorGroup.h"
#include
"timestamp.h"
#include
<unistd.h>
#include
<sys/ioctl.h>
...
...
@@ -24,20 +25,20 @@ struct read_format {
}
values
[];
};
Perf
Counte
rGroup
::
Perf
Counte
rGroup
(
const
std
::
string
name
)
:
Perf
Senso
rGroup
::
Perf
Senso
rGroup
(
const
std
::
string
name
)
:
SensorGroupTemplate
(
name
)
{
_bufSize
=
0
;
_buf
=
NULL
;
}
Perf
Counte
rGroup
::~
Perf
Counte
rGroup
()
{
Perf
Senso
rGroup
::~
Perf
Senso
rGroup
()
{
if
(
_buf
)
{
delete
[]
_buf
;
}
}
void
Perf
Counte
rGroup
::
init
(
boost
::
asio
::
io_service
&
io
)
{
void
Perf
Senso
rGroup
::
init
(
boost
::
asio
::
io_service
&
io
)
{
_cacheSize
=
_cacheInterval
/
_interval
+
1
;
if
(
!
_timer
)
{
_timer
=
new
boost
::
asio
::
deadline_timer
(
io
,
boost
::
posix_time
::
seconds
(
0
));
...
...
@@ -58,10 +59,10 @@ void PerfCounterGroup::init(boost::asio::io_service& io) {
}
}
void
Perf
Counte
rGroup
::
start
()
{
void
Perf
Senso
rGroup
::
start
()
{
if
(
_keepRunning
)
{
//we have been started already
LOG
(
info
)
<<
"
Counte
rgroup "
<<
_groupName
<<
" already running."
;
LOG
(
info
)
<<
"
Senso
rgroup "
<<
_groupName
<<
" already running."
;
return
;
}
...
...
@@ -112,20 +113,20 @@ void PerfCounterGroup::start() {
_keepRunning
=
1
;
_pendingTasks
++
;
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Counte
rGroup
::
readAsync
,
this
));
LOG
(
info
)
<<
"
Counte
rgroup "
<<
_groupName
<<
" started."
;
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Senso
rGroup
::
readAsync
,
this
));
LOG
(
info
)
<<
"
Senso
rgroup "
<<
_groupName
<<
" started."
;
}
void
Perf
Counte
rGroup
::
stop
()
{
void
Perf
Senso
rGroup
::
stop
()
{
_keepRunning
=
0
;
if
(
_fd
!=
-
1
)
{
close
(
_fd
);
_fd
=
-
1
;
}
LOG
(
info
)
<<
"
Counte
rgroup "
<<
_groupName
<<
" stopped."
;
LOG
(
info
)
<<
"
Senso
rgroup "
<<
_groupName
<<
" stopped."
;
}
void
Perf
Counte
rGroup
::
read
()
{
void
Perf
Senso
rGroup
::
read
()
{
reading_t
reading
;
reading
.
timestamp
=
getTimestamp
();
...
...
@@ -133,7 +134,7 @@ void PerfCounterGroup::read() {
unsigned
long
long
count
;
if
(
::
read
(
_fd
,
_buf
,
_bufSize
)
<
0
)
{
LOG
(
error
)
<<
"
Counte
rgroup"
<<
_groupName
<<
" could not read value"
;
LOG
(
error
)
<<
"
Senso
rgroup"
<<
_groupName
<<
" could not read value"
;
return
;
}
...
...
@@ -163,14 +164,14 @@ void PerfCounterGroup::read() {
_cacheIndex
=
(
_cacheIndex
+
1
)
%
_cacheSize
;
}
void
Perf
Counte
rGroup
::
readAsync
()
{
void
Perf
Senso
rGroup
::
readAsync
()
{
uint64_t
now
=
getTimestamp
();
read
();
if
(
_timer
!=
NULL
&&
_keepRunning
)
{
uint64_t
next
=
now
+
MS_TO_NS
(
_interval
);
_timer
->
expires_at
(
timestamp2ptime
(
next
));
_pendingTasks
++
;
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Counte
rGroup
::
readAsync
,
this
));
_timer
->
async_wait
(
std
::
bind
(
&
Perf
Senso
rGroup
::
readAsync
,
this
));
}
_pendingTasks
--
;
}
src/sensors/perfevent/Perf
Counte
rGroup.h
→
src/sensors/perfevent/Perf
Senso
rGroup.h
View file @
f8b30b59
/*
* Perf
Counte
rGroup.h
* Perf
Senso
rGroup.h
*
* Created on: 04.08.2018
* Author: Micha Mueller
*/
#ifndef PERF
COUNTE
RGROUP_H_
#define PERF
COUNTE
RGROUP_H_
#ifndef PERF
SENSO
RGROUP_H_
#define PERF
SENSO
RGROUP_H_
#include
"../../headers/SensorGroupTemplate.h"
#include
"PerfSensor.h"
#include
"PerfSensorBase.h"
#include
"PerfCounter.h"
class
Perf
Counte
rGroup
:
public
SensorGroupTemplate
<
PerfSensorBase
>
,
public
PerfAttributes
{
class
Perf
Senso
rGroup
:
public
SensorGroupTemplate
<
PerfSensorBase
>
,
public
PerfAttributes
{
public:
Perf
Counte
rGroup
(
const
std
::
string
name
);
virtual
~
Perf
Counte
rGroup
();
Perf
Senso
rGroup
(
const
std
::
string
name
);
virtual
~
Perf
Senso
rGroup
();
void
init
(
boost
::
asio
::
io_service
&
io
)
override
;
void
start
()
override
;
...
...
@@ -31,4 +31,4 @@ private:
std
::
vector
<
uint64_t
>
_ids
;
};
#endif
/* PERF
COUNTE
RGROUP_H_ */
#endif
/* PERF
SENSO
RGROUP_H_ */
src/sensors/perfevent/PerfeventConfigurator.cpp
View file @
f8b30b59
...
...
@@ -75,7 +75,7 @@ bool PerfeventConfigurator::derivedReadConfig(boost::property_tree::iptree& cfg)
if
(
STRCMP
(
sensor
,
"sensor"
))
{
LOG
(
debug
)
<<
"Sensor
\"
"
<<
sensor
.
second
.
data
()
<<
"
\"
"
;
if
(
!
sensor
.
second
.
empty
())
{
Perf
Counter
perfCounte
r
(
sensor
.
second
.
data
());
Perf
Sensor
perfSenso
r
(
sensor
.
second
.
data
());
//first check if default counter is given
boost
::
optional
<
boost
::
property_tree
::
iptree
&>
defaultC
=
sensor
.
second
.
get_child_optional
(
"default"
);
...
...
@@ -83,8 +83,8 @@ bool PerfeventConfigurator::derivedReadConfig(boost::property_tree::iptree& cfg)
LOG
(
debug
)
<<
" Using
\"
"
<<
defaultC
.
get
().
data
()
<<
"
\"
as default."
;
sensorMap_t
::
iterator
it
=
_templateSensors
.
find
(
defaultC
.
get
().
data
());
if
(
it
!=
_templateSensors
.
end
())
{
perf
Counte
r
=
it
->
second
;
perf
Counte
r
.
setName
(
sensor
.
second
.
data
());
perf
Senso
r
=
it
->
second
;
perf
Senso
r
.
setName
(
sensor
.
second
.
data
());
}
else
{
LOG
(
warning
)
<<
" Template sensor
\"
"
<<
defaultC
.
get
().
data
()
<<
"
\"
not found! Using standard values."
;
}
...
...
@@ -108,22 +108,22 @@ bool PerfeventConfigurator::derivedReadConfig(boost::property_tree::iptree& cfg)
}
//read remaining values
if
(
readSingleSensor
(
perf
Counte
r
,
sensor
.
second
))
{
if
(
readSingleSensor
(
perf
Senso
r
,
sensor
.
second
))
{
//create distinct perfCounter and mqttSuffix per CPU
string
startMqtt
=
perf
Counte
r
.
getMqtt
();
string
startMqtt
=
perf
Senso
r
.
getMqtt
();
//customize perfCounter for every CPU
for
(
auto
i
:
cpuSet
)
{
Perf
Counte
r
*
perf
CC
=
new
Perf
Counte
r
(
sensor
.
second
.
data
());
*
perf
CC
=
perf
Counte
r
;
Perf
Senso
r
*
perf
S
=
new
Perf
Senso
r
(
sensor
.
second
.
data
());
*
perf
S
=
perf
Senso
r
;
string
incMqtt
=
increaseMqtt
(
startMqtt
,
i
);
perf
CC
->
setName
(
perf
CC
->
getName
()
+
std
::
to_string
(
i
));
perf
CC
->
setCpuId
(
i
);
perf
CC
->
setMqtt
(
_mqttPrefix
+
incMqtt
);
LOG
(
debug
)
<<
" CPU "
<<
perf
CC
->
getCpuId
()
<<
" using MQTT-Topic "
<<
perf
CC
->
getMqtt
();
_sensors
.
push_back
(
perf
CC
);
perf
S
->
setName
(
perf
S
->
getName
()
+
std
::
to_string
(
i
));
perf
S
->
setCpuId
(
i
);
perf
S
->
setMqtt
(
_mqttPrefix
+
incMqtt
);
LOG
(
debug
)
<<
" CPU "
<<
perf
S
->
getCpuId
()
<<
" using MQTT-Topic "
<<
perf
S
->
getMqtt
();
_sensors
.
push_back
(
perf
S
);
}
}
else
{
LOG
(
warning
)
<<
" Sensor
\"
"
<<
sensor
.
second
.
data
()
<<
"
\"
has bad values! Ignoring..."
;
...
...
@@ -137,7 +137,7 @@ bool PerfeventConfigurator::derivedReadConfig(boost::property_tree::iptree& cfg)
if
(
STRCMP
(
group
,
"group"
))
{
LOG
(
debug
)
<<
"Group
\"
"
<<
group
.
second
.
data
()
<<
"
\"
"
;
if
(
!
group
.
second
.
empty
())
{
Perf
Counte
rGroup
perfGroup
(
group
.
second
.
data
());
Perf
Senso
rGroup
perfGroup
(
group
.
second
.
data
());
//initialize set with cpuIDs
//default cpuSet: contains all cpuIDs
...
...
@@ -164,10 +164,10 @@ bool PerfeventConfigurator::derivedReadConfig(boost::property_tree::iptree& cfg)
//customize perfGroup for every CPU
for
(
auto
i
:
cpuSet
)
{
Perf
Counte
rGroup
*
perf
C
G
=
new
Perf
Counte
rGroup
(
group
.
second
.
data
());
*
perf
C
G
=
perfGroup
;
perf
C
G
->
setGroupName
(
perf
C
G
->
getGroupName
()
+
std
::
to_string
(
i
));
perf
C
G
->
setCpuId
(
i
);
Perf
Senso
rGroup
*
perf
S
G
=
new
Perf
Senso
rGroup
(
group
.
second
.
data
());
*
perf
S
G
=
perfGroup
;
perf
S
G
->
setGroupName
(
perf
S
G
->
getGroupName
()
+
std
::
to_string
(
i
));
perf
S
G
->
setCpuId
(
i
);
//read counters
BOOST_FOREACH
(
boost
::
property_tree
::
iptree
::
value_type
&
val
,
group
.
second
)
{
...
...
@@ -176,14 +176,14 @@ bool PerfeventConfigurator::derivedReadConfig(boost::property_tree::iptree& cfg)
PerfSensorBase
*
perfSB
=
new
PerfSensorBase
(
val
.
second
.
data
()
+
std
::
to_string
(
i
));
if
(
readSensorBase
(
*
perfSB
,
val
.
second
))
{
perfSB
->
setMqtt
(
_mqttPrefix
+
mqttPart
+
increaseMqtt
(
perfSB
->
getMqtt
(),
i
));
LOG
(
debug
)
<<
"
Counte
r "
<<
perfSB
->
getName
()
<<
" on CPU "
<<
perf
C
G
->
getCpuId
()
<<
" using MQTT-Topic "
<<
perfSB
->
getMqtt
();
perf
C
G
->
pushBackSensor
(
perfSB
);
LOG
(
debug
)
<<
"
Senso
r "
<<
perfSB
->
getName
()
<<
" on CPU "
<<
perf
S
G
->
getCpuId
()
<<
" using MQTT-Topic "
<<
perfSB
->
getMqtt
();
perf
S
G
->
pushBackSensor
(
perfSB
);
}
else
{
LOG
(
warning
)
<<
"
Counte
r
\"
"
<<
val
.
second
.
data
()
<<
"
\"
has bad values! Ignoring..."
;
LOG
(
warning
)
<<
"
Senso
r
\"
"
<<
val
.
second
.
data
()
<<
"
\"
has bad values! Ignoring..."
;
}
}
}
_sensorGroups
.
push_back
(
perf
C
G
);
_sensorGroups
.
push_back
(
perf
S
G
);
}
}
}
...
...
src/sensors/perfevent/PerfeventConfigurator.h
View file @
f8b30b59
...
...
@@ -10,11 +10,11 @@
#include
<set>
#include
"PerfCounter.h"
#include
"PerfCounterGroup.h"
#include
"../../ConfiguratorTemplate.h"
#include
"PerfSensor.h"
#include
"PerfSensorGroup.h"
class
PerfeventConfigurator
:
public
ConfiguratorTemplate
<
PerfSensorBase
,
Perf
Counte
r
>
{
class
PerfeventConfigurator
:
public
ConfiguratorTemplate
<
PerfSensorBase
,
Perf
Senso
r
>
{
typedef
std
::
map
<
std
::
string
,
std
::
set
<
int
>>
templateCpuMap_t
;
typedef
std
::
map
<
std
::
string
,
unsigned
int
>
enumMap_t
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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