Quantcast
Channel: THWACK: Message List - Kiwi Syslog
Viewing all articles
Browse latest Browse all 2141

Re: Kiwi Syslog - replace string on alert

$
0
0

Hi Kstone,

yes exactly I would like to search more peer.

For this reason today I worked on a script (VB Script) and it works.

Basically the script do this things:

1) extract the neighbor IP from the log and save it on a variable (obviusly I filter the log using KSS filter in order to match only the ospf neighbot up/down events)

2) Then the script search the IP in a CSV file where on the first column I have the nbr IP and in the second column the value that I would like to save in a variable (varcustom) that print out in the alert email

 

This is the script (i have only to manage the case the the nbr IP is not listed.. new peer.. but this is simple, I'll do it tomorrow) :

 

Function Main()

strSyslog = VarRawMessageText

Set objRE = New RegExp

 

'Extract Neighbor IP

With objRE

    .Pattern    = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"

    .IgnoreCase = True

    .Global     = False

End With

 

Set objMatch = objRE.Execute( strSyslog )

 

'Set the Variabe varIP with the neighbor IP to parse the file

If objMatch.Count = 1 Then

    varIP = objMatch.Item(0)

End If

 

Const ForReading = 1

 

'Create the file system object

Set fso = CreateObject("Scripting.FileSystemObject")

 

'Open the source file to read it

set ts = fso.OpenTextFile("C:\temp\codifica.csv",ForReading)

 

'Read the file line by line

Do while not ts.AtEndOfStream

strLine = ts.ReadLine

'Split the line on the comma into an array

strValues = Split(strLine, ",")

'Check if the dq number matches

If strValues(0) = varIP Then

'Get the other values you need

varCustom01 = strValues(1)

'Exit the loop

Exit Do

End If

Loop

 

'Close the file

ts.Close

'Clean up

Set ts = Nothing

Set fso = Nothing

 

 

Main = "OK"

End Function

 

 

Thanks!


Viewing all articles
Browse latest Browse all 2141

Trending Articles