diff --git a/agent.py b/agent.py index bc26bc4..e251e2d 100755 --- a/agent.py +++ b/agent.py @@ -95,8 +95,11 @@ class Network: num=0 for interface in psutil.net_if_addrs(): exec("self.net_"+str(num)+" = {}") + interface_usage = psutil.net_io_counters(pernic=True) for detail in psutil.net_if_addrs()[interface]: exec("self.net_"+str(num)+"['name'] = '"+str(interface)+"'") + exec("self.net_"+str(num)+"['bytes_sent'] = '"+str(human_size(interface_usage[interface].bytes_sent))+"'") + exec("self.net_"+str(num)+"['bytes_recv'] = '"+str(human_size(interface_usage[interface].bytes_recv))+"'") ip_pattern = re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") if ip_pattern.match(detail.address): exec("self.net_"+str(num)+"['address_v4'] = '"+str(detail.address)+"'") diff --git a/templates/index.html b/templates/index.html index 0e37c14..744d173 100644 --- a/templates/index.html +++ b/templates/index.html @@ -133,10 +133,10 @@ total : {{ full[key]['size_total'] }} / used : {{ full[key]['size_used'] }} / fr
- + {% for key in full %} {% if key.startswith('net_') %} - + {% endif %} {% endfor %}
NameIPv4Netmask v4IPv6Netmask v6
NameIPv4Netmask v4IPv6Netmask v6SentReceived
{{ full[key]['name'] }}{{ full[key]['address_v4'] }}{{ full[key]['netmask_v4'] }}{{ full[key]['address_v6'] }}{{ full[key]['netmask_v6'] }}
{{ full[key]['name'] }}{{ full[key]['address_v4'] }}{{ full[key]['netmask_v4'] }}{{ full[key]['address_v6'] }}{{ full[key]['netmask_v6'] }}{{ full[key]['bytes_sent'] }}{{ full[key]['bytes_recv'] }}
@@ -148,25 +148,28 @@ total : {{ full[key]['size_total'] }} / used : {{ full[key]['size_used'] }} / fr const config = { type: 'line', data: { - labels: Array(30).fill("0000-00-00 00:00:00"), + labels: Array(60).fill("0000-00-00 00:00:00"), datasets: [{ label: "CPU %", backgroundColor: 'rgb(0, 191, 255)', borderColor: 'rgb(0, 191, 255)', - data: Array(30).fill(null), + data: Array(60).fill(null), fill: false, + pointRadius: 0, },{ label: "Mem %", - backgroundColor: 'rgb(255,240,100)', - borderColor: 'rgb(255, 240, 100)', - data: Array(30).fill(null), + backgroundColor: 'rgb(255,200,20)', + borderColor: 'rgb(255,200,20)', + data: Array(60).fill(null), fill: false, + pointRadius: 0, },{ label: "Swap %", backgroundColor: 'rgb(255, 20, 100)', borderColor: 'rgb(255, 20, 100)', - data: Array(30).fill(null), + data: Array(60).fill(null), fill: false, + pointRadius: 0, }], }, options: { @@ -212,7 +215,7 @@ total : {{ full[key]['size_total'] }} / used : {{ full[key]['size_used'] }} / fr const source = new EventSource("/chart-ressources/{{ node }}"); source.onmessage = function (event) { const data = JSON.parse(event.data); - if (config.data.labels.length === 30) { + if (config.data.labels.length === 60) { config.data.labels.shift(); config.data.datasets[0].data.shift(); config.data.datasets[1].data.shift();