summaryrefslogtreecommitdiffstats
path: root/app/taskmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/taskmanager.cpp')
-rw-r--r--app/taskmanager.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/taskmanager.cpp b/app/taskmanager.cpp
index ece6d83..5726388 100644
--- a/app/taskmanager.cpp
+++ b/app/taskmanager.cpp
@@ -28,6 +28,11 @@ void TaskManager::onConnected()
timer = new QTimer();
connect(timer, SIGNAL(timeout()), this, SLOT(query()));
timer->start(3000);
+
+ loadAvg();
+ loadAvgTimer = new QTimer();
+ connect(loadAvgTimer, SIGNAL(timeout()), this, SLOT(loadAvg()));
+ loadAvgTimer->start(1000);
}
void TaskManager::kill(int tid) {
callService("kill_process", QJsonValue(tid));
@@ -37,6 +42,10 @@ void TaskManager::getExtraInfo(int tid) {
callService("get_extra_info", QJsonValue(tid));
}
+void TaskManager::loadAvg() {
+ callService("get_load_avg", QJsonValue());
+}
+
void TaskManager::query() {
callService("get_process_list",
QJsonValue(QJsonObject({{"processes", QJsonValue()}})));
@@ -71,6 +80,10 @@ void TaskManager::ProcessResponse(Message *message)
QJsonObject info = message->replyData()["info"].toObject();
ProcessResponseExtraInfo(info);
}
+ if (QString::compare(msgType, "loadAvgInfo") == 0) {
+ QJsonObject loadInfo = message->replyData()["loadInfo"].toObject();
+ ProcessResponseLoadAvg(loadInfo);
+ }
// more response types to follow
}
@@ -144,3 +157,12 @@ void TaskManager::ProcessResponseExtraInfo(QJsonObject &info)
emit showProcessInfo(infoString);
}
+
+void TaskManager::ProcessResponseLoadAvg(QJsonObject &loadInfo)
+{
+ if (loadInfo.size() == 0) {
+ return;
+ }
+
+ emit updateLoadAverage(loadInfo["value"].toDouble());
+}