cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6687
Views
15
Helpful
15
Replies

EEM Script for reload

Felixsson1
Frequent Visitor
Frequent Visitor

Hi,

I've made a EEM applet for reloading a Cisco router after certain part of message appears in syslog.

No.   Class    Type    Event Type   Trap    Time    Registered                          Name
1      applet    user     syslog          Off      Mon     Dec 19 07:21:21 2022     RELOAD
pattern {Text ABC123}
maxrun 20.000
action 1.0 cli command "enable"
action 2.0 cli command "reload"

1.) Why is the text in pattern shown with {} instead with " as I typed?

2.) Trap says it's "off".

3.) In the output below the applet process status is abort so my router never reloads. What I'm missing in the configuration?

Router2#sh event manager history events
No. Job Id Proc Status Time of Event Event Type Name
1 41 Actv abort Mon Dec19 07:24:27 2022 syslog applet: RELOAD
2 42 Actv abort Mon Dec19 07:25:40 2022 syslog applet: RELOAD
3 43 Actv abort Mon Dec19 07:26:52 2022 syslog applet: RELOAD
4 44 Actv abort Mon Dec19 07:28:05 2022 syslog applet: RELOAD
5 45 Actv abort Mon Dec19 07:29:17 2022 syslog applet: RELOAD
6 46 Actv abort Mon Dec19 07:30:30 2022 syslog applet: RELOAD
7 47 Actv abort Mon Dec19 07:31:43 2022 syslog applet: RELOAD
8 48 Actv abort Mon Dec19 07:32:55 2022 syslog applet: RELOAD
9 49 Actv abort Mon Dec19 07:34:08 2022 syslog applet: RELOAD
10 50 Actv abort Mon Dec19 07:35:20 2022 syslog applet: RELOAD

 

EDIT:

This works:

event syslog pattern ".*Unknown modem on SKU type C881G-4G-GA-K9.*"
trigger delay 2000
action 1 cli command "ena"
action 2 cli command "reload" pattern "confirm"
action 3 cli command "y"

15 Replies 15

balaji.bandi
Hall of Fame
Hall of Fame

what is the device model and IOS code running, can you post EEM Script :

event manager applet reload-device
maxrun 20.000
event syslog pattern "my message"
action 1.0 cli command "enable"
action 2.0 cli command "reload"

 

BB

=====️ Preenayamo Vasudevam ️=====

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

can I see your config I will run lab test it 

event manager applet SKU_RELOAD
event syslog pattern "Unknown modem on SKU type C881G-4G-GA-K9"
action 1.0 cli command "enable"
action 2.0 cli command "reload"

Syslog generates this messages:

Dec 19 07:04:14.346: %CISCO800-2-MODEM_UP: Cellular0 modem is now UP
Dec 19 07:04:34.361: %CELLWAN-4-MODEM_COMM_FAIL: Communication between Modem and IOS failed: link recovery resets modem
Dec 19 07:05:05.956: %PLATFORM-4-CELLULAR_MODEM_SKU_MISMATCH: Mismatch detected between installed modem Unknown modem on SKU type C881G-4G-GA-K9. Expected modem for this SKU is MC7304

Hello,

post the output of:

debug event manager action cli

while you run the script.

that should work  as expected

event manager run SKU_RELOAD  - what is the outcome.

BB

=====️ Preenayamo Vasudevam ️=====

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Router#event manager run SKU_RELOAD
EEM policy SKU_RELOAD not registered with event none Event Detector

Hello,

start the script by adding:

Router#send log Unknown modem on SKU type C881G-4G-GA-K9

This will put the matched syslog pattern in the log and trigger the EEM. Post the output of 'debug event manager action cli' then...

Felixsson1
Frequent Visitor
Frequent Visitor

It's C881G-4G-GA-K9 and the IOS is Version 15.5(3)M4a.

Friend I do LAB, and I success do reload 
BUT BUT BUT this lab and I did not finish it 

event manager applet SKU_RELOAD

event syslog pattern " .  * Unknown modem on SKU type C881G-4G-GA-K9 . * " <<- this meaning dont care about timestamp and other words appear in syslog only within ".* ---.*" is important 
action 1.0 cli reload   <<- you can direct add reload under action 

WHAT I concern here ?
with normal reload the R ask to save config if you reload without save the config then it will be lost.

so I need time to finish lab first we must save the config then do reload. 

Thanks 

Thanks for the quick update! I think the problem might be with the syslog pattern since I didn't put .* at the beginning and at the end to ignore rest of the text, meaning that my script will work if only if there is a exact syslog mesagge "Unknown modem on SKU type C881G-4G-GA-K9" which in my case it's not.

friend again you need to save the config or it will LOST every time even action done. 
good luck.

Felixsson1
Frequent Visitor
Frequent Visitor

This is the final configuration that finally works:

event syslog pattern ".*Unknown modem on SKU type C881G-4G-GA-K9.*"
trigger delay 2000
action 1 cli command "ena"
action 2 cli command "reload" pattern "confirm"
action 3 cli command "y"

action 1 cli command "ena"
action 2 cli command "reload" pattern "confirm"
action 3 cli command "y"

instead of above 
action 1 cli reload <<- that only if your EEM ver support it 

and I glad the issue is solved. 
good luck friend 

Felixsson1
Frequent Visitor
Frequent Visitor

Thanks for the help!

🙋‍♂️