Email/SMS alert when state changed [howto]

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
Posts: 195
Joined: Thu Oct 11, 2007 5:10 am

Email/SMS alert when state changed [howto]

Post by haus » Tue Nov 25, 2008 11:45 pm

If you want to get an email/SMS alert when the runstate of your ZM box changes, go to line 110 of /usr/bin/

After "Info( "Updating DB: $state->{Name}\n" );", and add these lines:

Code: Select all

my $newstate = uc $state->{Name};
open(SENDMAIL, "|/usr/sbin/sendmail -oi -t -f<FROM_ADDRESS> -odb") or die "Can't fork for sendmail: $!\n";
print SENDMAIL <<"EOF";
Subject: ZoneMinder: $newstate

With these important caveats:

1. there is no space between "-f" and the from address. If your from address is "", it should read ""

2. <EMAIL_ADDRESS> has to be escaped. If your to: address is, it should look like "To: recipient\".

Hope that helps...kind of a nice touch. Now I can pull my USB stick on the way out and get a confirmation that the system actually armed. Not that it has ever failed so far, but still nice to know.

This only works when the runstate changes, not when the system is started or stopped (those are other code blocks within You can modify the code and placement if that information is important to you, etc.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests