cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1514
Views
10
Helpful
3
Replies

Supress Syslog Output for EEM Policy and write directly to remote FTP

Reuben Farrelly
Level 3
Level 3

I've got a slightly modified version of the handy findmyrouter.tcl script running on my 819G - but I'd like some assistance to make some tweaks to how it is working.  The original script can be found here:

https://supportforums.cisco.com/document/12018071/findmyrouterzip

On my router I have the following config:

event manager directory user policy "flash:/"
event manager policy findmyrouter.tcl type user

I have modified my own copy of this script slightly by adding the bottom to the end of it, so as to copy location.html to my server via FTP so that the location.html file is integrated into my website:

----------

        set filename "location.html"
        set fileId [open $filename "w"]
        puts -nonewline $fileId $data
        close $fileId

        cli_exec $cli1(fd) "enable"
        cli_exec $cli1(fd) "config t"
        cli_exec $cli1(fd) "file prompt quiet"
        cli_exec $cli1(fd) "do copy flash:location.html ftp://server://X/Y/index.html"
        cli_exec $cli1(fd) "default file prompt"
        cli_exec $cli1(fd) "end"

catch {cli_close $cli1(fd) $cli1(tty_id)}

------------

The questions I have are:

1. Is there a better way to achieve what I'm doing above?  I imagine it would be better to write the file directly to the ftp server instead of via local flash:, but I'm not sure how I would do that.  As the script runs every 10 mins I imagine the constant writing to local flash will eventuallly take it's toll on the flash card - and it's not necesssary anyway.

2. Every time the script runs it outputs the following to syslog:

Jan 16 10:10:01: %HA_EM-6-LOG: findmyrouter.tcl: regx = Jan 16 10:10:01 2015
Jan 16 10:10:02: %SYS-5-CONFIG_I: Configured from console by  on vty0 (EEM:findmyrouter.tcl)

How would I supress that output?  I really only need to know if there's an issue or error, not every time the script runs.

The router is currently running 15.5(1)T.

Thanks for any help

Reuben

1 Accepted Solution

Accepted Solutions

Dan Frey
Cisco Employee
Cisco Employee

I do not know of a way to do a file transfer without first making it a file on the local flash drive first.   You have a valid point that there are only so many read/write iterations before the flash drive goes bad and doing that every 10 minutes is too often.   If your router is stationary you could change the script to run less frequently.  
 

To remove the regx syslog message prepend the line with # and then re-register your eem policy.

#puts "regx = $mon $day $tod $year"

The other message is system generated and could be removed with syslog discriminator policy.

Another way to get this info from the router and from your entire network is to run a similiar policy from your webserver.   Attached is a Perl script that will poll all of you routers in the network (via snp) for GPS information then build a single file called location.html and will show the location of all of your router locations in googlemap.   Update the following in the Perl script then load onto your web server.

#load ip address of routers to do snmp polling.

@IP = qw(192.168.0.25 192.168.30.11 10.34.34.5);

#your snmp community string

$community = "public";


#webserver path for location.html

open(GPSAPI , "> /var/www/html/location.html");


# Update the script with your Google Map APIv3 key.

Your server will need net-snmp installed.  

 

 

 

 

 

View solution in original post

3 Replies 3

Dan Frey
Cisco Employee
Cisco Employee

I do not know of a way to do a file transfer without first making it a file on the local flash drive first.   You have a valid point that there are only so many read/write iterations before the flash drive goes bad and doing that every 10 minutes is too often.   If your router is stationary you could change the script to run less frequently.  
 

To remove the regx syslog message prepend the line with # and then re-register your eem policy.

#puts "regx = $mon $day $tod $year"

The other message is system generated and could be removed with syslog discriminator policy.

Another way to get this info from the router and from your entire network is to run a similiar policy from your webserver.   Attached is a Perl script that will poll all of you routers in the network (via snp) for GPS information then build a single file called location.html and will show the location of all of your router locations in googlemap.   Update the following in the Perl script then load onto your web server.

#load ip address of routers to do snmp polling.

@IP = qw(192.168.0.25 192.168.30.11 10.34.34.5);

#your snmp community string

$community = "public";


#webserver path for location.html

open(GPSAPI , "> /var/www/html/location.html");


# Update the script with your Google Map APIv3 key.

Your server will need net-snmp installed.  

 

 

 

 

 

Reuben Farrelly
Level 3
Level 3

OK that's friggen awesome, Daniel.  That solves everything - and in a far better way than I had envisaged.  As my server is a Gentoo Linux box I already have net-snmp running on it and have most of the Cisco MIBs already loaded on it - so it was easy to get it all to work.

I had to make a few changes to your script to make it work for me - so I've attached a diff showing my changes.  The main one being that textual names are returned from snmpwalk but there was also a parse problem with the values as well and an issue with the API_KEY statement.

Thanks once again, this is great...

Reuben

Joe Clarke
Cisco Employee
Cisco Employee

EEM supports opening any remote URI that IOS supports.  You could easily do:

 

set fd [open "ftp://server://X/Y/index.html" w]

puts $fd $data

close $fd

 

The same works with scp, tftp, etc.

Review Cisco Networking for a $25 gift card