For a while now I’ve been having to restart snmpd on my linux based router running CentOS whenever my PPPoE connection to my ADSL provider went down. This is because the interface disappeared, snmpd cracked it and returned 0 for all snmp queries until it was restarted. This becomes a royal pain when monitoring connection throughput with things like cacti or mrtg.
After getting sick of this the other day, I actually found a solution!
The file /etc/ppp/ip-up.local is run every time a PPP connection is established! This means I can restart snmpd from within this file and have it done automatically – forever!
All that is required is that /etc/ppp/ip-up.local contains:
#!/bin/bash /etc/init.d/snmpd restart
You could also use the same file to call scripts to update dynamic DNS providers like homeip.net etc as well!