version 1.120, 2020/01/11 21:54:31
|
version 1.121, 2020/01/11 22:37:19
|
Line 1096 sub write_hostips {
|
Line 1096 sub write_hostips {
|
if (keys(%prevhosts) && keys(%currhosts)) { |
if (keys(%prevhosts) && keys(%currhosts)) { |
foreach my $key (keys(%prevhosts)) { |
foreach my $key (keys(%prevhosts)) { |
unless ($currhosts{$key} eq $prevhosts{$key}) { |
unless ($currhosts{$key} eq $prevhosts{$key}) { |
$ipchange{$key} = $prevhosts{$key}.' | '.$currhosts{$key}.' |'; |
$ipchange{$key} = $prevhosts{$key}.' | '.$currhosts{$key}; |
} |
} |
} |
} |
foreach my $key (keys(%currhosts)) { |
foreach my $key (keys(%currhosts)) { |
unless ($currhosts{$key} eq $prevhosts{$key}) { |
unless ($currhosts{$key} eq $prevhosts{$key}) { |
$ipchange{$key} = $prevhosts{$key}.' | '.$currhosts{$key}.' |'; |
$ipchange{$key} = $prevhosts{$key}.' | '.$currhosts{$key}; |
} |
} |
} |
} |
} |
} |
Line 1109 sub write_hostips {
|
Line 1109 sub write_hostips {
|
if (keys(%ipchange)) { |
if (keys(%ipchange)) { |
if (open(my $fh,'>>',$perlvar{'lonDaemons'}.'/logs/hostip.log')) { |
if (open(my $fh,'>>',$perlvar{'lonDaemons'}.'/logs/hostip.log')) { |
print $fh "********************\n".localtime(time).' Changes --'."\n". |
print $fh "********************\n".localtime(time).' Changes --'."\n". |
"Hostname | Previous IP | New IP |\n". |
"| Hostname | Previous IP | New IP |\n". |
"--------------------------------\n"; |
" --------------------------------- \n"; |
foreach my $hostname (sort(keys(%ipchange))) { |
foreach my $hostname (sort(keys(%ipchange))) { |
print $fh "$hostname | $ipchange{$hostname}\n"; |
print $fh "| $hostname | $ipchange{$hostname} |\n"; |
} |
} |
print $fh "\n*******************\n\n"; |
print $fh "\n*******************\n\n"; |
close($fh); |
close($fh); |
Line 1127 sub write_hostips {
|
Line 1127 sub write_hostips {
|
"MIME-Version: 1.0\n\n". |
"MIME-Version: 1.0\n\n". |
"Host/IP changes\n". |
"Host/IP changes\n". |
" \n". |
" \n". |
"Hostname | Previous IP | New IP |\n". |
"| Hostname | Previous IP | New IP |\n". |
"--------------------------------\n"; |
" --------------------------------- \n"; |
foreach my $hostname (sort(keys(%ipchange))) { |
foreach my $hostname (sort(keys(%ipchange))) { |
$chgmail .= "$hostname | $ipchange{$hostname}\n"; |
$chgmail .= "| $hostname | $ipchange{$hostname} |\n"; |
} |
} |
$chgmail .= "\n\n"; |
$chgmail .= "\n\n"; |
if (open(my $mailh, "|/usr/lib/sendmail -oi -t -odb")) { |
if (open(my $mailh, "|/usr/lib/sendmail -oi -t -odb")) { |