mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
[API CHANGE] Add a new "action" for sysadm/systemmanager
"action"="deviceinfo" will return the full information about all devices attached to the system (via `pciconf -lv`)
-------------------
REST Request (example):
-------------------------------
PUT /sysadm/systemmanager
{
"action" : "deviceinfo"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"name" : "systemmanager",
"namespace" : "sysadm",
"args" : {
"action" : "deviceinfo"
}
}
Response:
-------------------------------
{
"args": {
"deviceinfo": {
"ahci0": {
"class": "mass storage",
"device": "8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]",
"subclass": "SATA",
"vendor": "Intel Corporation"
},
"ehci0": {
"class": "serial bus",
"device": "8 Series/C220 Series Chipset Family USB EHCI",
"subclass": "USB",
"vendor": "Intel Corporation"
},
"ehci1": {
"class": "serial bus",
"device": "8 Series/C220 Series Chipset Family USB EHCI",
"subclass": "USB",
"vendor": "Intel Corporation"
},
"hdac0": {
"class": "multimedia",
"subclass": "HDA",
"vendor": "NVIDIA Corporation"
},
"hdac1": {
"class": "multimedia",
"device": "8 Series/C220 Series Chipset High Definition Audio Controller",
"subclass": "HDA",
"vendor": "Intel Corporation"
},
"hostb0": {
"class": "bridge",
"device": "4th Gen Core Processor DRAM Controller",
"subclass": "HOST-PCI",
"vendor": "Intel Corporation"
},
"isab0": {
"class": "bridge",
"device": "B85 Express LPC Controller",
"subclass": "PCI-ISA",
"vendor": "Intel Corporation"
},
"none0": {
"class": "simple comms",
"device": "8 Series/C220 Series Chipset Family MEI Controller",
"vendor": "Intel Corporation"
},
"none1": {
"class": "serial bus",
"device": "8 Series/C220 Series Chipset Family SMBus Controller",
"subclass": "SMBus",
"vendor": "Intel Corporation"
},
"pcib1": {
"class": "bridge",
"device": "Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller",
"subclass": "PCI-PCI",
"vendor": "Intel Corporation"
},
"pcib2": {
"class": "bridge",
"device": "8 Series/C220 Series Chipset Family PCI Express Root Port",
"subclass": "PCI-PCI",
"vendor": "Intel Corporation"
},
"pcib3": {
"class": "bridge",
"device": "8 Series/C220 Series Chipset Family PCI Express Root Port",
"subclass": "PCI-PCI",
"vendor": "Intel Corporation"
},
"pcib4": {
"class": "bridge",
"device": "8 Series/C220 Series Chipset Family PCI Express Root Port",
"subclass": "PCI-PCI",
"vendor": "Intel Corporation"
},
"pcib5": {
"class": "bridge",
"device": "82801 PCI Bridge",
"subclass": "PCI-PCI",
"vendor": "Intel Corporation"
},
"re0": {
"class": "network",
"device": "RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller",
"subclass": "ethernet",
"vendor": "Realtek Semiconductor Co., Ltd."
},
"vgapci0": {
"class": "display",
"device": "GM206 [GeForce GTX 960]",
"subclass": "VGA",
"vendor": "NVIDIA Corporation"
},
"xhci0": {
"class": "serial bus",
"device": "8 Series/C220 Series Chipset Family USB xHCI",
"subclass": "USB",
"vendor": "Intel Corporation"
}
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -529,50 +529,54 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemMgmtRequest(const QJso
|
||||
ok = true;
|
||||
out->insert("batteryinfo", sysadm::SysMgmt::batteryInfo());
|
||||
}
|
||||
if(act=="cpupercentage"){
|
||||
else if(act=="cpupercentage"){
|
||||
ok = true;
|
||||
out->insert("cpupercentage", sysadm::SysMgmt::cpuPercentage());
|
||||
}
|
||||
if(act=="cputemps"){
|
||||
else if(act=="cputemps"){
|
||||
ok = true;
|
||||
out->insert("cputemps", sysadm::SysMgmt::cpuTemps());
|
||||
}
|
||||
if(act=="externalmounts"){
|
||||
else if(act=="externalmounts"){
|
||||
ok = true;
|
||||
out->insert("externalmounts", sysadm::SysMgmt::externalDevicePaths());
|
||||
}
|
||||
if(act=="halt"){
|
||||
else if(act=="halt"){
|
||||
ok = true;
|
||||
out->insert("halt", sysadm::SysMgmt::systemHalt());
|
||||
}
|
||||
if(act=="killproc"){
|
||||
else if(act=="killproc"){
|
||||
ok = true;
|
||||
out->insert("killproc", sysadm::SysMgmt::killProc(in_args.toObject()));
|
||||
}
|
||||
if(act=="memorystats"){
|
||||
else if(act=="memorystats"){
|
||||
ok = true;
|
||||
out->insert("memorystats", sysadm::SysMgmt::memoryStats());
|
||||
}
|
||||
if(act=="procinfo"){
|
||||
else if(act=="procinfo"){
|
||||
ok = true;
|
||||
out->insert("procinfo", sysadm::SysMgmt::procInfo());
|
||||
}
|
||||
if(act=="reboot"){
|
||||
else if(act=="reboot"){
|
||||
ok = true;
|
||||
out->insert("reboot", sysadm::SysMgmt::systemReboot());
|
||||
}
|
||||
if(act=="setsysctl"){
|
||||
else if(act=="setsysctl"){
|
||||
ok = true;
|
||||
out->insert("setsysctl", sysadm::SysMgmt::setSysctl(in_args.toObject()));
|
||||
}
|
||||
if(act=="sysctllist"){
|
||||
else if(act=="sysctllist"){
|
||||
ok = true;
|
||||
out->insert("sysctllist", sysadm::SysMgmt::sysctlList());
|
||||
}
|
||||
if(act=="systeminfo"){
|
||||
else if(act=="systeminfo"){
|
||||
ok = true;
|
||||
out->insert("systeminfo", sysadm::SysMgmt::systemInfo());
|
||||
}
|
||||
else if(act=="deviceinfo"){
|
||||
ok = true;
|
||||
out->insert("deviceinfo", sysadm::SysMgmt::systemDevices());
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
|
||||
@@ -385,8 +385,10 @@ QJsonArray PKG::list_repos(bool updated){
|
||||
}
|
||||
|
||||
QJsonObject PKG::evaluateInstall(QStringList origins, QString repo){
|
||||
qDebug() << "Verify Install:" << origins << repo;
|
||||
//qDebug() << "Verify Install:" << origins << repo;
|
||||
QJsonObject out;
|
||||
out.insert("install_origins", QJsonArray::fromStringList(origins) );
|
||||
out.insert("repo", repo);
|
||||
if(repo=="local" || origins.isEmpty()){ return out; } //nothing to do
|
||||
QString dbconn = openDB(repo);
|
||||
QString ldbconn = openDB("local");
|
||||
@@ -418,14 +420,14 @@ QJsonObject PKG::evaluateInstall(QStringList origins, QString repo){
|
||||
for(int i=0; i<local_names.length(); i++){
|
||||
names.removeAll(local_names[i]);
|
||||
}
|
||||
qDebug() << " - Filtered Names:" << names;
|
||||
//qDebug() << " - Filtered Names:" << names;
|
||||
toInstall_id = ids_from_names(names, DB); //now get the shorter/filtered list of ID's (remote)
|
||||
//qDebug() << " - Filtered ID's:" << toInstall_id;
|
||||
//Get the list of conflicting packages which are already installed
|
||||
QStringList conflict_ids = conflicts_from_ids(toInstall_id, DB); //also get the list of any conflicts for these packages
|
||||
conflict_ids.removeDuplicates();
|
||||
QStringList conflict_names = names_from_ids(conflict_ids, "packages", DB);
|
||||
qDebug() << " - Conflicts (remote):" << conflict_ids << conflict_names;
|
||||
//qDebug() << " - Conflicts (remote):" << conflict_ids << conflict_names;
|
||||
out.insert("conflicts", QJsonArray::fromStringList(names_from_ids( ids_from_names(conflict_names, LDB), "packages", LDB) ) );
|
||||
//Now assemble all the information about the packages (remote database)
|
||||
QJsonObject install;
|
||||
@@ -441,7 +443,7 @@ QJsonObject PKG::evaluateInstall(QStringList origins, QString repo){
|
||||
obj.insert( "comment", qi.value("comment").toString());
|
||||
install.insert(qi.value("name").toString(), obj);
|
||||
}
|
||||
qDebug() << "Final Install Object:" << install;
|
||||
//qDebug() << "Final Install Object:" << install;
|
||||
//qDebug() << "Last Query Error:" << qi.lastError().text();
|
||||
//Add the info to the output object and close the databases
|
||||
out.insert("install", install);
|
||||
|
||||
@@ -262,7 +262,7 @@ QJsonObject SysMgmt::procInfo() {
|
||||
for(int i=0; i<output.length(); i++){
|
||||
if (output.at(i).contains("PID") && output.at(i).contains("USERNAME")){
|
||||
inSection = true;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
if (!inSection)
|
||||
continue;
|
||||
@@ -392,6 +392,30 @@ QJsonObject SysMgmt::systemReboot() {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get all device information about the system
|
||||
QJsonObject SysMgmt::systemDevices(){
|
||||
QJsonObject pciconf_info;
|
||||
QStringList lines = General::RunCommand("pciconf -lv").split("\n");
|
||||
//qDebug() << "Raw pciconf:" << lines;
|
||||
QJsonObject cobj; QString cid;
|
||||
for(int i=0; i<lines.length(); i++){
|
||||
if(!lines[i].contains(" = ") && !cid.isEmpty()){ pciconf_info.insert(cid,cobj); cid.clear(); cobj = QJsonObject(); }
|
||||
if(lines[i].contains(" = ")){
|
||||
QString var = lines[i].section("=",0,0).simplified();
|
||||
QString val = lines[i].section("=",1,-1).simplified();
|
||||
if(val.startsWith("\'") && val.endsWith("\'")){ val.chop(1); val = val.remove(0,1); }
|
||||
//qDebug() << "PCICONF LINE:" << lines[i];
|
||||
//qDebug() << "\t\t" << var << val;
|
||||
cobj.insert(var,val);
|
||||
}else{
|
||||
//New device section
|
||||
cid = lines[i].section("@",0,0);
|
||||
}
|
||||
}
|
||||
if(!cid.isEmpty() && cobj.keys().isEmpty()){ pciconf_info.insert(cid,cobj); }
|
||||
return pciconf_info;
|
||||
}
|
||||
|
||||
// Source Management
|
||||
/*
|
||||
void SysMgmt::fetchPortsTree(QStringList &cmds, QStringList &dirs){
|
||||
|
||||
@@ -26,10 +26,12 @@ public:
|
||||
static QJsonObject systemInfo();
|
||||
static QJsonObject systemReboot();
|
||||
static QJsonObject systemHalt();
|
||||
|
||||
static QJsonObject systemDevices();
|
||||
// static void fetchPortsTree(QStringList &cmds, QStringList &dirs); // This is not ready yet
|
||||
// static void fetchSourceTree(QString branch, QStringList &cmds, QStringList &dirs); // This is not ready yet
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
} //end of namespace
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user