This is exactly what I thought of doing this morning when I noticed that one of my trunks failedā¦
I donāt know why it does that but once in a while Asterisk decides that one of its trunk is unreachable and it has to be restarted to work againā¦
Anybody knows why? It sounds like an Asterisk bug to meā¦
When I noticed the problem I, of course, restarted Asterisk and started googling around and found a few matches (including one on this forum, Notification when trunk is down, which is unfortunately incomplete and I am no Python guruā¦).
One of those matches suggested using https://sourceforge.net/projects/swatch/ and when I saw the similarity between it and fail2ban I realized fail2ban could most likely be used to do this.
I have not yet tried to make a fail2ban rule for this but my guess is that it would definitely be doableā¦
Good luck and have a nice day!
Nick
ps: The trunk that failed is the one that provides 911 service!