How to be notified if an interface is down?
Is there a tool already built-in to notify me if an interface goes down? I want to not only be informed but I also want to know if attempts are made to reconnect again.
1- If the PPoE interface goes down, I want an e-mail message to be put in queue to be sent to me once the connection is back up.
2- If PPoE is down, I want the interface to continuously and repeatedly query the DSL provider for an IP and connection. I think that happens by default but for my piece of mind I want to confirm this if it happens.
3- At a later stage, what I want to do is to actually connect to an Asterisk server which is connected to the pfsense router to place a call through the analogue lines to inform me of the down interface. I guess once I have #1 and #2 confirmed and figured out then #3 can be easily implemented.
#2 happens automatically, it reconnects as many times as it takes. It wouldn't be wise to generate an e-mail on each attempt.
As for #1, SMTP (and Growl) notifications are in 2.0, but I don't think we have an 'interface down' notification, though it could be done.
Not sure how you'd pull off #3, but I doubt anything that relied on Asterisk would be in the base system.
Where should I look for the code to detect an interface down. I abandoning other ideas and will be just sending a request to Asterisk server to make a call rather than e-mail alerts. Asterisk server is on the same network so it's very unlikely that LAN port will go down.
Any pointers are greatly appreciated.
If you are looking for a hard interface failure (e.g. the port is unplugged or CPE powered off) look into the link events in /etc/devd.conf (read the FreeBSD man page)
As for a "soft" failure, such as a high delay or connectivity loss (no pings returned) you might be able to get that info from /tmp/apinger.status
Or just route the system logs to another server (the system log settings page can do this) and have something that watches/parses the log and reports on failures there.