03-11-2020 01:45 AM
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
Solved! Go to Solution.
03-11-2020 02:05 AM
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.
03-11-2020 02:05 AM
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.
03-11-2020 03:05 AM
03-11-2020 07:49 AM - edited 03-11-2020 07:55 AM
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.
03-11-2020 08:52 AM
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.
03-23-2020 02:50 AM
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: