cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
933
Views
18
Helpful
6
Replies

Methods for exporting statistics and/or flow data

d.parks
Level 1
Level 1

Hello,

Has anyone come up with a good way to retrieve statistics (flow information in particular) from the CSS platform?

I have an application owner who would like to periodically log information on service state and flow data. I suppose a telnet script or something of that nature would work, but I'd like to avoid giving command line access for something like this.

I would rather use a script or some other function that would result in the CSS exporting the data rather than having an outside process hit the CSS.

Thanks!

6 Replies 6

pknoops
Level 3
Level 3

I guess you could always run the "showtech" script on the CSS via command scheduler and make sure you dump it to disk. Then you could have another command scheduler grab the output (stored in /log/showtech.out) and ftp it off the CSS. The "script play showtech" has alot of useful infomation including "flow stats"

Maybe ??

Regards

Pete Knoops

Cisco Systems

Thanks Pete,

I think a showtech might be overkill since I really only need the output from "show flow {ip address}", but this gives me an idea.

I think I'll dig through the showtech script and see if I can use the file manipulation function(s) to write my own script. Perhaps a multipurpose version that will allow me to specify the command I want to run, filename, and destination for the output...

Thanks,

Dominic

Eureka! I've created a script that accepts a command, FTP record, and destination filename. The script executes the command directing output to a temporary file. The file FTP'd to the server and then deleted.

By running this script with the command scheduler, I can regularly export statistics from the CSS to a host as needed.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Filename: ftplogger

!

! Description:

!

! This script will execute a given command, (must be a

! single word command so use an alias if needed), direct the

! output to a temporary file, and then copy the file to a

! given FTP record.

!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!no echo

expert

if ${ARGS}[#] "NEQ" "3"

echo "usage: ftplogger \'command ftprecord filename\'"

exit script 1

endbranch

set command "${ARGS}[1]"

echo "Command issued is ${command}"

set ftprecord "${ARGS}[2]"

echo "FTP record requested is ${ftprecord}"

set ftpfile "${ARGS}[3]"

echo "FTP destination filename is ${ftpfile}"

set outfile ">> log/ftplogger.tmp"

echo "Temporary output file is log/ftplogger.tmp"

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Issue command and log to the local temporary file

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

no terminal more

${command} ${outfile}

terminal more

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Copy temporary file to the FTP server

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

copy log ftplogger.tmp ftp ${ftprecord} ${ftpfile}

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Delete temporary file

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

clear log ftplogger.tmp

no expert

exit script 0

Could you please explain how to run the script. I (hope you don't mind) copied the script into my CSS and tried to run it with the "script play" command. All I got was

CSSNDC_Extl# script play ftp_script

usage: ftplogger "command ftprecord filename"

Obviously I need to input something!

regards

Tony Barnett

Hi Tony,

You'll need to pass 3 parameters in order, enclosed in quotes.

1. The command you want to execute, (It has to be one word, so you may need an alias.)

2. The FTP record name for the FTP server where you want the file to go.

3. The filename that you want the output to appear as on the FTP server.

I ran into some issues when trying to use this with cmd-sched. The biggest issue is that I couldn't pass arguements due to the extra set of quotation marks required. To get around this, I had to simplify the script to just use hard-coded variables instead of arguments. The downside to this is that I'll need to create a new script for each specific use...

Here's one example of issuing a "show flow" command.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Filename: ftplogflow

!

! Description:

!

! This script will execute a given command, direct

! the output to a temporary file, and then copy the

! file to a given FTP record.

!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!no echo

expert

set cmdstr "flows 10.32.0.48"

set ftprecord "ace"

set ftpfile "flowinfo.txt"

set outfile ">> log/ftplogger.tmp"

echo "Command issued is ${cmdstr}"

echo "FTP record requested is ${ftprecord}"

echo "FTP destination filename is ${ftpfile}"

echo "Temporary output file is ${outfile}"

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Timestamp the output file

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

show clock ${outfile}

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Issue command and log to the local temporary file

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

no terminal more

show ${cmdstr} ${outfile}

terminal more

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Copy temporary file to the FTP server

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

copy log ftplogger.tmp ftp ${ftprecord} ${ftpfile}

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Delete temporary file

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

clear log ftplogger.tmp

no expert

exit script 0

Thanks for the response. The info is very much appreciated.

regards

Tony

Review Cisco Networking for a $25 gift card