mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Additional information on system used (#1045)
* Allow --version, even if hyperion is already running * Add CPU-Model to SysInfo * Add additional CPUInfos * Use fileUtils & RegEx on CPU-Info * Add CPU - Hardware info * Update changelog * Suppress empty CPU info elements
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
#include "utils/SysInfo.h"
|
||||
#include "utils/FileUtils.h"
|
||||
|
||||
#include <QHostInfo>
|
||||
#include <QSysInfo>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
SysInfo* SysInfo::_instance = nullptr;
|
||||
|
||||
@@ -17,6 +22,7 @@ SysInfo::SysInfo()
|
||||
_sysinfo.prettyName = QSysInfo::prettyProductName();
|
||||
_sysinfo.hostName = QHostInfo::localHostName();
|
||||
_sysinfo.domainName = QHostInfo::localDomainName();
|
||||
getCPUInfo();
|
||||
}
|
||||
|
||||
SysInfo::HyperionSysInfo SysInfo::get()
|
||||
@@ -26,3 +32,48 @@ SysInfo::HyperionSysInfo SysInfo::get()
|
||||
|
||||
return SysInfo::_instance->_sysinfo;
|
||||
}
|
||||
|
||||
void SysInfo::getCPUInfo()
|
||||
{
|
||||
QString cpuInfo;
|
||||
if( FileUtils::readFile("/proc/cpuinfo", cpuInfo, Logger::getInstance("DAEMON"), true) )
|
||||
{
|
||||
QRegularExpression regEx ("^model\\s*:\\s(.*)", QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption);
|
||||
QRegularExpressionMatch match;
|
||||
|
||||
match = regEx.match(cpuInfo);
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
_sysinfo.cpuModelType = match.captured(1);
|
||||
}
|
||||
|
||||
regEx.setPattern("^model name\\s*:\\s(.*)");
|
||||
match = regEx.match(cpuInfo);
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
_sysinfo.cpuModelName = match.captured(1);
|
||||
}
|
||||
|
||||
regEx.setPattern("^hardware\\s*:\\s(.*)");
|
||||
match = regEx.match(cpuInfo);
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
_sysinfo.cpuHardware = match.captured(1);
|
||||
}
|
||||
|
||||
regEx.setPattern("^revision\\s*:\\s(.*)");
|
||||
match = regEx.match(cpuInfo);
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
_sysinfo.cpuRevision = match.captured(1);
|
||||
}
|
||||
|
||||
regEx.setPattern("^revision\\s*:\\s(.*)");
|
||||
match = regEx.match(cpuInfo);
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
_sysinfo.cpuRevision = match.captured(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user