Hello,
I am new on perl and want to do one script who will ask for the name of the log file to analyse and will give the statictics :
1- the covered period of the log (start-end) by date and hours;
2- the total number of lines (traces) foreach adress;
3-the total numbers of traces for each service;
4-the total number of connections pop, ssh and imap;
5- the list of addresses that made a ssh connection and how many for each
6- list of adresses that sent an email by sendmail and how many for each
example of log to ananyle :
I start my script with this code :
[CODE=perl]#!/usr/bin/perl
print "Gime me the filename";
chop ($name = <STDIN>);
my @file = $name;
open(LOG,"@file ") or die "Unable to open logfile:$!\n";
while(<LOG>){
my @lines = <LOG>;
foreach $ligne (@lignes)
{ }
close(LOG);[/CODE]
I am new on perl and want to do one script who will ask for the name of the log file to analyse and will give the statictics :
1- the covered period of the log (start-end) by date and hours;
2- the total number of lines (traces) foreach adress;
3-the total numbers of traces for each service;
4-the total number of connections pop, ssh and imap;
5- the list of addresses that made a ssh connection and how many for each
6- list of adresses that sent an email by sendmail and how many for each
example of log to ananyle :
Code:
Jan 13 04:05:43 client.IRO.UMontreal.CA sendmail[22674]: i0D95hr8022674: from=root, size=271, class=0, nrcpts=1, msgid=<200401130905.i0D95hr8022674@client.IRO.UMontreal.CA>,relay=root@localhost Jan 13 04:05:44 client.IRO.UMontreal.CA sendmail[22674]: i0D95hr8022674: to=root, ctladdr=root (0/1), delay=00:00:01, mailer=relay, pri=30271, relay=[127.0.0.1], dsn=2.0.0, stat=Sent (i0D95hEt022675 Message accepted for delivery) Jan 13 04:05:45 server.IRO.UMontreal.CA sendmail[22627]: i0D95jQ6022627: from=<root@gamma.IRO.umontreal.ca>, size=750, class=0, nrcpts=1,msgid=<200401130905.i0D95hr8022674@client.IRO.UMontreal.CA>, proto=ESMTP, daemon=MTA, relay=client.IRO.UMontreal.CA [132.204.24.102] Jan 13 04:08:20 server.IRO.UMontreal.CA sendmail[23390]: i0D98KQ6023390:<cpm2000@IRO.UMontreal.CA>... User unknown Jan 13 04:12:41 server.IRO.UMontreal.CA ipop3d[26735]: pop3 service init from 132.204.24.100 Jan 13 04:12:41 server.IRO.UMontreal.CA ipop3d[26735]: Logout user=??? host=server.IRO.UMontreal.CA [132.204.24.100] Jan 13 04:12:42 server.IRO.UMontreal.CA imapd[26748]: imap service init from 132.204.24.100 Jan 13 04:12:42 server.IRO.UMontreal.CA imapd[26748]: Logout user=??? host=server.IRO.UMontreal.CA [132.204.24.100] Jan 13 04:13:58 server.IRO.UMontreal.CA sudo: fmserver : TTY=none ; PWD=/home/fmserver/bin ; USER=root ; COMMAND=/bin/du -sk /home/ouimet Jan 13 04:15:27 alpha.IRO.UMontreal.CA sshd2[412]: connection from "132.204.24.100"
[CODE=perl]#!/usr/bin/perl
print "Gime me the filename";
chop ($name = <STDIN>);
my @file = $name;
open(LOG,"@file ") or die "Unable to open logfile:$!\n";
while(<LOG>){
my @lines = <LOG>;
foreach $ligne (@lignes)
{ }
close(LOG);[/CODE]
Comment