소스 검색

Merge pull request #62 from freifunk-gluon/clientcount

mesh-batman-adv-core: add clientcount statistics
Nils Schneider 9 년 전
부모
커밋
40321595a9
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
+       }