diff options
Diffstat (limited to 'logdrake')
-rwxr-xr-x | logdrake | 87 |
1 files changed, 86 insertions, 1 deletions
@@ -33,7 +33,7 @@ Gtk->set_locale; use my_gtk qw(:helpers :wrappers); use MDK::Common; - +use Data::Dumper; #------------------------------------------------------------- # i18n routines # IMPORTANT: next two routines have to be redefined here to @@ -69,6 +69,7 @@ for (@ARGV) { /^--explain=(.*)$/ and do { $::isExplain = ($::Explain) = $1; $::isFile=1; $::File="/var/log/explanations"; next }; /^--file=(.*)$/ and do { $::isFile = ($::File) = $1; next }; /^--word=(.*)$/ and do { $::isWord = ($::Word) = $1; next }; + /^--alert$/ and do { alert_config(undef, $in); exit; }; } $::isTail=1 if ($::isFile); @@ -358,6 +359,87 @@ sub log_output { #------------------------------------------------------------- +# mail/sms alert +#------------------------------------------------------------- + +sub alert_config { + my ($prefix, $in) = @_; + $::Wizard_pix_up = "wiz_drakgw.png"; # FIXME + $::Wizard_title = _("Mail/SMS alert"); + +my $cron =q(#!/usr/bin/perl +# generated by logdrake +use MDK::Common; +my $r= "*** ". chomp_(`date`) . " ***\n"; + +); + + my ($load,$mail,$email,$smtp,$sms,$smssend); + $load=3; + + begin: + $::isWizard = 1; + $::Wizard_no_previous = 1; + $in->ask_okcancel(_("Mail/SMS alert configuration"), + _("Welcome to the mail/SMS configuration utility.\n\nHere, you'll be able to set up \n" + ), 1); + step_service: + undef $::Wizard_no_previous; + my $l ={ + http => ["/etc/init.d/httpd", _("Apache is a World Wide Web server. It is used to serve HTML files and CGI."), '$r .= "Apache is not running\n" if (`[ -x /etc/init.d/httpd ] && LC_ALL=C /etc/init.d/httpd status` =~ /\*not\* running/);'], + bind => ["/etc/init.d/named", _("named (BIND) is a Domain Name Server (DNS) that is used to resolve host names to IP addresses."), ], + ftp => ["/etc/init.d/proftpd", _("proftpd"), '$r .= "FTP server (proftpd) is not running\n" unless (`[ -x /etc/init.d/proftpd ] && /etc/init.d/proftpd status 2>&1 > /dev/null`);'], + postfix => ["/etc/init.d/postfix", _("Postfix is a Mail Transport Agent, which is the program that moves mail from one machine to another."), '$r .= "Postfix is not running\n" unless (`[ -x /etc/init.d/postfix ] && LC_ALL=C /etc/init.d/postfix status`);'], + samba => ["/etc/init.d/smb", ("samba"), '$r .= "samba is not running\n" unless (`[ -x /etc/init.d/smb ] && LC_ALL=C /etc/init.d/smb status`);'], + sshd => ["/etc/init.d/sshd", _("sshd"), '$r .= "sshd is not running\n" unless (`[ -x /etc/init.d/sshd ] && LC_ALL=C /etc/init.d/sshd status`);'], + webmin => ["/etc/init.d/webmin", _("webmin"), '$r .= "webmin is not running\n" unless (`[ -x /etc/init.d/webmin ] && LC_ALL=C /etc/init.d/webmin status`);'], + xinetd=> ["/etc/init.d/xinetd", _("xinetd"), '$r .= "xinetd is not running\n" unless (`[ -x /etc/init.d/xinetd ] && LC_ALL=C /etc/init.d/yxinetd status`);'], + }; + + $in->ask_from(_("service setting"), + _("You will recieve an alert if one of the selected service is no more running"), + [ map { {label => "$_", val=> \${$_}, type => "bool", text => "$l->{$_}[1]" }; } keys %$l + ]) or goto begin; + + $cron .= "#- check services\n"; + for (keys %$l) { + $cron .= $l->{$_}[2]."\n" if (${$_}); + } + + step_load: + $in->ask_from(_("load setting"), + _("You will recieve an alert if the load is upper than this value"), + [ + { label => "load ", val => \$load, type => 'range', min => 1, max => 50 }, + ]) or goto step_service; + + $cron .= q@ +#- load +my ($load) = split ' ', first(cat_("/proc/loadavg")); +$r .= "Load is huge: $load\n" if ($load >@ . "$load);\n\n"; + + step_output: + $in->ask_from(_("window title - ask_from"), + _("message\nexamples of utilisation of ask_from"), + [ + { label => "mail", val => \$mail, type => "bool", text => "mail output" }, + { label => "email", val => \$email, disabled => sub { !$mail; }}, + { label => "smtp ??", val => \$smtp, disabled => sub { !$mail; } }, + { label => "", text => "jjjjjjjjjjj" }, + { label => "sms output", val => \$sms, type => "bool", text => "you need some rpm, and to have set up smsend\nThis service can be unavailable on some countries" }, + { label => "smssend output", val => \$smssend , disabled => sub {!$sms;}}, + ]) or goto step_load; + +#output("/etc/cron.hourly/logdrake_alert.pl", ($cron)); + $cron .= q@#- report it +print $r; +# EOF@; + print $cron; + $in->exit(0); +} + + +#------------------------------------------------------------- # menu callback functions #------------------------------------------------------------- @@ -420,6 +502,9 @@ sub destroy_window { # log # $Log$ +# Revision 1.31 2002/01/27 01:58:23 yduret +# added --alert feature +# # Revision 1.30 2002/01/26 20:42:30 yduret # --explain= feature # |