diff options
author | Vitaly Wool <vitaly.wool@konsulko.com> | 2019-04-08 12:45:42 +0200 |
---|---|---|
committer | Vitaly Wool <vitaly.wool@konsulko.com> | 2019-04-08 12:47:51 +0200 |
commit | 22a7ffb93ee7ef8d0c05e86e99fb1c70efca0888 (patch) | |
tree | 9bd9dc211d5d72c9fa73db4e1835cc88df635344 /app/taskmanager.cpp | |
parent | 122bcc295d054a733585996e859dea870ba5ca88 (diff) |
Implement system load visualization
Implement system load visualization in TaskManager as a separate
tab showing average system load graph basing on the info provided
by the backend.
Change-Id: I81359185516ebb1b6218bfd9ca53f1d76dfddeb4
Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.com>
Diffstat (limited to 'app/taskmanager.cpp')
-rw-r--r-- | app/taskmanager.cpp | 22 |
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()); +} |