mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new API call to get a bunch of various system information back
REST Request:
-------------------------------
PUT /sysadm/systeminfo
{
"action" : "systeminfo"
}
REST Response:
-------------------------------
{
"args": {
"systeminfo": {
"arch": "amd64",
"cpucores": "4",
"cputype": "Intel(R) Xeon(R) CPU E3-1220 v3 @ 3.10GHz",
"hostname": "krisdesktop",
"kernelident": "GENERIC",
"kernelversion": "10.2-RELEASE-p11",
"systemversion": "10.2-RELEASE-p12",
"totalmem": 10720,
"uptime": "up 2 days 5:09"
}
}
}
WebSocket Request:
-------------------------------
{
"args" : {
"action" : "systeminfo"
},
"id" : "fooid",
"name" : "systeminfo",
"namespace" : "sysadm"
}
WebSocket Response:
-------------------------------
{
"args": {
"systeminfo": {
"arch": "amd64",
"cpucores": "4",
"cputype": "Intel(R) Xeon(R) CPU E3-1220 v3 @ 3.10GHz",
"hostname": "krisdesktop",
"kernelident": "GENERIC",
"kernelversion": "10.2-RELEASE-p11",
"systemversion": "10.2-RELEASE-p12",
"totalmem": 10720,
"uptime": "up 2 days 5:09"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -174,3 +174,41 @@ QJsonObject SysInfo::memoryPercentage() {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Return a bunch of various system information
|
||||
QJsonObject SysInfo::systemInfo() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QString arch = General::RunCommand("uname -m").simplified();
|
||||
retObject.insert("arch", arch);
|
||||
|
||||
QString sysver = General::RunCommand("freebsd-version").simplified();
|
||||
retObject.insert("systemversion", sysver);
|
||||
|
||||
QString kernver = General::RunCommand("uname -r").simplified();
|
||||
retObject.insert("kernelversion", kernver);
|
||||
|
||||
QString kernident = General::RunCommand("uname -i").simplified();
|
||||
retObject.insert("kernelident", kernident);
|
||||
|
||||
QString host = General::RunCommand("hostname").simplified();
|
||||
retObject.insert("hostname", host);
|
||||
|
||||
QString uptime = General::RunCommand("uptime").simplified().section(" ", 1, 4).simplified().replace(",", "");
|
||||
retObject.insert("uptime", uptime);
|
||||
|
||||
QString cputype = General::RunCommand("sysctl -n hw.model").simplified();
|
||||
retObject.insert("cputype", cputype);
|
||||
|
||||
QString cpucores = General::RunCommand("sysctl -n kern.smp.cpus").simplified();
|
||||
retObject.insert("cpucores", cpucores);
|
||||
|
||||
bool ok;
|
||||
QString totalmem = General::RunCommand("sysctl -n hw.realmem").simplified();
|
||||
totalmem.toDouble(&ok);
|
||||
if ( ok ) {
|
||||
retObject.insert("totalmem", totalmem.toDouble() / 1024 / 1024);
|
||||
}
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static QJsonObject cpuTemps();
|
||||
static QJsonObject externalDevicePaths();
|
||||
static QJsonObject memoryPercentage();
|
||||
static QJsonObject systemInfo();
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
@@ -275,6 +275,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemInfoRequest(const QJso
|
||||
ok = true;
|
||||
out->insert("memorypercentage", sysadm::SysInfo::memoryPercentage());
|
||||
}
|
||||
if(act=="systeminfo"){
|
||||
ok = true;
|
||||
out->insert("systeminfo", sysadm::SysInfo::systemInfo());
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
|
||||
Reference in New Issue
Block a user