Created
January 20, 2012 10:46
-
-
Save hydra35/1646664 to your computer and use it in GitHub Desktop.
retrieve wireless status from OpenWRT then send to tsdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(cmd) | |
local f = assert(io.popen(cmd, 'r')) | |
--local f = assert(io.open('a', 'r')) | |
local cur_station = '' | |
local result = {} | |
for line in f:lines() do | |
fst_char = string.sub(line, 0, 1) | |
if fst_char == "S" then | |
captured = string.match(line, "Station%s(%x%x:%x%x:%x%x:%x%x:%x%x:%x%x)") | |
if captured then cur_station = captured end | |
else | |
key, value = string.match(line, "%s+([%w ]+):%s+([%w.]+)") | |
if key then | |
point = string.format("put wireless.%s %s %s mac=%s", | |
string.gsub(key, "%s", '_'), os.time(), value, cur_station) | |
print(point) | |
end | |
end | |
end | |
end | |
main('iw dev wlan0 station dump') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment