Parsing Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 01:55 PM - edited 03-02-2019 05:49 AM
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.
- Labels:
-
Other Networking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2003 04:35 AM
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 /
# 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
