1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
#!/usr/bin/perl
use strict;
system("cls");
print "Bienvenu dans le programme d\'analyseur de log\n";
print " Quel type de log voulez-vous analyser ?\n\n";
print " 1.Apache\n";
print " 2.IIS\n\n";
my $num = (<STDIN>);
system("cls");
print " Veuillez entrer le numero correspondant a l\'action voulue :\n\n";
print " 1.Hits des adresses IP\n";
print " 2.Hits des pages les plus visitees\n";
print " 3.Hits des Referer\n";
print " 4.Hits en Ko\n";
print " 5.Hits des navigateurs\n";
print " 6.Quitter le programme\n\n";
open(Fichier, "log") || die "Problème à l\'ouverture : $!";
my($ligne,@ips,$ip,%total,@pages,$page,%total1,@ref,$ref,%total2,@ko,$ko,%total3,@nav,$nav,%total4);
if ($num == "1") {
while (<Fichier>) {
@ips = (split /\s+/)[0];
foreach $ip (@ips) {
$total{$ip}++;
}
@pages = (split /\s+/)[6];
foreach $page (@pages) {
$total1{$page}++;
}
@ref = (split /\s+/)[9];
foreach $ref (@ref) {
$total2{$ref}++;
}
@ko = (split /\s+/)[8];
foreach $ko (@ko) {
$total3{$ko}++;
}
@nav = (split /\s+/)[10];
foreach $nav (@nav) {
$total4{$nav}++;
}
}
}
elsif ($num == "2") {
while (<Fichier>) {
@ips = (split /\s+/)[0];
foreach $ip (@ips) {
$total{$ip}++;
}
@pages = (split /\s+/)[3];
foreach $page (@pages) {
$total1{$page}++;
}
@ref = (split /\s+/)[6];
foreach $ref (@ref) {
$total2{$ref}++;
}
@ko = (split /\s+/)[8];
foreach $ko (@ko) {
$total3{$ko}++;
}
@nav = (split /\s+/)[12];
foreach $nav (@nav) {
$total4{$nav}++;
}
}
}
else {
print "\nNumero invalide - Au revoir\n";
exit;
}
close(Fichier);
my $num1 = (<STDIN>);
if ($num1 == "1") {
&subip();
}
elsif ($num1 == "2") {
&subpage();
}
elsif ($num1 == "3") {
&subref();
}
elsif ($num1 == "4") {
&subko();
}
elsif ($num1 == "5") {
&subnav();
}
else {
print "\nA bientot\n";
exit;
}
sub subip {
foreach $ip (sort keys %total)
{
print "IP : $ip a ete rencontre $total{$ip} fois\n";
}
exit;
}
sub subpage {
foreach $page (sort keys %total1)
{
print "La Page \"$page a ete visitee $total1{$page} fois.\n";
}
exit;
}
sub subref {
foreach $ref (sort keys %total2)
{
print "Le referer $ref a ete vu $total2{$ref} fois.\n";
}
exit;
}
sub subko {
foreach $ko (sort keys %total3)
{
print "Voici le hit des Kilos octets : $ko ko\n";
}
exit;
}
sub subnav {
foreach $nav (sort keys %total4)
{
print "Le navigateur $nav a ete rencontre $total4{$nav} fois.\n";
}
exit;
} |
Partager