Event Handler:Executables (preferably Lua scripts) in /etc/fonstated/
Scheduler Configuration:/etc/config/fonstate
Fire an event:Lua: require "luci.fon.event".new("EVENT")
CBI: = {"EVENT"}
Shell: fs -l EVENT
Immediately process an event (sync.):Lua: require "luci.fon.event".runnow("EVENT")
Shell: /etc/fonstated/EVENT
Immediately process an event (async.):Lua: require "luci.fon.event".runnow_nowait("EVENT")
Shell: /etc/fonstated/EVENT &


Fonstated is an event driven system scheduler and a core component of the Fon-ng firmware. It serves as a system event dispatcher and is therefore responsible for triggering the start up of services on system boot time after the basic system has been initialized as well as for handling system events like configuration changes that trigger actions like restarting running daemons, configuration of system components or external hardware.


Events are actions initiated by specific system status changes such as configuration changes, gaining / loosing internet connection or user intervention.

Each event has a unique alphanumeric identifier. Events can be registered by creating an executable - preferably Lua script - with the event identifier as filename under /etc/fonstated. Therefore a list of registered events can be obtained by listing the contents of this directory.

Triggering an event through fonstated:

The usual way of triggering an event is queueing it through fonstated. Queued events may not be handled immediately but at a point where handling the event will most likely not result in risking the operation or stability of the system which could otherwise happen if many events are triggered concurrently. Therefore events should - whenever possible

  • be triggerd through fonstated.

Lua / LuCI:

local event = require "luci.fon.event""EVENT")


-- node can be any CBI Map, Section or Value
-- events will be triggered whenever the node value is changed = {"EVENT"}


fs -l EVENT

Immediately triggering an event:

However there might be special cases where an event requires immediate action. Therefore you can trigger event handlers directly.

Lua / LuCI:

local event = require "luci.fon.event"
event.runnow("EVENT") -- synchronously
-- or
event.runnow_nowait("EVENT") -- asynchronously


Last modified 10 years ago Last modified on Dec 31, 2008, 5:14:22 PM