cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1334
Views
0
Helpful
5
Replies
Shri2
Beginner

Avoid override of data in EEM

Hi All,

 

With below script, i am trying to get IP address from each line and perform ping/tracert and upload it in flash.

So this is whats happening.

it takes 1st IP : performs ping/tracert and uploads in ping.txt and tracert.txt....All good.

it takes 2nd IP : performs ping/tracert and uploads in ping.txt and tracert.txt. However it overrides the previous data in .txt file.

Is there a any command/way to overcome this issue ?

 

action 5.1 cli command "sh dial-peer voic summary | sec ipv4"
action 5.2 set summary1 "$_cli_result"
action 5.3 foreach line "$summary1" "\n"
action 5.4   regexp "(.*)ipv4:(.*)busyout" "$line" _match _sub1 _sub2
action 5.5 cli command "ping $_sub2"
action 5.6 file open fd flash:ping.txt w
action 5.7 file write fd "$_cli_result"
action 5.8 file close fd
action 5.9 cli command "traceroute $_sub2"
action 6.0 file open fd flash:tracert.txt w
action 6.1 file write fd "$_cli_result"
action 6.2 file close fd

1 ACCEPTED SOLUTION

Accepted Solutions
Cristian Matei
VIP Collaborator

Hi,

 

   Create/open the file for appending, so you always write at the end of the file, you're currently opening it for writing, which means overwriting. Try the following and see how it goes:

 

action 5.1 cli command "sh dial-peer voic summary | sec ipv4"
action 5.2 set summary1 "$_cli_result"
action 5.3 foreach line "$summary1" "\n"
action 5.4   regexp "(.*)ipv4:(.*)busyout" "$line" _match _sub1 _sub2
action 5.5 cli command "ping $_sub2"
action 5.6 file open fd flash:ping.txt a
action 5.7 file write fd "$_cli_result"
action 5.8 file close fd
action 5.9 cli command "traceroute $_sub2"
action 6.0 file open fd flash:tracert.txt a
action 6.1 file write fd "$_cli_result"
action 6.2 file close fd

 

Regards,

Cristian Matei.

View solution in original post

5 REPLIES 5
Cristian Matei
VIP Collaborator

Hi,

 

   Create/open the file for appending, so you always write at the end of the file, you're currently opening it for writing, which means overwriting. Try the following and see how it goes:

 

action 5.1 cli command "sh dial-peer voic summary | sec ipv4"
action 5.2 set summary1 "$_cli_result"
action 5.3 foreach line "$summary1" "\n"
action 5.4   regexp "(.*)ipv4:(.*)busyout" "$line" _match _sub1 _sub2
action 5.5 cli command "ping $_sub2"
action 5.6 file open fd flash:ping.txt a
action 5.7 file write fd "$_cli_result"
action 5.8 file close fd
action 5.9 cli command "traceroute $_sub2"
action 6.0 file open fd flash:tracert.txt a
action 6.1 file write fd "$_cli_result"
action 6.2 file close fd

 

Regards,

Cristian Matei.

View solution in original post

Let me try

It worked, Thanks.

 

One more query, as we know trace route takes quite a time to process due to which default time of EEM script is elapsing causing scrip to terminate.

 

I am aware of maxrun, currently its set to 20. I am planning to increase to 60, however its asking to enter some more parameter.

router#event none maxrun 60 ?
default Default action timer
ratelimit Limit trigger to once per given time period
sync EEM policy execution sync or async
<cr>

 

Can i know what is ratelimit and SYNC parameter.

Hi,

 

   I did not play with those options to have a clear understanding of what it does, I also used just the maxrun option. There is no need to specify other options, look closer.

   You could look in the Command Reference for those options.

 

 

Regards,

Cristian Matei.

Okay.
Below commands ( FILE ) are not acceptable in router 28XX. Is there any other way to get the output of ping/traceroute for 28XX router.

action 5.6 file open fd flash:ping.txt a
action 5.7 file write fd "$_cli_result"
action 5.8 file close fd
action 5.9 cli command "traceroute $_sub2"
action 6.0 file open fd flash:tracert.txt a
action 6.1 file write fd "$_cli_result"
action 6.2 file close fd
Content for Community-Ad