浏览代码

mesh-batman-adv-core: add clientcount statistics

This adds

  "client" { "total": <int>, "wifi": <int>" }

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.
Nils Schneider 10 年之前
父节点
当前提交
a1d27aefbb
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. 20 0
      package/gluon-mesh-batman-adv-core/files/lib/gluon/announce/statistics.d/clients

+ 20 - 0
package/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
+       }