08-04-2014 05:46 AM
Hi guys,
Just setup a small but useful Remote Access VPN accounting script:
event manager applet VPN_Accounting_UP
event syslog pattern "%CRYPTO-5-SESSION_STATUS: Crypto tunnel is UP"
action 1.0 cli command "enable"
action 1.2 cli command "show clock | append flash:/VPN_Accounting"
action 2.0 cli command "show crypto session brief | append flash:/VPN_Accounting"
action 3.0 append flash:/VPN_Accounting "=================================================="
And here's the output as I just almost need it:
Cisco-Tests#more flash:/VPN_Accounting
14:28:50.680 EEST Mon Aug 4 2014
Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating
K - No IKE
ivrf = (none)
Peer I/F Username Group/Phase1_id Uptime Status
85.24.27.62 Vl11 ra-user VPNRA 00:02:34 UA
15:10:33.492 EEST Mon Aug 4 2014
Status: A- Active, U - Up, D - Down, I - Idle, S - Standby, N - Negotiating
K - No IKE
ivrf = (none)
Peer I/F Username Group/Phase1_id Uptime Status
85.24.27.62 Vl11 ra-user VPNRA 00:00:00 UA
My only question is how can I add after the last output append some string like: "==================================".
Mainly just action 3.0 is not working...
Thanks!
08-04-2014 08:23 AM
Do not know any easy way to do that, but you could create a tcl script that just "puts" its argument and then do "tclsh puts.tcl ========================= | append flash:/VPN_Accounting"
Kind of an "echo" command :)
08-04-2014 10:32 AM
The append action is for appending a string to another string. If you have EEM 4.0, you can use the file open and file write actions, but it's not clear what version of IOS you have. As a general workaround, you can try what cgm suggests, or convert this applet to Tcl at http://www.marcuscom.com/convert_applet/ then add:
set fd [open "flash:/VPN_Accounting" a]
puts $fd "========================================"
close $fd
08-04-2014 07:45 PM
As Joseph said, the file operation are available from 15.2(2)T. Reference here
If you are able to use the file actions, you could do it as in the example below:
event manager applet VPN_Accounting_UP
event syslog pattern "%CRYPTO-5-SESSION_STATUS: Crypto tunnel is UP"
action 1 file open LOGFILE flash:VPN_Accounting.txt a+
action 2 cli command "enable"
action 3 cli command "show clock"
action 4 file puts LOGFILE "$_cli_result"
action 5 cli command "show crypto session brief"
action 6 file puts LOGFILE "$_cli_result"
action 7 set filebuffer "=================================================="
action 8 file puts LOGFILE "$filebuffer"
action 9 file close LOGFILE
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide