Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KSysGuard
Commits
0f600bb5
Commit
0f600bb5
authored
Aug 24, 2020
by
David Redondo
🏎
Browse files
iterate through all sensors on linux and print info
parent
a63bede9
Changes
3
Hide whitespace changes
Inline
Side-by-side
plugins/global/cpu/CMakeLists.txt
View file @
0f600bb5
...
...
@@ -4,5 +4,13 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif
(
CMAKE_SYSTEM_NAME STREQUAL
"FreeBSD"
)
target_sources
(
ksysguard_plugin_cpu PRIVATE freebsdcpu.cpp
)
endif
()
target_link_libraries
(
ksysguard_plugin_cpu Qt5::Core KSysGuard::StatsBackend KF5::CoreAddons KF5::I18n
)
if
(
SENSORS_FOUND
)
target_include_directories
(
ksysguard_plugin_cpu PRIVATE
${
SENSORS_INCLUDE_DIR
}
)
target_link_libraries
(
ksysguard_plugin_cpu
${
SENSORS_LIBRARIES
}
)
target_compile_definitions
(
ksysguard_plugin_cpu PRIVATE HAVE_SENSORS
)
endif
()
install
(
TARGETS ksysguard_plugin_cpu DESTINATION
${
KDE_INSTALL_PLUGINDIR
}
/ksysguard
)
plugins/global/cpu/linuxcpu.cpp
View file @
0f600bb5
...
...
@@ -4,6 +4,8 @@
#include
<KLocalizedString>
#include
<sensors/sensors.h>
#include
<SensorContainer.h>
static
double
readCpuFreq
(
const
QString
&
cpuId
,
const
QString
&
attribute
,
bool
&
ok
)
...
...
@@ -31,7 +33,6 @@ LinuxCpuObject::LinuxCpuObject(const QString &id, const QString &name, SensorCon
if
(
ok
)
{
m_frequency
->
setMin
(
min
);
}
qDebug
()
<<
id
<<
frequency
<<
min
<<
max
;
}
}
...
...
@@ -67,8 +68,8 @@ void LinuxCpuObject::update(unsigned long long system, unsigned long long user,
}
if
(
ok
)
{
m_frequency
->
setValue
(
frequency
);
}
// FIXME Should we fall back to reading /proc/cpuinfo again when the above fails? Could have the
}
// FIXME Should we fall back to reading /proc/cpuinfo again when the above fails? Could have the
// frequency value changed even if the cpu apparently doesn't use CPUFreq?
}
...
...
@@ -114,6 +115,30 @@ LinuxCpuPluginPrivate::LinuxCpuPluginPrivate(CpuPlugin *q)
auto
coreCount
=
new
SensorProperty
(
QStringLiteral
(
"coreCount"
),
i18nc
(
"@title"
,
"Number of Cores"
),
cores
,
total
);
coreCount
->
setShortName
(
i18nc
(
"@title, Short fort 'Number of Cores'"
,
"Cores"
));
coreCount
->
setDescription
(
i18nc
(
"@info"
,
"Number of CPU cores across all physical CPUS"
));
addSensors
();
}
void
LinuxCpuPluginPrivate
::
addSensors
()
{
#ifdef HAVE_SENSORS
sensors_init
(
nullptr
);
int
number
=
0
;
while
(
sensors_chip_name
const
*
chipName
=
sensors_get_detected_chips
(
nullptr
,
&
number
))
{
char
name
[
100
];
sensors_snprintf_chip_name
(
name
,
100
,
chipName
);
qDebug
()
<<
name
<<
chipName
->
prefix
<<
"Bus("
<<
chipName
->
bus
.
nr
<<
chipName
->
bus
.
type
<<
")"
<<
chipName
->
addr
<<
chipName
->
path
;
int
featureNumber
=
0
;
while
(
sensors_feature
const
*
feature
=
sensors_get_features
(
chipName
,
&
featureNumber
))
{
qDebug
()
<<
'\t'
<<
feature
->
number
<<
sensors_get_label
(
chipName
,
feature
)
<<
feature
->
name
<<
feature
->
type
;
int
subfeatureNumber
=
0
;
while
(
sensors_subfeature
const
*
subfeature
=
sensors_get_all_subfeatures
(
chipName
,
feature
,
&
subfeatureNumber
))
{
qDebug
()
<<
"
\t\t
"
<<
subfeature
->
number
<<
subfeature
->
name
<<
subfeature
->
type
<<
subfeature
->
flags
<<
subfeature
->
mapping
;
}
}
}
#endif
}
void
LinuxCpuPluginPrivate
::
update
()
...
...
plugins/global/cpu/linuxcpu.h
View file @
0f600bb5
...
...
@@ -39,6 +39,8 @@ class LinuxCpuPluginPrivate : public CpuPluginPrivate {
public:
LinuxCpuPluginPrivate
(
CpuPlugin
*
q
);
void
update
()
override
;
private:
void
addSensors
();
};
#endif
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