1 |
vip-ire |
1.1 |
diff -Nur smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats smeserver-zabbix-agent-0.1_mod/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats |
2 |
|
|
--- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats 2011-05-04 17:21:02.000000000 +0200 |
3 |
|
|
+++ smeserver-zabbix-agent-0.1_mod/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats 2011-05-04 17:26:11.000000000 +0200 |
4 |
|
|
@@ -1,11 +1,20 @@ |
5 |
|
|
{ |
6 |
|
|
if ((${'zabbix-agent'}{'status'} || 'disabled') eq 'enabled'){ |
7 |
|
|
-$OUT .=<<"HERE"; |
8 |
|
|
+ $OUT .=<<"HERE"; |
9 |
|
|
|
10 |
|
|
# Parse mail logs and write stats in zabbix tmp directory |
11 |
|
|
*/10 * * * * root /var/lib/zabbix/bin/mail_in.sh |
12 |
|
|
*/10 * * * * root /var/lib/zabbix/bin/mail_out.sh |
13 |
|
|
|
14 |
|
|
HERE |
15 |
|
|
+ |
16 |
|
|
+ if ((${'zabbix-agent'}{'StatusMail'} || 'disabled' ) eq 'enabled'){ |
17 |
|
|
+ $OUT .=<<"HERE"; |
18 |
|
|
+ |
19 |
|
|
+# Send a status mail |
20 |
|
|
+*/15 * * * * root /var/lib/zabbix/bin/mailstatus.pl |
21 |
|
|
+ |
22 |
|
|
+HERE |
23 |
|
|
+ } |
24 |
|
|
} |
25 |
|
|
} |
26 |
|
|
diff -Nur smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mailstatus.pl smeserver-zabbix-agent-0.1_mod/root/var/lib/zabbix/bin/mailstatus.pl |
27 |
|
|
--- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mailstatus.pl 1970-01-01 01:00:00.000000000 +0100 |
28 |
|
|
+++ smeserver-zabbix-agent-0.1_mod/root/var/lib/zabbix/bin/mailstatus.pl 2011-05-04 17:22:24.000000000 +0200 |
29 |
|
|
@@ -0,0 +1,23 @@ |
30 |
|
|
+#!/usr/bin/perl -w |
31 |
|
|
+ |
32 |
|
|
+use Mail::Send; |
33 |
|
|
+use esmith::ConfigDB; |
34 |
|
|
+ |
35 |
|
|
+my $c = esmith::ConfigDB->open_ro(); |
36 |
|
|
+my $domain = $c->get('DomainName')->value(); |
37 |
|
|
+my $host = $c->get('SystemName')->value(); |
38 |
|
|
+my $z = $c->get('zabbix-agent'); |
39 |
|
|
+my $dest = $z->prop('StatusRecipient') || 'admin@' . $domain; |
40 |
|
|
+ |
41 |
|
|
+my $mail = new Mail::Send; |
42 |
|
|
+$mail->to("$dest"); |
43 |
|
|
+$mail->set("From","zabbix-agent"); |
44 |
|
|
+$mail->subject("[STATUS] $host.$domain"); |
45 |
|
|
+my $body = $mail->open; |
46 |
|
|
+print $body localtime(time)."\n", |
47 |
|
|
+ "\n#>tail /var/log/messages :\n", |
48 |
|
|
+ `/usr/bin/tail /var/log/messages`, |
49 |
|
|
+ "\n#>netstat --numeric-hosts -tpu :\n", |
50 |
|
|
+ `/bin/netstat --numeric-hosts -tpu`; |
51 |
|
|
+$body->close; |
52 |
|
|
+ |