From cb66d542db83504001d99f50d044c281dc5951d8 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 10 Aug 2014 12:49:56 +0200 Subject: [PATCH] mesh-batman-adv-core: add clientcount statistics This adds "client" { "total": , "wifi": " } to statistics.d. "total" will be the number of clients connected. "wifi" will be the number of clients connected over wifi. I.e. "total" will always be equal to or greater than "wifi". The node will not count itself. --- .../lib/gluon/announce/statistics.d/clients | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 gluon/gluon-mesh-batman-adv-core/files/lib/gluon/announce/statistics.d/clients diff --git a/gluon/gluon-mesh-batman-adv-core/files/lib/gluon/announce/statistics.d/clients b/gluon/gluon-mesh-batman-adv-core/files/lib/gluon/announce/statistics.d/clients new file mode 100644 index 0000000..235865e --- /dev/null +++ b/gluon/gluon-mesh-batman-adv-core/files/lib/gluon/announce/statistics.d/clients @@ -0,0 +1,20 @@ +local list = io.lines("/sys/kernel/debug/batman_adv/bat0/transtable_local") + +local count = 0 +local wifi = 0 +for line in list do + local mac, _, flags, lastseen = line:match("^ %* ([0-9a-f:]+) *(.- )%[(.-)%] +(%d+%.%d+)") + if mac then + if not flags:match('P') then + count = count + 1 + + if flags:match('W') then + wifi = wifi +1 + end + end + end +end + +return { total = count + , wifi = wifi + }