Quantcast
Channel: THWACK: Popular Discussions - Script Lab
Viewing all articles
Browse latest Browse all 9937

Best way to use Log Parser with more than 10 statistics?

$
0
0

Please, hear out and try to understand my dilemma -- here is a list to retrace my steps.

 

1. First, there is already an extensive amount of ERROR(s) within the log file, and I have no way of telling which ones are unique to each other (meaning duplicates). Therefore, I decided to use PowerShell to regex the log file, getting rid of unneeded lines and text.

2. After an extensive amount of regex, I now have a big list of duplicate ERROR names (such as ClientAbortException, CancelledException, getLowLevelConnector.getConnection, Invalid query, java.lang.NullPointerException, etc.).

3. Then I wrote more code in PowerShell for Solarwinds using no arguments for regex (since the log file is already regex'd):

POWERSHELL:

$f_path = $args.get(0);

 

#Conditional Testing for f_path and regex

if(!$f_path)

{

write-host "Message: The argument 'f_path' was unable to process."

}

if ( !$(Test-Path $f_path) )

  {

  Write-Host "Message: File $f_path not found."

  }

 

#CREATE INSTANCE OF ARRAYS for COUNT and NAME

$arrC = @()

$arrN = @()

 

#Find the count for every single name.

#Write-Host Count Name

#Below is an attempt to keep the code generic by pulling unique ERRORs (group), putting them in a array, and looping the array.

$group = get-content $f_path | group

 

$total = $group.Count

 

for ( $i = 0 ; $i -le $total; $i++ ) {

  $arrC += @($i)

  $arrN += @($i)

  }

 

$i = 1

 

#PUT DATA INTO ARRAYs

$stat = $group | select count, name | ForEach-Object {

  $arrC[$i] = $_.count

  $arrN[$i] = $_.name

  $i = $i + 1

  }

 

  $i= 1;

 

for($i=1; $i -le $total; $i++){

  write-host "Statistic.$i : "$arrC[$i]

  write-host "Message.$i : " $arrN[$i]

}

 

#IF NOTHING IN THE GROUP

if ($total -eq 0)

{

write-host "Statistic: 0"

write-host "Message: No strings found"

}

 

RESULT DISPLAYS CORRECTLY:

Statistic.1 :  315

Message.1 :  ClientAbortException

Statistic.2 :  127

Message.2 :  CancelledException

Statistic.3 :  75

Message.3 :  getLowLevelConnector.getConnection

Statistic.4 :  35

Message.4 :  Invalid queryQCustomObjectQuery

Statistic.5 :  18

Message.5 :  java.lang.NullPointerException

Statistic.6 :  7

Message.6 :  Scheduled

Statistic.7 :  2

Message.7 :  ContainerBackgroundProcessorStandardEnginejboss.web getLowLevelConnector.getConnection

Statistic.8 :  2

Message.8 :  java.lang.StringIndexOutOfBoundsExceptionString index out of range0

Statistic.9 :  3

Message.9 :  java.lang.IndexOutOfBoundsExceptionIndex0, Size0

 

Now I'm thinking, awesome! I got the correct results! I don't have to do anything else....

Dilemma:

What if the pre-regex'd file ends up containing more than 10 unique duplicate ERROR's, which is more than Solarwinds allows per component??

How do I get around this problem?

Should I trust the fact that my regex will always be correct, manually set ERROR arguments to avoid regex, and hope for the best?

 

Any thoughts on the best way to handle my dilemma would be appreciated!


Viewing all articles
Browse latest Browse all 9937

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>