is it possible to create two scripts?

Answered Question
Apr 25th, 2013
User Badges:

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)#

Correct Answer by Joe Clarke about 3 years 5 months ago

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

Correct Answer by Joe Clarke about 4 years 1 day ago

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.

Correct Answer by Joe Clarke about 4 years 1 day ago

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

Correct Answer by Joe Clarke about 4 years 1 day ago

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?

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4.8 (8 ratings)
Loading.
Correct Answer
Joe Clarke Thu, 04/25/2013 - 19:49
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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?

Josiah Inubio Thu, 04/25/2013 - 20:06
User Badges:

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.

Correct Answer
Joe Clarke Thu, 04/25/2013 - 20:19
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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

Josiah Inubio Thu, 04/25/2013 - 20:32
User Badges:

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

Joe Clarke Thu, 04/25/2013 - 20:41
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

Josiah Inubio Thu, 04/25/2013 - 20:47
User Badges:

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!

Correct Answer
Joe Clarke Thu, 04/25/2013 - 21:08
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

Josiah Inubio Sun, 10/06/2013 - 17:53
User Badges:

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

Joe Clarke Sun, 10/06/2013 - 20:17
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

Josiah Inubio Sun, 10/06/2013 - 20:44
User Badges:

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

Joe Clarke Sun, 10/06/2013 - 20:59
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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

Josiah Inubio Sun, 10/06/2013 - 22:27
User Badges:

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)

Joe Clarke Mon, 10/07/2013 - 08:11
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Cell1 appears to be working.  In cell2, add:


action 1.8 end


That will take care of the error you see there.

Josiah Inubio Mon, 10/07/2013 - 18:15
User Badges:

On the underlined logs below, i can see now that the script is working on the 2 downtime instances but there's no indication that the reload command works.


Oct  7 09:09:33.086 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct  7 09:09:49.674 MNL: %LINK-5-CHANGED: Interface Cellular0/0/0, changed state

to reset

Oct  7 09:09:52.926 MNL: %CELLWAN-2-MODEM_UP: Modem in HWIC slot 0/0 is now UP

Oct  7 09:09:54.674 MNL: %LINK-3-UPDOWN: Interface Cellular0/0/0, changed state

to down

Oct  7 09:10:14.718 MNL: %LINK-3-UPDOWN: Interface Cellular0/0/0, changed state

to up

Oct  8 08:29:28.113 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN


ROUTER#sh event manager history events

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

1    1      Actv success  Mon Oct 7 09:09:33 2013  syslog             applet: cell2

2    2      Actv success  Tue Oct 8 08:29:28 2013  syslog             applet: cell2


Oct  8 09:14:14.948 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_open called.

Oct  8 09:14:14.952 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Oct  8 09:14:14.952 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01>enable

Oct  8 09:14:15.264 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Oct  8 09:14:15.264 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01#show clock

Oct  8 09:14:15.276 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 09:14:15.264 MNL Tue Oct 8 2013

Oct  8 09:14:15.276 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Oct  8 09:14:15.276 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.


Also HWIC slot 0/0 keeps and always be down. How to prevent this?


Thank you so much.

Joe Clarke Mon, 10/07/2013 - 23:13
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

The reload will only be invoked if the time is between 19:00 and 06:00.  The current time is 09:14.  So the router will not reload.  In terms of the HWIC, you don't do anything in your applet to bring it back up.  If there are commands that need to be run, add them to your cell2 applet.

Josiah Inubio Tue, 10/08/2013 - 00:42
User Badges:

is it still works even if it doesn't show up in sh logs? normally reload will take 3-5mins, but logs shows HWIC slot 0/0 is UP after a split second. (in bold)


Oct  7 09:09:33.086 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct  7 09:09:49.674 MNL: %LINK-5-CHANGED: Interface Cellular0/0/0, changed state

to reset

Oct  7 09:09:52.926 MNL: %CELLWAN-2-MODEM_UP: Modem in HWIC slot 0/0 is now UP

Oct  7 09:09:54.674 MNL: %LINK-3-UPDOWN: Interface Cellular0/0/0, changed state

to down

Oct  7 09:10:14.718 MNL: %LINK-3-UPDOWN: Interface Cellular0/0/0, changed state

to up

Oct  8 08:29:28.113 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Joe Clarke Tue, 10/08/2013 - 08:03
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I don't really understand what the flow from a hardware standpoint should be.  All I can tel you is what I see from the applet commands.  The cell1 applet runs the test command (what it should do, I don't know, but it is running).  The cell2 applet checks the time and reloads the whole router if the time is within a specific window.  That should work, too, if the time is right.

Josiah Inubio Tue, 10/08/2013 - 17:52
User Badges:

Sorry for being persistent, but for this scenario below, the HWIC did state it was down as of 00:05, but i think the applet didn't works, it supposed to reload between 19:00-6:00. So i reloaded it manually after i've noticed it at 8:43.


Oct  9 00:05:58.018 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct  9 08:43:05.044 MNL: %SYS-5-SCHEDULED_RELOAD: Reload requested for 20:00:00 MNL Wed Oct 9 2013 at 08:43:03 MNL Wed Oct 9 2013 by jvi01131990 on vty0 (10.49.

135.135). Reload Reason: Reload Command.

Oct  9 08:46:47.592 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct  9 08:46:56.184 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_open called.

Oct  9 08:46:56.192 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : Reload scheduled for 20:00:00 MNL Wed Oct 9 2013 (in 11 hours and 13 minutes) by jvi0113

1990 on vty0 (10.49.135.135)

Oct  9 08:46:56.192 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : Reload reason: Reload Command

Oct  9 08:46:56.192 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Oct  9 08:46:56.192 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01>enable

Oct  9 08:46:56.504 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Oct  9 08:46:56.504 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01#show clock

Oct  9 08:46:56.516 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 08:46:56.508 MNL Wed Oct 9 2013

Oct  9 08:46:56.516 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Oct  9 08:46:56.516 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.

Oct  9 08:48:40.104 MNL: %HA_EM-4-FMPD_NO_EVENT: No event configured for applet cell2

Oct  9 08:48:40.104 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Joe Clarke Wed, 10/09/2013 - 08:02
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

This debug is from 08:46, though.  It doesn't show what happened at midnight.

Josiah Inubio Tue, 11/05/2013 - 17:16
User Badges:

I've noticed that the syslog below sometimes occur between 6AM - 6PM, so which means the event applet below will not take effect. question, how can i do a script that whenever the syslog pattern occur b/n 6AM-6PM i could set it up to reload automatically at 7PM. thanks


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 18

action 1.4 reload

action 1.5 end

action 1.6 if $hour le 6

action 1.7 reload

action 1.8 end

Joe Clarke Wed, 11/06/2013 - 11:55
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Have this applet configure another applet that triggers a reload at 19:00.  That is, add actions like:


event manager environment q "

!

action 1.7 cli command "config t"

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

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

action 2.0 cli command "action 1.0 reload"

action 2.1 cli command "end"

action 2.2 end


Same thing starting at action 1.4.

Josiah Inubio Wed, 11/06/2013 - 16:11
User Badges:

is this correct?


event manager applet cell3

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 18

action 1.4 reload

action 1.5 end

action 1.6 if $hour le 6

action 1.7 reload

action 1.8 end


action 1.9 cli command "config t"

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

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

action 2.2 cli command "action 1.0 reload"

action 2.3 cli command "end"

action 2.4 end

Joe Clarke Thu, 11/07/2013 - 16:45
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

No.  The action numbers I listed were what I meant.  Meaning what I provided was designed to replace action 1.7 on.  Note: you'll also have to replace actions 1.4 and 1.5 with the same list of items I did starting at action 1.7.

Josiah Inubio Thu, 11/07/2013 - 22:22
User Badges:

is this right?


the script must have this 2 scenario below. thanks.

  • 1st scenario should be it will reload automatically if syslog appears from 6PM to 6AM.
  • 2nd scenario should be it will reload at 7PM if syslog appears from 6AM to 6PM.


event manager applet cell3

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 18

action 1.4 cli command "config t"

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

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

action 1.7 cli command "action 1.0 reload"

action 1.8 cli command "end"

action 1.9 end

action 2.0 if $hour le 6

action 2.1 cli command "config t"

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

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

action 2.4 cli command "action 1.0 reload"

action 2.5 cli command "end"

action 2.6 end

Correct Answer
Joe Clarke Sat, 11/09/2013 - 14:36
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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

Josiah Inubio Mon, 11/11/2013 - 23:19
User Badges:

Hi Joseph, i've run the script and see if it works the way 2 scenarios should be. Thank you very much


Nov 12 15:19:04.828 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_open called.

Nov 12 15:19:04.828 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Nov 12 15:19:04.828 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01>enable

Nov 12 15:19:05.140 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Nov 12 15:19:05.140 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01#show clock

Nov 12 15:19:05.152 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 15:19:05.140 MNL Tue Nov 12 2013

Nov 12 15:19:05.152 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Nov 12 15:19:05.152 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01#config t

Nov 12 15:19:05.464 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line.  End with CNTL/Z.

Nov 12 15:19:05.464 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01(config)#

Nov 12 15:19:05.464 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01(config)#event manager applet reload-at-seven

Nov 12 15:19:05.776 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01(config-applet)#

Nov 12 15:19:05.776 MNL: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: q

Nov 12 15:19:05.776 MNL: %HA_EM-3-FMPD_ERROR: Error executing applet cell2 statement 3.4

Nov 12 15:19:05.776 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.


PHILAM-ANT-BR01#sh event manager history events

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

4    4      Actv success  Tue Nov12 15:19:04 2013  none               applet: cell2

Josiah Inubio Mon, 12/02/2013 - 17:05
User Badges:

Nov 12 15:19:05.464 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01(config)#event manager applet reload-at-seven


Nov 12 15:19:05.776 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01(config-applet)#


Nov 12 15:19:05.776 MNL: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: q


Nov 12 15:19:05.776 MNL: %HA_EM-3-FMPD_ERROR: Error executing applet cell2 statement 3.4

Joe Clarke Mon, 12/02/2013 - 18:09
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

You need to make sure the following is configured on your device:


event manager environment q "

Josiah Inubio Tue, 12/03/2013 - 16:31
User Badges:

hi joseph, what is the script to put inside the event manager environment q "


event manager environment q

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"


is this it?

Joe Clarke Tue, 12/03/2013 - 17:49
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

All this does is create a variable, q, to stand for the double quote character.  All you need to configure is:


event manager environment q "


Then you can use $q in your applets to stand for the embedded double quote.

Josiah Inubio Tue, 08/27/2013 - 00:00
User Badges:

Hi Joseph, I just found an error on using the script and the action doesn't work. It says there's something wrong with the variable "hour". How can I resolve this? Thanks.


Aug 25 08:23:57.362: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Aug 25 08:23:57.690: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: hour

Aug 25 08:23:57.690: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: hour

Joe Clarke Tue, 08/27/2013 - 08:13
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

The output of show clock must not be matching the regexp.  Run "debug event manager action cli" and look at the output to see what "show clock" looks like to EEM.

Josiah Inubio Tue, 08/27/2013 - 23:38
User Badges:

I have now executed the command, so how do i exactly see the output? thanks


ROUTER#debug event manager action cli

Debug EEM action cli debugging is on


ROUTER#sh clo

14:32:03.655 Wed Aug 28 2013

Joe Clarke Wed, 08/28/2013 - 08:34
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I meant enable debug, get your policy to execute, then look at the debug output to see what the show clock output looks like to EEM.

Josiah Inubio Thu, 08/29/2013 - 00:33
User Badges:

This is what looks like.


Aug 29 14:31:07.757 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Aug 29 14:31:07.761 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_open called.

Aug 29 14:31:07.761 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : ROUTER>

Aug 29 14:31:07.761 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : ROUTER>enable

Aug 29 14:31:08.073 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : No authorization entry found for 172.29.7.17

Aug 29 14:31:08.073 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT :

Aug 29 14:31:08.073 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : ROUTER>

Aug 29 14:31:08.073 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : ROUTER>show clock

Aug 29 14:31:08.085 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 14:31:08.077 MNL Thu Aug 29 2013

Aug 29 14:31:08.085 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : ROUTER>

Aug 29 14:31:08.085 MNL: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: hour

Aug 29 14:31:08.085 MNL: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: hour

Aug 29 14:31:08.085 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.

Joe Clarke Thu, 08/29/2013 - 14:28
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Not sure what your applet looks like now, but try this:


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

Josiah Inubio Wed, 09/04/2013 - 17:02
User Badges:

This is what it looks like. does the script works?


Sep  4 08:19:14.565 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Sep  4 08:19:14.565 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_open called.

Sep  4 08:19:14.569 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Sep  4 08:19:14.569 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01>enable

Sep  4 08:19:14.881 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : No authorization entry found for 172.29.7.17

Sep  4 08:19:14.881 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT :

Sep  4 08:19:14.881 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Sep  4 08:19:14.881 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01>show clock

Sep  4 08:19:14.893 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 08:19:14.881 MNL Wed Sep 4 2013

Sep  4 08:19:14.893 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Sep  4 08:19:14.893 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.

Sep  4 08:19:31.233 MNL: %LINK-5-CHANGED: Interface Cellular0/0/0, changed state to reset

Sep  4 08:19:34.477 MNL: %CELLWAN-2-MODEM_UP: Modem in HWIC slot 0/0 is now UP

Josiah Inubio Wed, 09/04/2013 - 17:22
User Badges:

hi joseph, there should be an enable password after these bold text indicated. how to put password on it? thanks


Sep  4 16:49:21.764 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-BLA-BR01>enable

Sep  4 16:49:22.076 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : No authorization entry found for 172.29.7.20

Sep  4 16:49:22.076 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT :

Josiah Inubio Wed, 09/04/2013 - 17:56
User Badges:

Hi joseph, I think it needed an username before action "enable" and a password after "enable". so how can i put that in the script? thanks

Joe Clarke Thu, 09/05/2013 - 10:33
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Configure:


event manager session cli username USER


Where USER is a username authorized to run all of the CLI commands in your applet.

Josiah Inubio Sun, 09/08/2013 - 19:06
User Badges:

is it also possible to configure telnet password and enable password?

Joe Clarke Sun, 09/08/2013 - 20:37
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

No.  They are not used or needed by EEM.

Josiah Inubio Wed, 09/04/2013 - 18:22
User Badges:

and this is another scenario. the script should be initiated after 19:00 since the syslog occur on 15:00. as you see below, i think the script didn't work.


Sep  4 15:15:13.953 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/1 is DOWN

Sep  4 15:15:13.957 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_opencalled.

Sep  4 15:15:13.957 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-SFL-BR01#

Sep  4 15:15:13.957 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-SFL-BR01#enable

Sep  4 15:15:14.269 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : No authorization entry found for 172.29.7.55

Sep  4 15:15:14.269 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT :

Sep  4 15:15:14.269 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-SFL-BR01#

Sep  4 15:15:14.269 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-SFL-BR01#show clock

Sep  4 15:15:14.281 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 15:15:14.273 MNL Wed Sep 4 2013

Sep  4 15:15:14.281 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-SFL-BR01#

Sep  4 15:15:14.281 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.

Josiah Inubio Wed, 10/30/2013 - 15:46
User Badges:

Hi Joseph, i really need your help here. I tried not to reload it manually and observed it that the script doesn't work. Here's the script.


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"

action 1.2 end

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 18

action 1.4 reload

action 1.5 end

action 1.6 if $hour le 6

action 1.7 reload

action 1.8 end


Here's the logs:


=========================

Router 1

=========================

Router 1#sh log | i Oct 30

Oct 30 03:08:48.826 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct 30 08:06:23.725 MNL: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to down

Oct 30 08:06:24.725 MNL: %LINK-3-UPDOWN: Interface GigabitEthernet0/0, changed state to down

Oct 30 08:06:32.725 MNL: %LINK-3-UPDOWN: Interface GigabitEthernet0/0, changed state to up

Oct 30 08:06:33.725 MNL: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

Oct 30 09:53:45.824 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:53:54.828 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 1#sh clo

18:48:31.798 MNL Wed Oct 30 2013

=========================

Router 2

=========================

Router 2#sh log | i Oct 30

Oct 30 09:31:32.529 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:31:42.169 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 2#sh clo

18:24:27.239 MNL Wed Oct 30 2013

=========================

Router 3

=========================

Router 3#sh log | i Oct 30

Oct 30 09:17:03.899 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:22:26.559 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:29:25.147 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 3#sh clo

18:11:22.917 MNL Wed Oct 30 2013

=========================

Router 4

=========================

Router 4#sh log | i Oct 30

Oct 30 04:11:23.706 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct 30 09:49:38.513 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:54:01.005 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 4#sh clo

18:32:06.895 MNL Wed Oct 30 2013

=========================

Router 5

=========================

Router 5#sh log | i Oct 30

Oct 30 02:02:08.631 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct 30 09:32:44.613 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:33:22.745 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:33:30.249 MNL: %HA_EM-4-FMPD_NO_EVENT: No event configured for applet cell2

Oct 30 09:33:30.249 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:36:40.993 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:37:06.905 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:37:14.277 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 5#sh clo

18:34:42.955 MNL Wed Oct 30 2013

=========================

Router 6

=========================

Router 6#sh log | i Oct 30

Oct 30 09:00:53.282 MNL: %CELLWAN-2-MODEM_DOWN: Modem in HWIC slot 0/0 is DOWN

Oct 30 09:53:31.309 MNL: %HA_EM-6-FMPD_EEM_CONFIG: cell1: "end" action found outside of conditional block

Oct 30 09:53:39.709 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 6#sh clo

18:41:18.951 MNL Wed Oct 30 2013

=========================

Router 7

=========================

Router 7#sh log | i Oct 30

Oct 30 09:25:42.539 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:26:30.703 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_open called.

Oct 30 09:26:30.707 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01>

Oct 30 09:26:30.707 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01>enable

Oct 30 09:26:31.019 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Oct 30 09:26:31.019 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : IN  : PHILAM-ANT-BR01#show clock

Oct 30 09:26:31.031 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : 09:26:31.023 MNL Wed Oct 30 2013

Oct 30 09:26:31.031 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : OUT : PHILAM-ANT-BR01#

Oct 30 09:26:31.031 MNL: %HA_EM-6-LOG: cell2 : DEBUG(cli_lib) : : CTL : cli_close called.

Oct 30 09:27:45.923 MNL: %HA_EM-4-FMPD_NO_EVENT: No event configured for applet cell2

Oct 30 09:27:45.923 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:29:39.703 MNL: %HA_EM-4-FMPD_NO_EVENT: No event configured for applet cell2

Oct 30 09:29:39.703 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:32:19.571 MNL: %SYS-5-PRIV_AUTH_FAIL: Authentication to privilege level 15 failed by jvi01131990 on vty0 (10.49.135.135)

Oct 30 09:39:27.103 MNL: %SYS-5-CONFIG_I: Configured from console by jvi01131990 on vty0 (10.49.135.135)

Router 7# sh clo

18:37:49.320 MNL Wed Oct 30 2013

Joe Clarke Wed, 10/30/2013 - 22:33
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Get rid of action 1.2 in cell1.  Additionally, if your router 7 output, the time is outside the window, so the reload would not happen.

Josiah Inubio Thu, 05/16/2013 - 23:15
User Badges:

Hey joseph, is it possible to create a script that will send an email to you on a syslog that you choose?

Joe Clarke Fri, 05/17/2013 - 07:22
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Yes.  You can use the "mail" action in an applet to send the email and use the syslog event detector to match your syslog message.

Josiah Inubio Fri, 05/17/2013 - 08:09
User Badges:

for example for this event syslog pattern "Modem in HWIC slot 0/2 is DOWN", how will i create the script to notify me thru email?

Actions

This Discussion