cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
9792
Views
13
Helpful
62
Replies

is it possible to create two scripts?

Josiah Inubio
Level 1
Level 1

Is it possible this way if I'm making two script? Thanks.

Script 1

For this log:

Apr 24 07:40:01.884 MNL: %LINK-3-UPDOWN: Interface Cellular0/2/0, changed state

to down

ROUTER(config)#event manager applet cell1

ROUTER(config-applet)# event syslog pattern "Interface Cellular0/2/0, changed state to down"

ROUTER(config-applet)# action 1.0 cli command "enable"

ROUTER(config-applet)# action 1.1 cli cmmand "configure term"

ROUTER(config-applet)# action 1.2 cli command "interface Cellular0/2/0"

ROUTER(config-applet)# action 1.3 cli command "no shut"

ROUTER(config-applet)#

Script 2

For this log:

Apr 25 11:17:49.881 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/2 is DOWN

ROUTER(config)#event manager applet cell2

ROUTER(config-applet)# event syslog pattern "Modem in HWIC slot 0/2 is DOWN"

ROUTER(config-applet)# action 1.0 cli command "enable"

ROUTER(config-applet)# action 1.1 cli cmmand "reload at 19:00"

ROUTER(config-applet)#

5 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

These will work.  You can have them both configured at once.  However, the reload at is strange.  Is that the only way to recover?  Are you okay with waiting for a specific time to reload?

View solution in original post

You could use a regexp to do this:

action 001 cli command "enable"

action 002 cli command "show clock"

action 003 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour

action 004 if $hour ge 17

action 005  reload

action 006 end

View solution in original post

The regexp line extracts the hour portion of the time and the if lines compare that value to 17 (5pm) and 6 (6 am) respectively.  If the hour is greater than or equal to 17 or less than or equal to 6 (numerically) then the reload action will be invoked.

View solution in original post

event manager applet mode-down

event syslog pattern "Modem in HWIC slot 0/2 is DOWN"

action 1.0 mail from user@company.com to user@company.com server 10.1.1.1 subject "Modem down" body "$_syslog_msg"

View solution in original post

No.  Not given these scenarios.

event manager applet cell3

description "TEST ONLY"

event syslog pattern "Modem in HWIC slot 0/0 is DOWN"

action 0.5 set timed_reload 0

action 1.0 cli command "enable"

action 1.1 cli command "show clock"

action 1.2 regexp "([0-9]+):[0-9]+:[0-9]+" "$_cli_result" match hour

action 1.3 if $hour ge 18

action 1.4  reload

action 1.9 else

action 2.0  set timed_reload 1

action 2.1 end

action 2.2 if $hour lt 6

action 2.4  reload

action 2.8 else

action 2.9  set timed_reload 1

action 3.0 end

action 3.1 if $timed_reload eq 1

action 3.2  cli command "config t"

action 3.3  cli command "event manager applet reload-at-seven"

action 3.4  cli command "event timer cron cron-entry $q 0 19 * * *$q"

action 3.5  cli command "action 1.0 reload"

action 3.6  cli command "end"

action 3.7 end

View solution in original post

62 Replies 62

Joe Clarke
Cisco Employee
Cisco Employee

These will work.  You can have them both configured at once.  However, the reload at is strange.  Is that the only way to recover?  Are you okay with waiting for a specific time to reload?

It's the most convenient time to reload since our client business hours end at 17:00 or 5PM. So i don't want to put the connection down.

Is there as script that could identify when the time comes when the interface or HWIC modem will be down at 19:00 to 0600 and then reload it right away? So i don't have to wait 17:00.

You could use a regexp to do this:

action 001 cli command "enable"

action 002 cli command "show clock"

action 003 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour

action 004 if $hour ge 17

action 005  reload

action 006 end

Wow, i'll try it and i'll let you know. Thanks so much on this. But is this right below?

ROUTER(config)#event manager applet cell2

ROUTER(config-applet)# event syslog pattern "Modem in HWIC slot 0/2 is DOWN"

ROUTER(config-applet)# action 1.0 cli command "enable"

ROUTER(config-applet)# action 1.1 cli command "show clock"

ROUTER(config-applet)# action 1.2 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour

ROUTER(config-applet)# action 1.3 if $hour ge 17

ROUTER(config-applet)# action 1.4 reload

ROUTER(config-applet)# action 1.5 end

Yes, but perhaps you want to do:

action 1.6 if $hour le 6

action 1.7  reload

action 1.8 end

And this will only work if the message comes in at that time.  It won't handle the case where the message comes in during business hours.  You would still want to add your reload at line in that case.

Sorry that i'm being persistent. I'm new at this.

Question, can you help me understand these scripts? the bold phrases.

ROUTER(config-applet)# action 1.2 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour

ROUTER(config-applet)# action 1.3 if $hour ge 17

ROUTER(config-applet)# action 1.4 reload

ROUTER(config-applet)# action 1.5 end

ROUTER(config-applet)# action 1.6 if $hour le 6

ROUTER(config-applet)# action 1.7  reload

ROUTER(config-applet)# action 1.8 end

Appreciate it a lot!

The regexp line extracts the hour portion of the time and the if lines compare that value to 17 (5pm) and 6 (6 am) respectively.  If the hour is greater than or equal to 17 or less than or equal to 6 (numerically) then the reload action will be invoked.

Thank you so much for the assistance. Appreciate it!

hi joseph, i think the script is not working. i can't see any activity working based on the debug logs. thanks

Without seeing what you're seeing, I don't know what to tell you.  I'm honestly not even sure what the script looks like at this point.

here's what the script looks like

event manager session cli username "jvi01131990"

event manager applet cell1

description "TEST ONLY"

event syslog pattern "Interface Cellular0/0/0, changed state to down"

action 1.0 cli command "enable"

action 1.1 cli command "test cellular 0/0/0 modem-power-cycle"

event manager applet cell2

description "TEST ONLY"

event syslog pattern "Modem in HWIC slot 0/0 is DOWN"

action 1.0 cli command "enable"

action 1.1 cli command "show clock"

action 1.2 regexp "([0-9]+):[0-9]+:[0-9]+" "$_cli_result" match hour

action 1.3 if $hour ge 19

action 1.4  reload

action 1.5 end

action 1.6 if $hour le 6

action 1.7  reload

When one of these syslog messages is generated, what do you see in your debug output?  What does "show event manager history event" show?

to run cell1 manually, its successful, but not with cell2

PHILAM-COT-BR01#sh event manager history events

No.  Job Id Proc Status   Time of Event            Event Type         Name

1    1      Actv success  Mon Oct 7 13:12:01 2013  none               applet: cell1

CELL1

Oct  7 13:11:49.177 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct  7 13:12:01.293 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : CTL : cli_open called.

Oct  7 13:12:01.297 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : OUT : Reload scheduled for 20:00:00 MNL Mon Oct 7 2013 (in 6 hours and 47 minutes) by jvi01131

990 on vty0 (10.49.135.135)

Oct  7 13:12:01.297 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : OUT : Reload reason: Reload Command

Oct  7 13:12:01.297 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : OUT : PHILAM-COT-BR01>

Oct  7 13:12:01.301 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : IN  : PHILAM-COT-BR01>enable

Oct  7 13:12:01.613 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : OUT : PHILAM-COT-BR01#

Oct  7 13:12:01.613 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : IN  : PHILAM-COT-BR01#test cellular 0/0/0 modem-power-cycle

Oct  7 13:12:10.925 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : OUT : Cellular

Modem in HWIC slot 0/0 is still in reset, we recommend to re-execute this cmd after 60 seconds

Oct  7 13:12:10.925 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : OUT : PHILAM-COT-BR01#

Oct  7 13:12:10.925 MNL: %HA_EM-6-LOG: cell1 : DEBUG(cli_lib) : : CTL : cli_close called.

CELL2

Oct  7 13:16:53.137 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell2: Missing "end" action in conditional block

Oct  7 13:16:53.137 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990

on vty0 (10.49.135.135)

Cell1 appears to be working.  In cell2, add:

action 1.8 end

That will take care of the error you see there.

Getting Started

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: