summaryrefslogtreecommitdiffstats
path: root/app
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
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')
-rw-r--r--app/main.qml141
-rw-r--r--app/taskmanager.cpp19
-rw-r--r--app/taskmanager.h3
3 files changed, 133 insertions, 30 deletions
diff --git a/app/main.qml b/app/main.qml
index 7e76265..45864ba 100644
--- a/app/main.qml
+++ b/app/main.qml
@@ -48,7 +48,11 @@ Window {
}
onUpdateLoadAverage: {
- mainTabview.getTab(1).item.tempAdd(value_);
+ mainTabview.getTab(1).item.updateLoadChart(value_);
+ }
+
+ onUpdateNetworkStats: {
+ mainTabview.getTab(1).item.updateNetChart(in_, out_);
}
}
@@ -178,53 +182,130 @@ Window {
anchors.fill: parent
title: "System"
- ChartView {
- id: chartView
- title: "System load average"
+ Rectangle {
+ id: graphsView
width: parent.width
- height: parent.height / 2
- legend.visible: false
- antialiasing: true
+ height: parent.height
+
+ function updateLoadChart(value_)
+ {
+ loadChart.tempAdd(value_)
+ }
+ function updateNetChart(in_, out_)
+ {
+ networkChart.updateStats(in_, out_)
+ }
+
+ ChartView {
+ id: loadChart
+ title: "System load average"
+ width: parent.width
+ height: parent.height / 3
+ legend.visible: false
+ antialiasing: true
+
+ LineSeries {
+ id: loadSeries
+
+ axisX: DateTimeAxis {
+ id: timeLoadAxis
+ labelsVisible: false
+ format: "hh:mm"
+ }
+
+ axisY: ValueAxis {
+ id: valueAxis
+ max: 2
+ min: 0
+ tickCount: 3
+ }
+
+ XYPoint { x: new Date().getTime(); y: 0 }
+ XYPoint { x: (new Date().getTime()+ 10); y: 0 }
+ }
+ function tempAdd(value_)
+ {
+ var time_ = new Date();
- LineSeries {
- id: loadSeries
+ if (value_ > valueAxis.max)
+ valueAxis.max = value_;
- axisX: DateTimeAxis {
- id: timeAxis
+ loadSeries.append(time_.getTime(), value_);
+ timeLoadAxis.max = time_;
+
+ if (loadSeries.count > 1800)
+ {
+ loadSeries.remove(0);
+ time_.setMinutes(time_.getMinutes() - 30);
+ timeLoadAxis.min = time_;
+ }
+
+ loadChart.update();
+ }
+ }
+ ChartView {
+ id: networkChart
+ title: "Network Stats and Charts"
+ width: parent.width
+ height: parent.height / 3
+ legend.visible: true
+ antialiasing: true
+ anchors.top: loadChart.bottom
+
+ DateTimeAxis {
+ id: timeNetAxis
labelsVisible: false
format: "hh:mm"
}
- axisY: ValueAxis {
- id: valueAxis
+ ValueAxis {
+ id: octetsAxis
max: 2
min: 0
tickCount: 3
}
+ LineSeries {
+ id: netSeriesIn
+ name: "InOctets"
- XYPoint { x: new Date().getTime(); y: 0 }
- XYPoint { x: (new Date().getTime()+ 10); y: 0 }
+ axisX: timeNetAxis
+ axisY: octetsAxis
- }
+ XYPoint { x: new Date().getTime(); y: 0 }
- function tempAdd(value_)
- {
- var time_ = new Date();
-
- if (value_ > valueAxis.max)
- valueAxis.max = value_;
+ }
+ LineSeries {
+ id: netSeriesOut
+ name: "OutOctets"
- loadSeries.append(time_.getTime(), value_);
- timeAxis.max = time_;
+ axisX: timeNetAxis
+ axisY: octetsAxis
- if (loadSeries.count > 1800)
- {
- loadSeries.remove(0);
- time_.setMinutes(time_.getMinutes() - 30);
- timeAxis.min = time_;
+ XYPoint { x: new Date().getTime(); y: 0 }
}
+ function updateStats(in_, out_)
+ {
+ var time_ = new Date();
+
+ if (in_ > octetsAxis.max)
+ octetsAxis.max = (in_ / 1000 + 1) * 1000;
+ if (out_ > octetsAxis.max)
+ octetsAxis.max = (out_ / 1000 + 1) * 1000;
+
+ netSeriesIn.append(time_.getTime(), in_);
+ netSeriesOut.append(time_.getTime(), out_);
+ timeNetAxis.max = time_;
+
+ if (netSeriesIn.count > 1800)
+ {
+ netSeriesIn.remove(0);
+ netSeriesOut.remove(0);
+ time_.setMinutes(time_.getMinutes() - 30);
+ timeNetAxis.min = time_;
+ }
- chartView.update();
+ networkChart.update();
+ }
}
}
}
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;
+}
diff --git a/app/taskmanager.h b/app/taskmanager.h
index 180c379..1ee351d 100644
--- a/app/taskmanager.h
+++ b/app/taskmanager.h
@@ -30,6 +30,7 @@ signals:
void removeProcess(int tid_);
void showProcessInfo(const QString info_);
void updateLoadAverage(double value_);
+ void updateNetworkStats(unsigned int in_, unsigned int out_);
private slots:
void query();
@@ -41,11 +42,13 @@ private slots:
private:
MessageEngine *m_loop;
std::vector<ProcInfo> m_procinfos;
+ unsigned int inOctets, outOctets;
void ProcessResponse(Message *message);
void ProcessResponseTasklist(QJsonArray& processes);
void ProcessResponseExtraInfo(QJsonObject& info);
void ProcessResponseLoadAvg(QJsonObject& loadInfo);
+ void ProcessResponseNetStat(QJsonObject& netstat);
};
#endif // TASKMANAGER_H