#!/bin/perl use strict; my $major=0; my $minor=0; my $critical=0; my $systime=0; my $syshr = 0; my $sysmin=0; my $syssec=0; $systime=`date '+%H:%M:%S'`; ($syshr,$sysmin,$syssec) = split(/:/,$systime); printf("Hr: $syshr Min: $sysmin Sec: $syssec"); my $errorcount = 0; my $k = 0; my @logdesc; chdir('/opt/vk/app/osa/ecp/current/log/') or die "chdir Failed $! \n"; ### This is the array in which we are grepping Critical and Major alarms @logdesc=`egrep 'MAJOR|CRITICAL' AppOsaEcp.log | cut -f 1-2 -d "]" | sort | uniq`; # printf("##### 1st line $logdesc[0]\n"); my $arraycount = 0 ; $arraycount=@logdesc; my @fields; my @errorstring; @fields=split(/\s+/,$logdesc[0]); printf("\n\nCritical and Major errors observerd during last one hour are : \n\n"); my $i=0; my $loghr=0; my $logmin=0; my $logsec=0; my @errorarray; my $cnt=0; my $s=0; my $matchcount=0; ###### Parsing the log file to find alarms depending on time-stamp to find erros in last one hour for($i=0;$i<=$arraycount;$i++) { (@fields) = split(/\s+/,$logdesc[$i]); ($loghr,$logmin,$logsec) = split(/:/,$fields[1]); if(($syshr == 0) && ($loghr == 23)) { if( $logmin > $sysmin ) { if( $fields[3] =~ /MAJOR/ ) { $major++; } if( $fields[3] =~ /CRITICAL/ ) { $critical++; } if( $fields[3] =~ /MINOR/ ) { $minor++; } $errorarray[$cnt++] = $fields[4]; for($s=0;$s<$cnt;$s++) { if( $errorarray[$s] eq "$fields[4]" ) { $matchcount++; } } (@errorstring) = split(/]/,$logdesc[$i]); if( $matchcount == 1 ) { printf("$fields[0] $fields[1] $errorstring[1]"); } } } if(( $syshr >= 0) && ($loghr >= 0)) { my $dhr = 0; $dhr=$syshr-$loghr; if( $dhr == 1) { if( $logmin >= $sysmin ) { if( $fields[3] =~ /MAJOR/ ) { $major++; } if( $fields[3] =~ /CRITICAL/ ) { $critical++; } if( $fields[3] =~ /MINOR/ ) { $minor++; } $errorarray[$cnt++] = $fields[4]; for($s=0;$s<$cnt;$s++) { if( $errorarray[$s] eq "$fields[4]" ) { $matchcount++; } } (@errorstring) = split(/]/,$logdesc[$i]); if( $matchcount == 1 ) { printf("$fields[0] $fields[1] $errorstring[1]"); } } } if( $dhr == 0) { if( $logmin < $sysmin ) { if( $fields[3] =~ /MAJOR/ ) { $major++; } if( $fields[3] =~ /CRITICAL/ ) { $critical++; } if( $fields[3] =~ /MINOR/ ) { $minor++; } $errorarray[$cnt++] = $fields[6]; for($s=0;$s<$cnt;$s++) { if( $errorarray[$s] eq "$fields[4]" ) { $matchcount++; } } (@errorstring) = split(/]/,$logdesc[$i]); if( $matchcount == 1 ) { printf("$fields[0] $fields[1] $errorstring[1]"); } } } } } print "\n\nCount of Alarms in Last One Hour .............. \n\n"; print "CRITICAL = $critical\nMAJOR = $major\nMINOR = $minor \n\n"; #### Critical and Major errors observerd during last one hour are : 2009-06-18 09:36:18,666 MAJOR com.vk.service.rating.server.task.RateRequestTask - RATING ERROR - chargingSessionId: 25999, chargingParameters: Undefined: 9999,Item: ECP Postpaid_Prepaid,SubType: RateQuery,Spid: 53,Calling Party Number: 6768874971,Called Party Number: a126a8864884,Bearer Service: 00,BillNum: 6768874971,RatePlan: RP5301`53,ScpId: 9999,UsageHist: ,DateTime: 20090618093618,FlatFee: Count of Alarms in Last One Hour .............. CRITICAL = 0 MAJOR = 81 MINOR = 0 #### Critical and Major errors observerd during last one hour are : Critical Alarms 2009-06-18 09:36:18,666 CRITICAL com.vk.service.rating.server.task.OrginatingCallContext ( * With lastest timestamp) Count=4 2009-06-18 09:36:18,666 CRITICAL com.vk.service.rating.server - Call Threshold reached Cont=10 Major Alarms 2009-06-18 09:36:18,666 MAJOR com.vk.service.rating.server.task.RateRequestTask - RATING ERROR - chargingSessionId: 25999, chargingParameters:: 0,FCA: true,**********SPLIT RATING PARAMETER**********ServiceId: -2,Split Rating Amount: 0 Count = 20 2009-06-18 09:36:18,666 MAJOR com.vk.service.rating.server - Connection tmeout Count = 5