aboutsummaryrefslogtreecommitdiffstats
path: root/app/taskmanager.cpp
diff options
context:
space:
mode:
authorVitaly Wool <vitaly.wool@konsulko.com>2019-05-20 07:49:52 +0000
committerVitaly Wool <vitaly.wool@konsulko.com>2019-05-20 07:51:30 +0000
commita4d90fcb10ee166bf877f3308b71a3f694b7f312 (patch)
treed3612f7a7bf43602eb1750199a6f626cf18d7f65 /app/taskmanager.cpp
parent22a7ffb93ee7ef8d0c05e86e99fb1c70efca0888 (diff)
Implement network load visualizationhalibut_7.99.1halibut/7.99.17.99.1
Implement network load visualization in TaskManager as a complement to the System tab. It shows in/out network activity graph basing on the info provided by the backend. Bug-AGL: SPEC-2403 Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.com> Change-Id: I7d6b4f25424bd3ee1bfc12e9b084a021df289992
Diffstat (limited to 'app/taskmanager.cpp')
-rw-r--r--app/taskmanager.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/taskmanager.cpp b/app/taskmanager.cpp
index 5726388..fb81098 100644
--- a/app/taskmanager.cpp
+++ b/app/taskmanager.cpp
@@ -49,6 +49,7 @@ void TaskManager::loadAvg() {
void TaskManager::query() {
callService("get_process_list",
QJsonValue(QJsonObject({{"processes", QJsonValue()}})));
+ callService("get_netstat", QJsonValue());
}
void TaskManager::callService(const QString& command, QJsonValue value) {
@@ -84,6 +85,10 @@ void TaskManager::ProcessResponse(Message *message)
QJsonObject loadInfo = message->replyData()["loadInfo"].toObject();
ProcessResponseLoadAvg(loadInfo);
}
+ if (QString::compare(msgType, "netStatInfo") == 0) {
+ QJsonObject netstat = message->replyData()["netstat"].toObject();
+ ProcessResponseNetStat(netstat);
+ }
// more response types to follow
}
@@ -166,3 +171,17 @@ void TaskManager::ProcessResponseLoadAvg(QJsonObject &loadInfo)
emit updateLoadAverage(loadInfo["value"].toDouble());
}
+
+void TaskManager::ProcessResponseNetStat(QJsonObject &netstat)
+{
+ if (netstat.size() == 0) {
+ return;
+ }
+
+ unsigned int newInOctets = netstat["InOctets"].toInt();
+ unsigned int newOutOctets = netstat["OutOctets"].toInt();
+
+ emit updateNetworkStats(newInOctets - inOctets, newOutOctets - outOctets);
+ inOctets = newInOctets;
+ outOctets = newOutOctets;
+}