Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

How can I execute a command every 10 seconds in a specific time-frame

Hello,

I would like to create a script which in a specific time-frame collects some outputs and also pings every 10 seconds.

To collect the outputs every minute from 22:00PM to 22:10PM I have the following:

event manager applet snmp_output
event timer cron cron-entry "0-10/1 22 * * *" maxrun 30
action 010 cli command "enable"
action 020 cli command "show clock"
action 030 cli command "terminal exec prompt timestamp"
action 040 cli command "show snmp stats oid | append bootdisk:show_snmp_stats_oid.txt "
action 045 wait 5
action 050 cli command "show snmp pending | append bootdisk:show_snmp_pending.txt "
action 055 wait 5
action 060 cli command "show snmp sessions | append bootdisk:show_snmp_sessions.txt "
acionn 065 wait 5
action 070 cli command "end"

To confirm connectivity to the device doing the SNMP polls I would like to execute a ping every 10 seconds in the same timeframe.

Cron seems only to support minutes. Is it possible to combine a watchdog timer + a cron timer?

Can this ping function be incorporated in the SNMP output applet or will I have to write a new one?

Will I need TCL here (I have no experience in TCL)?

Best regards,

Tim

 

5 REPLIES
Cisco Employee

If you wanted the pings to

If you wanted the pings to run in parallel, you could have this applet configure another applet to do the pinging, then remove it on the last run.  This will require an amount of programmatic logic, though.  If you wanted to keep things a bit simpler, add another applet that runs at 22:00 that configures a watchdog pinging applet, then a third applet that runs at 22:10 that removes the pinging applet.

 

When it comes to embedded quotes when you configure your nested pinging applet, you'll need to use $q to stand for the embedded quotes.  You'll also need to configure:

 

event manager environment q "

New Member

Hi Joseph,thanks for the

Hi Joseph,

thanks for the reply! I was suspecting something like this.

So in essence it is not possible to have a single applet (without it configuring another applet) to start at a specific time and run command repeatedly (barring TCL of course)?

Best regards,

Tim

Cisco Employee

Yeah.  Using Tcl, you could

Yeah.  Using Tcl, you could add a "background" task that does the pinging.  Using applets, you'd need to have use another applet to get the same asynchronous behavior.

New Member

Hi,thanks for the help. I was

Hi,

thanks for the help. I was able to configure the applet. But it seems one cannot redirect the Ping output to a file ;)

Cisco Employee

No, you cannot | redirect

No, you cannot | redirect ping output.  If you are running new enough IOS code, you can use the file manipulation capabilities of EEM applets to open a file on flash and record the information.  Something like

 

file open fd "flash:ping_out.txt"

cli command "ping HOST"

file write fd "$_cli_result"

file close fd

604
Views
0
Helpful
5
Replies