added code the create mail aliase for trap handler in snmp.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@947 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-03-31 15:57:15 +00:00
parent 40b8590c41
commit 67b4dba325

View File

@ -68,6 +68,9 @@ sub start {
#enable MMAs if any
configMPA(1);
#configure mail to enabling receiving mails from trap handler
configMail();
return (0, "started")
}
@ -257,6 +260,7 @@ sub configMPA {
return ($ret_val, $ret_text);
}
#--------------------------------------------------------------------------------
=head3 configSNMP
This function puts xcat_traphanlder into the snmptrapd.conf file and
@ -341,6 +345,35 @@ sub configSNMP {
return (0, "started");
}
#--------------------------------------------------------------------------------
=head3 configMail
This function adds a "alerts" mail aliase so that the mail notification
from the trap handler can be received. It the alerts already exists, this
function does nothing.
TODO: configure mail servers on MS to forward mails to MS
Arguments:
none
Returns:
(return code, message)
=cut
#--------------------------------------------------------------------------------
sub configMail {
#check if "alerts" is in the /etc/aliases file
if (-f "/etc/aliases"){
# if the file exists, check if alerts is in
`/bin/grep -e ^alerts /etc/aliases > /dev/null`;
if ($? ==0) { return (0, "") };
}
#make a alerts aliase, forwarding the mail to the root of local host.
`echo "alerts: root" >> /etc/aliases`;
#make it effective
`newaliases`;
return (0, "");
}
#--------------------------------------------------------------------------------
=head3 stop