my $Log_Path;
my $OPLOG_PATH;
my $Start_Time_Dur;
my $End_Time_Dur;
my $Category ;
my $op_file ;
if (scalar @ARGV < 2) {
die "
***********************************************************
USAGE:
Option1 : $0 Log_File_Name Flag
Option2 : $0 Log_File_Name Flag ArrayCounter
Help :
perl $0 Log_File_Name --flags
flags are:
--Help Suggests the usage for the script and the flags available
--Default 1. Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}
2. Top ten URL's Response Time wise, Top Ten URL Download Wise, Hourly Frequency of load
--Hourly Outputs Hourly hit/response time/download amount from URL's
--CategoryWise Outputs category wise hit/response time/download amount from URL's
--Categ_Hourly Outputs Hourly as well as Category wise hit/response time/download amount from URL's
--Download Outputs download amount from URL's
--Cat_Download Outputs Category wise download amount from URL's
--Hourly_Download Outputs Hourly download amount from URL's
--Create_Hourly_Logs This Creates the Hourly Log as per the requirement
--All3Ip Output's 3 ip's which are present at IP field
--URL Output's the unique URL
--HperIP Output's Hit's Per Ip
"
}
else {
$Log_Path = $ARGV[0] || '';
}
use strict;
my $array_counter = $ARGV[2] || '15';
print "Number of Rows Requested : ".$array_counter."\n";
my %hash1 = ();
my @array1;
my $output_file;
my @arrays;
my @hourly_log;
my $scalar1;
my %seen = ();
my $tim;
my $waqt;
my $series;
my $text;
my @hitsip;
my @respons;
my @topten;
my @qwe;
my @dada;
my @highrespo;
my @all3ip;
my @sorthosize;
my @bothvalue;
my $oneval;
my @topten_size;
my @topten_cat_size;
my @topten_onlycat_size;
my @sorthousize;
my @toptensize;
my @sortsize;
my @highsize;
my @sortcat;
my @sortdowcatonly;
my @diff_value;
my @hourly_op;
my @topt_3;
my @next3array;
my $pages;
my @special;
my @next3soarray;
my @sortcatonly;
my $how;
my @topten_hourly;
my @highestsize;
my @topten_onlycat;
my %count;
my @sortcatsize;
my @topten_cat;
my @nextarray;
my @nextsoarray;
my @sortqwe;
my @grephours ;
my @timarr = (1 .. 24);
my ($begin_time, $end_time, $total_hits);
my ($Start_Hour,$Start_Min,$End_Hour,$End_Min);
my ($host, $ident_user, $auth_user, $date, $time, $time_zones, $farji, $farji2i, $farji3, $farji4, $farji5, $farji6, $farji7, $farji8, $farji9, $farji10, $farji11, $farji12) ;
my ($hour, $min, $sec) ;
print "Log File Used for Parsing is -->$Log_Path"."\n";
open (MYFILE,$Log_Path) || die "Error : $!";
############### parse command line argument and choose the right request to server ############
if ($ARGV[1] =~ "--Hourly") {
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
&break_component ;
&hourly_repso ;
&hourly_size;
} elsif ($ARGV[1] =~ "--Default") {
print "Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}";
&break_component ;
&genral_behav ;
&hou_only_size;
&download_wise;
&cat_only_size;
} elsif ($ARGV[1] =~ "--CategoryWise") {
print " Give Category you want to analyze ";
chomp($Category = <STDIN>);
print " Category Choosen --> ".$Category."\n";
&break_component ;
&category_wise ;
&categ_down_wise;
} elsif ($ARGV[1] =~ "--Categ_Hourly") {
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
print " Give Category you want to analyze ";
chomp($Category = <STDIN>);
print " Category Choosen --> ".$Category."\n";
&break_component ;
&hourcateg_repso;
&download_wise;
&hourly_cat_size;
} elsif ($ARGV[1] =~ "--Download") {
&break_component ;
&download_wise ;
&cat_only_size;
} elsif ($ARGV[1] =~ "--Cat_Download") {
print " Give Category you want to analyze ";
chomp($Category = <STDIN>);
print " Category Choosen --> ".$Category."\n";
&break_component ;
&category_wise ;
} elsif ($ARGV[1] =~ "--Hourly_Download") {
print " Analyze Hourly Download ";
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
&break_component ;
&categ_down_wise;
&hourly_size ;
} elsif ($ARGV[1] =~ "--Create_Hourly_Logs") {
print " Analyze Category Wise Hourly Download ";
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
print "Give THe File Name To wirte the Logs-->"."\n";
chomp($output_file = <STDIN>);
print "Output File Name is --> ".$output_file."\n";
#print "Give Category you want to analyze ";
#chomp($Category = <STDIN>);
#print " Category Choosen --> ".$Category."\n";
&break_component ;
&hourly_op ;
} elsif ($ARGV[1] =~ "--All3Ip") {
&break_component;
&new_all3_ip ;
}
elsif ($ARGV[1] =~ "--URL") {
&break_component;
&uniqe_url;
&greedy_parse;
&parse_unique;
} elsif ($ARGV[1] =~ "--HperIP") {
&break_component;
&perIPhit;
}
############### parsing of command line argument over ############
my $OPLOG_PATH;
my $Start_Time_Dur;
my $End_Time_Dur;
my $Category ;
my $op_file ;
if (scalar @ARGV < 2) {
die "
***********************************************************
USAGE:
Option1 : $0 Log_File_Name Flag
Option2 : $0 Log_File_Name Flag ArrayCounter
Help :
perl $0 Log_File_Name --flags
flags are:
--Help Suggests the usage for the script and the flags available
--Default 1. Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}
2. Top ten URL's Response Time wise, Top Ten URL Download Wise, Hourly Frequency of load
--Hourly Outputs Hourly hit/response time/download amount from URL's
--CategoryWise Outputs category wise hit/response time/download amount from URL's
--Categ_Hourly Outputs Hourly as well as Category wise hit/response time/download amount from URL's
--Download Outputs download amount from URL's
--Cat_Download Outputs Category wise download amount from URL's
--Hourly_Download Outputs Hourly download amount from URL's
--Create_Hourly_Logs This Creates the Hourly Log as per the requirement
--All3Ip Output's 3 ip's which are present at IP field
--URL Output's the unique URL
--HperIP Output's Hit's Per Ip
"
}
else {
$Log_Path = $ARGV[0] || '';
}
use strict;
my $array_counter = $ARGV[2] || '15';
print "Number of Rows Requested : ".$array_counter."\n";
my %hash1 = ();
my @array1;
my $output_file;
my @arrays;
my @hourly_log;
my $scalar1;
my %seen = ();
my $tim;
my $waqt;
my $series;
my $text;
my @hitsip;
my @respons;
my @topten;
my @qwe;
my @dada;
my @highrespo;
my @all3ip;
my @sorthosize;
my @bothvalue;
my $oneval;
my @topten_size;
my @topten_cat_size;
my @topten_onlycat_size;
my @sorthousize;
my @toptensize;
my @sortsize;
my @highsize;
my @sortcat;
my @sortdowcatonly;
my @diff_value;
my @hourly_op;
my @topt_3;
my @next3array;
my $pages;
my @special;
my @next3soarray;
my @sortcatonly;
my $how;
my @topten_hourly;
my @highestsize;
my @topten_onlycat;
my %count;
my @sortcatsize;
my @topten_cat;
my @nextarray;
my @nextsoarray;
my @sortqwe;
my @grephours ;
my @timarr = (1 .. 24);
my ($begin_time, $end_time, $total_hits);
my ($Start_Hour,$Start_Min,$End_Hour,$End_Min);
my ($host, $ident_user, $auth_user, $date, $time, $time_zones, $farji, $farji2i, $farji3, $farji4, $farji5, $farji6, $farji7, $farji8, $farji9, $farji10, $farji11, $farji12) ;
my ($hour, $min, $sec) ;
print "Log File Used for Parsing is -->$Log_Path"."\n";
open (MYFILE,$Log_Path) || die "Error : $!";
############### parse command line argument and choose the right request to server ############
if ($ARGV[1] =~ "--Hourly") {
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
&break_component ;
&hourly_repso ;
&hourly_size;
} elsif ($ARGV[1] =~ "--Default") {
print "Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}";
&break_component ;
&genral_behav ;
&hou_only_size;
&download_wise;
&cat_only_size;
} elsif ($ARGV[1] =~ "--CategoryWise") {
print " Give Category you want to analyze ";
chomp($Category = <STDIN>);
print " Category Choosen --> ".$Category."\n";
&break_component ;
&category_wise ;
&categ_down_wise;
} elsif ($ARGV[1] =~ "--Categ_Hourly") {
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
print " Give Category you want to analyze ";
chomp($Category = <STDIN>);
print " Category Choosen --> ".$Category."\n";
&break_component ;
&hourcateg_repso;
&download_wise;
&hourly_cat_size;
} elsif ($ARGV[1] =~ "--Download") {
&break_component ;
&download_wise ;
&cat_only_size;
} elsif ($ARGV[1] =~ "--Cat_Download") {
print " Give Category you want to analyze ";
chomp($Category = <STDIN>);
print " Category Choosen --> ".$Category."\n";
&break_component ;
&category_wise ;
} elsif ($ARGV[1] =~ "--Hourly_Download") {
print " Analyze Hourly Download ";
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
&break_component ;
&categ_down_wise;
&hourly_size ;
} elsif ($ARGV[1] =~ "--Create_Hourly_Logs") {
print " Analyze Category Wise Hourly Download ";
print "Start Time of analysis Period ";
print "Start Time -->in format of HH:MM --> ";
chomp($Start_Time_Dur = <STDIN>);
($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
print $Start_Hour."\n" ;
print $Start_Min."\n" ;
}
else {
print "Start Time Should be in range of 00 to 24 hours ";
exit ;
}
print "End Time of analysis Period ";
print "End Time --> in format of HH:MM --> ";
chomp($End_Time_Dur = <STDIN>);
($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
print $End_Hour."\n" ;
print $End_Min."\n" ;
}
else {
print "End Time Should be in range of 00 to 24 hours ";
exit ;
}
if ($Start_Hour <= $End_Hour) {
print "This is Right Order Of Time Duration"."\n" ;
}
else {
print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
exit ;
}
if ($End_Hour == 24){
print "Default Value of End Minute when End Hour is 24"."\n" ;
$End_Min = 00 ;
print $End_Min."\n";
}
print "Give THe File Name To wirte the Logs-->"."\n";
chomp($output_file = <STDIN>);
print "Output File Name is --> ".$output_file."\n";
#print "Give Category you want to analyze ";
#chomp($Category = <STDIN>);
#print " Category Choosen --> ".$Category."\n";
&break_component ;
&hourly_op ;
} elsif ($ARGV[1] =~ "--All3Ip") {
&break_component;
&new_all3_ip ;
}
elsif ($ARGV[1] =~ "--URL") {
&break_component;
&uniqe_url;
&greedy_parse;
&parse_unique;
} elsif ($ARGV[1] =~ "--HperIP") {
&break_component;
&perIPhit;
}
############### parsing of command line argument over ############
No comments:
Post a Comment