You are not logged in.

#1 2010-07-26 14:19:42

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Sending a notification email: scripted or cron?

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)

Offline

#2 2010-07-26 15:13:26

KimTjik
Member
From: Sweden
Registered: 2007-08-22
Posts: 715

Re: Sending a notification email: scripted or cron?

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

Offline

#3 2010-07-31 18:03:23

Spip
Member
From: USA
Registered: 2010-07-29
Posts: 28

Re: Sending a notification email: scripted or cron?

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.

Offline

#4 2010-08-19 10:58:38

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: Sending a notification email: scripted or cron?

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.

Offline

Board footer

Powered by FluxBB