From 86a89a372ec2c09894d5fa7bc1fff2421f484a88 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 10 Dec 2019 15:47:45 +1000 Subject: Add RRD data collection, and a speed graph. --- README.md | 1 + apt-panopticon-report-RRD.lua | 16 ++++++++++++ apt-panopticon-report-email-web.lua | 51 +++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100755 apt-panopticon-report-RRD.lua diff --git a/README.md b/README.md index 992b6ee..fd7849e 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ installed - * luajit * LuaSocket, on Debian based systems it'll be in the lua-socket package. * md5sum and sha256, on Debian based systems they'll be in the coreutils package. +* rrdtool, may need to include lua-rrd. * xz, on Debian based systems it'll be in the xz-utils package. Using it. diff --git a/apt-panopticon-report-RRD.lua b/apt-panopticon-report-RRD.lua new file mode 100755 index 0000000..dfe21d2 --- /dev/null +++ b/apt-panopticon-report-RRD.lua @@ -0,0 +1,16 @@ +#!/usr/bin/env luajit + +local APT = require 'apt-panopticommon' +local D = APT.D +local I = APT.I +local W = APT.W +local E = APT.E +local C = APT.C +local arg, sendArgs = APT.parseArgs({...}) + + +APT.mirrors = loadfile("results/mirrors.lua")() +APT.html = false +for k, v in APT.orderedPairs(APT.mirrors) do + APT.doRRD('results', k, v) +end diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index ef61183..7d4b0fc 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua @@ -231,6 +231,57 @@ if nil == email then C("opening mirrors file - " .. e) else end +local colours = +{ + 'f0000080', + '0f000080', + '00f00080', + '000f0080', + '0000f080', + '00000f80', + '80000080', + '08000080', + '00800080', + '00080080', + '00008080', + '00000880', + 'ff000080', + '0ff00080', + '00ff0080', + '000ff080', + '0000ff80', + '88000080', + '08800080', + '00880080', + '00088080', + '00008880', +} +local g = {} +local count = 0 +for k, v in APT.orderedPairs(mirrors) do + if 'pkgmaster.devuan.org' ~= k then count = count + 1 end +end +for i = 1, count do +end + +count = 1 +for k, v in APT.orderedPairs(mirrors) do + if 'deb.devuan.org' ~= k then + local c = colours[count] + if 'pkgmaster.devuan.org' == k then c = 'ffffff' end + table.insert(g, 'DEF:speed' .. count .. '=rrd/' .. k .. '/HTTP/Speed.rrd:max:LAST') + table.insert(g, 'VDEF:vspeed' .. count .. '=speed' .. count .. ',AVERAGE') + table.insert(g, 'LINE2:speed' .. count .. '#' .. c .. ':' .. k .. '\t') + table.insert(g, 'GPRINT:vspeed' .. count .. ':%5.1lf%s\\l') + count = count + 1 + end +end +APT.rrd.graph('results/speed.png', '--start', 'now-1w', '--end', 'now', '-t', 'Speed', '-v', 'bytes per second', '-w', '900', '-h', '400', '-Z', +'-c', 'BACK#000000', '-c', 'CANVAS#000000', '-c', 'FONT#FFFFFF', '-c', 'AXIS#FFFFFF', '-c', 'FRAME#FFFFFF', '-c', 'ARROW#FFFFFF', +unpack(g)) + + + results = {} m = {} faulty = "" -- cgit v1.1