Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Attention: The Community will be in read-only mode on 12/14/2017 from 12:00 am pacific to 11:30 am.

During this time you will only be able to see content. Other interactions such as posting, replying to questions, or marking content as helpful will be disabled for few hours.

We apologize for the inconvenience while we perform important updates to the Community.

New Member

Parsing Script

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
Silver

Re: Parsing Script

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

115
Views
0
Helpful
1
Replies
CreatePlease to create content