aboutsummaryrefslogtreecommitdiffstats
path: root/app/taskmanager.cpp
diff options
context:
space:
mode:
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;
+}