ifplug.d style eventing?

James Aimonetti <>
Sun Jul 18 17:48:40 CEST 2010


I have a board with three ethernet nics and have some monitoring
software running in erlang that polls the nics for their config data
(addr, broadaddr, netmask) every 30 seconds or so. I'm using
inet:getiflist/0 and inet:ifget/2 to do the data retrieval. This data
is then sent to a remote server and processed, with the response being
tailored to the data sent, and the monitoring code updating various
config files (a dhcp server, some iptables rules, etc).

Side note: is there a simple way to authoritatively find out the
gateway address for a nic? It could prove useful down the road, but I
didn't see it as an option to inet:ifget/2.

I was wondering if there was a way, in Erlang, to have an event
listener on the nics that I could subscribe to instead of polling?
Where I could detect a nic coming up or going down because a cable was
plugged/unplugged, or, if the nic is configured with dhcp when the IP
changes, things of that nature.

The other piece I'm having trouble with is testing, of the nics that
are up, which have WAN access. I'd like, during all of this
polling/eventing, that I could test if a configured nic is able to
access our remote server. So if eth0 and eth1 are up (say on init),
test both connections to see if I can reach the server; later, should
eth0 go down for whatever reason, and both had WAN access, I could
modify my configs to use eth1 as the failover WAN.

I appreciate any help.

James


More information about the erlang-questions mailing list