|
|
@ -1,7 +1,8 @@ |
|
|
|
#!/usr/bin/perl -w |
|
|
|
#!/usr/bin/perl -w |
|
|
|
|
|
|
|
|
|
|
|
use Mail::Send; |
|
|
|
|
|
|
|
use esmith::ConfigDB; |
|
|
|
use esmith::ConfigDB; |
|
|
|
|
|
|
|
use MIME::Lite; |
|
|
|
|
|
|
|
use Net::SMTP; |
|
|
|
|
|
|
|
|
|
|
|
my $c = esmith::ConfigDB->open_ro(); |
|
|
|
my $c = esmith::ConfigDB->open_ro(); |
|
|
|
my $domain = $c->get('DomainName')->value(); |
|
|
|
my $domain = $c->get('DomainName')->value(); |
|
|
@ -9,15 +10,22 @@ my $host = $c->get('SystemName')->value(); |
|
|
|
my $z = $c->get('zabbix-agent'); |
|
|
|
my $z = $c->get('zabbix-agent'); |
|
|
|
my $dest = $z->prop('StatusRecipient') || 'admin@' . $domain; |
|
|
|
my $dest = $z->prop('StatusRecipient') || 'admin@' . $domain; |
|
|
|
|
|
|
|
|
|
|
|
my $mail = new Mail::Send; |
|
|
|
my $smtp = Net::SMTP->new('localhost'); |
|
|
|
$mail->to("$dest"); |
|
|
|
my $mail = MIME::Lite->new( |
|
|
|
$mail->set("From","zabbix-agent"); |
|
|
|
From => 'smeserver-status@' . $domain, |
|
|
|
$mail->subject("[STATUS] $host.$domain"); |
|
|
|
To => $dest, |
|
|
|
my $body = $mail->open; |
|
|
|
Subject => "[STATUS] $host.$domain", |
|
|
|
print $body localtime(time)."\n", |
|
|
|
Data => localtime(time)."\n" . |
|
|
|
"\n#>tail /var/log/messages :\n", |
|
|
|
"\n#>tail /var/log/messages :\n" . |
|
|
|
`/usr/bin/tail \$(readlink /var/log/messages)`, |
|
|
|
`/usr/bin/tail \$(readlink /var/log/messages)` . |
|
|
|
"\n#>netstat --numeric-hosts -tpu :\n", |
|
|
|
"\n#>netstat --numeric-hosts -tpu :\n" . |
|
|
|
`/bin/netstat --numeric-hosts -tpu`; |
|
|
|
`/bin/netstat --numeric-hosts -tpu` |
|
|
|
$body->close; |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$smtp->mail('smeserver-status@' . $domain); |
|
|
|
|
|
|
|
$smtp->recipient($dest); |
|
|
|
|
|
|
|
$smtp->data(); |
|
|
|
|
|
|
|
$smtp->datasend($mail->as_string); |
|
|
|
|
|
|
|
$smtp->dataend(); |
|
|
|
|
|
|
|
$smtp->quit; |
|
|
|
|
|
|
|
|
|
|
|