cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
356
Views
0
Helpful
1
Replies

Parsing Script

caplanner
Level 1
Level 1

Hi all-

I'm looking to find a method by which to load Cisco router output logs into statisctical software. In otherwords, I need to take a fairly messy text file and convert it into several database tables. I've been informed that these output logs are standard; apparently the logfile I am seeing will be similar to the one you would get. Before I start coding a parsing script I'm hoping to find if any of you have any experience with this problem, and possibly, have such a script you would like to share.

Thanks.

1 Reply 1

donewald
Level 6
Level 6

This is not quite a databasing script but a Syslog parser that might help you write what you need. Hope this helps you.

if `test -f $1`

then

ls //$1* > file.out

# Above is needed if there are mutliple syslog files and you want to report on them all

# this will make a listing of the files in a file called file.out and go through them all

for m in `cat $HOME/file.out` ; do `cat "$m" | egrep "^$2" | grep % | cut -d " " -f 1-20 >>$HOME/report.out` ; done

echo There have been `cat $HOME/report.out | cut -d" " -f3,4,8 | wc -l` syslog messages on $2

# Gets the syslog Messages and outputs them to "log.out"

cat $HOME/report.out | cut -d"%" -f 2 | cut -d " " -f 1 | sort -u > log.out

# Gets the number of each syslog Message and outputs them to "numbers.out"

for i in `cat $HOME/report.out | cut -d "%" -f 2 | cut -d " " -f 1 | sort -u` ; do echo `grep $i $HOME/report.out |wc -l`;done > numbers.out

#Get the number of routers for each syslog message and output them to "routers.out"

for a in `cat log.out` ; do echo `cat $HOME/report.out |grep $a | cut -d " " -f 4 | sort -u |wc -l`; done > routers.out

echo These are the different syslog messages that were reported

echo "Message ID Number of Messages Number of Routers Reporting this"

paste -d '\t \t ' log.out numbers.out routers.out

#rm *.out

else

echo "$1 is not a file"

fi

Regards,

Don