mirror of https://github.com/aredn/aredn.git
Minor wifi monitor improvements for better metrics reporting (#875)
This commit is contained in:
parent
8c4d9edd99
commit
7650b627e8
|
@ -55,10 +55,10 @@ local action_limits = {
|
||||||
}
|
}
|
||||||
-- Start action state assuming the node is active and no actions are pending
|
-- Start action state assuming the node is active and no actions are pending
|
||||||
local action_state = {
|
local action_state = {
|
||||||
done_scan1 = true,
|
scan1 = true,
|
||||||
done_scan2 = true,
|
scan2 = true,
|
||||||
done_rejoin1 = true,
|
rejoin1 = true,
|
||||||
done_rejoin2 = true
|
rejoin2 = true
|
||||||
}
|
}
|
||||||
local unresponsive = {
|
local unresponsive = {
|
||||||
max = 0,
|
max = 0,
|
||||||
|
@ -193,7 +193,10 @@ end
|
||||||
function M.run_actions()
|
function M.run_actions()
|
||||||
-- No action if we have stations and they're responsive
|
-- No action if we have stations and they're responsive
|
||||||
if station_count.last_nonzero > station_count.last_zero and unresponsive.max < action_limits.unresponsive_trigger1 then
|
if station_count.last_nonzero > station_count.last_zero and unresponsive.max < action_limits.unresponsive_trigger1 then
|
||||||
action_state = {}
|
for k, _ in pairs(action_state)
|
||||||
|
do
|
||||||
|
action_state[k] = false
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -201,25 +204,25 @@ function M.run_actions()
|
||||||
|
|
||||||
-- If network stations falls to zero when it was previously non-zero
|
-- If network stations falls to zero when it was previously non-zero
|
||||||
if station_count.first_zero > station_count.first_nonzero then
|
if station_count.first_zero > station_count.first_nonzero then
|
||||||
if not action_state.done_scan1 and station_count.last_zero - station_count.first_zero > action_limits.zero_trigger1 then
|
if not action_state.scan1 and station_count.last_zero - station_count.first_zero > action_limits.zero_trigger1 then
|
||||||
M.reset_network("scan-quick")
|
M.reset_network("scan-quick")
|
||||||
action_state.done_scan1 = true
|
action_state.scan1 = true
|
||||||
return
|
return
|
||||||
elseif not action_state.done_scan2 and station_count.last_zero - station_count.first_zero > action_limits.zero_trigger2 then
|
elseif not action_state.scan2 and station_count.last_zero - station_count.first_zero > action_limits.zero_trigger2 then
|
||||||
M.reset_network("scan-all")
|
M.reset_network("scan-all")
|
||||||
action_state.done_scan2 = true
|
action_state.scan2 = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- We are failing to ping stations we are associated with
|
-- We are failing to ping stations we are associated with
|
||||||
if unresponsive.max >= action_limits.unresponsive_trigger1 and not action_state.done_rejoin1 then
|
if unresponsive.max >= action_limits.unresponsive_trigger1 and not action_state.rejoin1 then
|
||||||
M.reset_network("rejoin")
|
M.reset_network("rejoin")
|
||||||
action_state.done_rejoin1 = true
|
action_state.rejoin1 = true
|
||||||
return
|
return
|
||||||
elseif unresponsive.max >= action_limits.unresponsive_trigger2 and not action_state.done_rejoin2 then
|
elseif unresponsive.max >= action_limits.unresponsive_trigger2 and not action_state.rejoin2 then
|
||||||
M.reset_network("rejoin")
|
M.reset_network("rejoin")
|
||||||
action_state.done_rejoin2 = true
|
action_state.rejoin2 = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -248,6 +251,11 @@ function M.start_monitor()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- No stations when we start
|
||||||
|
local now = nixio.sysinfo().uptime
|
||||||
|
station_count.first_zero = now
|
||||||
|
station_count.last_zero = now
|
||||||
|
|
||||||
wait_for_ticks(math.max(1, 120 - nixio.sysinfo().uptime))
|
wait_for_ticks(math.max(1, 120 - nixio.sysinfo().uptime))
|
||||||
|
|
||||||
-- Extract all the necessary wifi parameters
|
-- Extract all the necessary wifi parameters
|
||||||
|
@ -256,6 +264,8 @@ function M.start_monitor()
|
||||||
frequency = iwinfo.nl80211.frequency(wifi)
|
frequency = iwinfo.nl80211.frequency(wifi)
|
||||||
ssid = iwinfo.nl80211.ssid(wifi)
|
ssid = iwinfo.nl80211.ssid(wifi)
|
||||||
if not (phy and frequency and ssid) then
|
if not (phy and frequency and ssid) then
|
||||||
|
log:write("Startup failed")
|
||||||
|
log:flush()
|
||||||
exit_app()
|
exit_app()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue