#!/usr/bin/perl
#
# Error handler routines for Postgres Redundancy Program
#
# usage is Er-Handler(comma seperated message list)
sub Er_Handler
{
	#get date
	$date=&ctime(time);
	chomp($date);
	chomp($_[0]);
	#write message to error file
	open(ERRF,">>/home/postgres/data/error")||die"could not open error file\n";
 	print ERRF "\-\>Error on $_[1] Postgres Redundancy Program:$date\n";
	print ERRF "$_[0]\<\-\n";
	close(ERRF);
	#write message to E-mail
#	open(MAIL,"|/var/qmail/bin/qmail-inject") || die "could not mail\n";
	open(MAIL,"|/var/qmail/bin/qmail-inject") || die "could not mail\n";
	print MAIL "To: root\@veritime.com\n";
	print MAIL "From: root\@veritime.com\n";
	print MAIL "Subject: Postgres Redundancy Error\n";
	print MAIL "\n\n";
	print MAIL "The following Error has occured in the $_[1] \n";
	print MAIL "On $date\n";
	print MAIL "$_[0]\n";
	print MAIL ".\n";
	close(MAIL);
	
	print "Redundancy Error\n";
	print "An error has occurred\n";
	print "A message has been sent to the administrator.\n";
	print "If error continues please contact root\@veritime.com.\n";
 	print "\n";
#	exit;
}
1;#return true
