From 8d8a209df65b153a35e7886c24d39067c75a7914 Mon Sep 17 00:00:00 2001 From: stransky Date: Sun, 10 Feb 2002 17:08:11 +0100 Subject: [PATCH] nouvelle fonction : j'ai ajout l'affichage de la prriode d'analyse darcs-hash:20020210160811-a279a-d8b5814ac5b464a07db463de477320ae51763573.gz --- analyse.pl | 58 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/analyse.pl b/analyse.pl index 39f60db0..0cec8564 100755 --- a/analyse.pl +++ b/analyse.pl @@ -5,7 +5,7 @@ ## Made by Vincent HANQUEZ ## ## Started on Tue 09 Oct 2001 01:28:25 AM CEST tab -## Last Update jeu 07 fév 2002 08:47:59 CET Nicolas STRANSKY +## Last Update dim 10 fév 2002 16:55:24 CET Nicolas STRANSKY ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,8 +21,8 @@ ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. ## ## -## AUTEUR: Tab -## MAINTAINERS: Tab, Nicolas STRANSKY +## AUTEUR: Vincent HANQUEZ +## MAINTAINERS: Vincent HANQUEZ, Nicolas STRANSKY ## ## DESCRIPTION: analyse permet de creer des resumes des fichiers de ## log cree par net-acct. Net-acct est un daemon qui permet de logguer toutes @@ -53,13 +53,15 @@ my $pattern_ip = my ($opt_download, $opt_upload) = 0; my $opt_dnsresolve = 1; my $opt_normalize = 1; -my $opt_config = 1; +#my $opt_config = 1; +my $opt_config = 0; my $opt_file = "/var/log/net-acct/net-acct.log.0"; my $opt_configfile = "/etc/analyse.conf"; my $opt_host = ""; my $opt_mail = ""; my $opt_number = -1; my $bad_arg = 0; +my $period = 1; $opt_upload = 1; ######## ERROR GEST ######## @@ -79,6 +81,7 @@ sub usage print "\t --nonorm\tNe transforme pas les nombres en forme plus lisible (Ko, Mo, Go)\n"; print "\t --today\tChiffres du jour, analyse de /var/log/net-acct/net-acct.log\n"; print "\t --noconfig\tNe charge pas les options du fichier de config\n"; + print "\t --noperiod\tN'affiche pas la période sur laquelle porte l'analyse\n"; print "\t --help\tAffiche cette aide\n"; print "\n"; print "par defaut si l'option n'est pas utilise:\n"; @@ -156,6 +159,29 @@ sub show_all { $way1 = "down"; $way2 = "up"; } # on affiche $nb_to_print entree, en ayant trier les machines +if ($period) +{ + open (INPUT, $opt_file) || die ("Unable to open $opt_file"); + my $line1 = ; + my $firstdate = (split "\t", $line1)[0]; + my $firstdate2 = strftime("Analyse depuis le %d-%m-%Y %H:%M:%S", localtime($firstdate)); + print $firstdate2; + print "\n"; + close (INPUT); + + my $t = open (INPUT, $opt_file); + seek(INPUT, -90, 2); + my $lastlineX = ; + my $lastline = ; + my $lastdate = (split "\t", $lastline)[0]; + my $lastdate2 = strftime(" jusq'au %d-%m-%Y %H:%M:%S", localtime($lastdate)); + print $lastdate2; + print "\n"; + close(INPUT); + + print "\n";} + + for (my $dec = $nb_to_print; $dec > 0; $dec--) { foreach my $ip (keys %db) @@ -204,6 +230,27 @@ sub get_host_info close (INPUT); # printing info +if ($period) +{ + open (INPUT, $opt_file) || die ("Unable to open $opt_file"); + my $line1 = ; + my $firstdate = (split "\t", $line1)[0]; + my $firstdate2 = strftime("Analyse depuis le %d-%m-%Y %H:%M:%S", localtime($firstdate)); + print $firstdate2; + print "\n"; + close (INPUT); + + my $t = open (INPUT, $opt_file); + seek(INPUT, -90, 2); + my $lastlineX = ; + my $lastline = ; + my $lastdate = (split "\t", $lastline)[0]; + my $lastdate2 = strftime(" jusq'au %d-%m-%Y %H:%M:%S", localtime($lastdate)); + print $lastdate2; + print "\n"; + close(INPUT); + + print "\n";} print "--- Info for $ip_search ---"; print "\n"; @@ -337,6 +384,7 @@ Getopt::Long::GetOptions 'nodns' => sub { $opt_dnsresolve = 0; }, 'nonorm' => sub { $opt_normalize = 0; }, 'noconfig' => sub { $opt_config = 0; }, + 'noperiod' => sub { $period = 0; }, 'today' => sub { $opt_file = "/var/log/net-acct/net-acct.log"; } ) or $bad_arg = 1; @@ -354,9 +402,9 @@ if ($opt_config) if ($opt_mail ne "") { $mail_msg = new Mail::Send; - $mail_fh = $mail_msg->open(); $mail_msg->to($opt_mail); $mail_msg->subject("[ANALYSE]"); + $mail_fh = $mail_msg->open(); close (STDOUT); open (STDOUT, ">/tmp/analyse_mail"); }