I made a little script to reestablish a dropped network called testnetconn and it's working very nicely.
I did a little log check the other day and discovered that testnetconn has actually restored my network connection quite a few times since I started running it.
Now I think it would be nice to add an email notification when the script re-establishes the network.
Should I set this notification up directly in the script (adding variables for email address, subject, etc to the config file) or, seeing as cron runs the script anyway, recommend getting notifications from cron instead?
The first way seems more complete but the 2nd way seems much more holistic.
I should also mention that the script writes to the system logs as well, so I guess you could get notifications from a log watching tool too.
Opinions, ideas or suggestions most welcome.
Last edited by dtw (2010-07-26 14:25:07)
It looks easier to me that you simply send the content of the already created log file by cron. You wouldn't need any extra log watching tool for that, if it's not a question of adding a whole list of different logs to it. If you have a working mailer on the PC/server you could make a simple one-liner script for cron by using mutt.
mutt -F /path/to/muttrc -s "some title" -- e-mail_address@something < /path/to/log_file
Another possibility could be logwatch. If you configure it correctly, you can receive (generally a daily mail) a digest of your log included the one you want to keep an eye on.
Logwatch is not a daemon, it is run by crond.
Thanks for the suggestions. I had a look at using sSMTP and putting something straight in the script but I think it's better to let people manage notifications how they want. Cron actually emailed me today when the script kicked in and I don't recall even setting that up, so I guess that pretty much covers it!
I think writing to the logs, which allows logwatch to cover it too, is probably enough.