cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
686
Views
0
Helpful
5
Replies
Highlighted

EEM registration failed for python script

Hello all,

 

I'm trying to register a python script in EEM but it keeps failing, I have dumbed down the script do do nothing but print and im still getting nowhere, from articles I've read I should be all good (https://blogs.cisco.com/developer/on-box-python-for-devices)

 

ive seen that in bash patterns start with ## so I tried to also no no avail

 

test2.py

::cisco::eem::event_register_syslog pattern ".*%BGP-5-ADJCHANGE:.*Down.*" maxrun 60
print("BGP DOWN")

IOS

POC-RTR-01(config)#event manager directory user policy flash:scripts
POC-RTR-01(config)#event manager policy test2.py authorization bypass type user
EEM configuration: failed to retrieve intermediate registration result for policy test2.py
POC-RTR-01(config)#do dir flash:scripts
Directory of bootflash:/scripts/

186210  -rw-              420  Apr 12 2019 13:29:42 +00:00  test.py
186211  -rw-              104  Apr 17 2019 15:51:30 +00:00  test2.py

6703677440 bytes total (4593250304 bytes free)
POC-RTR-01#show event manager detector all
No.  Name                Version   Node        Type
1    application         01.00     node0/0     RP
2    rf                  01.00     node0/0     RP
3    syslog              01.00     node0/0     RP
4    mat                 01.00     node0/0     RP
5    neighbor-discovery  01.00     node0/0     RP
6    generic             01.00     node0/0     RP
7    track               01.00     node0/0     RP
8    routing             03.00     node0/0     RP
9    resource            01.00     node0/0     RP
10   cli                 01.00     node0/0     RP
11   counter             01.00     node0/0     RP
12   interface           01.00     node0/0     RP
13   ioswdsysmon         01.00     node0/0     RP
14   none                01.00     node0/0     RP
15   oir                 01.00     node0/0     RP
16   snmp                01.00     node0/0     RP
17   snmp-object         01.00     node0/0     RP
18   snmp-notification   01.00     node0/0     RP
19   timer               01.00     node0/0     RP
20   test                01.00     node0/0     RP
21   config              01.00     node0/0     RP
22   env                 01.00     node0/0     RP
23   ds                  01.00     node0/0     RP
24   crash               01.00     node0/0     RP
25   gold                01.00     node0/0     RP
26   rpc                 01.00     node0/0     RP
27   ipsla               01.00     node0/0     RP

 

 

has anyone come across this and know the fix?

 

 

Everyone's tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: EEM registration failed for python script

This was solved with TACs assistance, currently cannot run EEM python scripts from a sub directory, they have to be run from the root

View solution in original post

5 REPLIES 5
Highlighted

Re: EEM registration failed for python script

I have some debug output from attempting to register the script as per the below, I have highlighted a possible issue, it seems as if eem cannot open the file.

 

I went into guesthell and gave the file 777 permissions and still the same issue occurred

 

[guestshell@guestshell scripts]$ chmod 777 eem_test.py
[guestshell@guestshell scripts]$ ls -lah eem_test.py
-rwxrwxrwx 1 guestshell guestshell 162 Apr 23 09:08 eem_test.py
[guestshell@guestshell scripts]$ exit

 

Also from what ive read eem should detect the .py extension and register it as python, in the logs below it looks like its attempting to register a tcl script only?

 

POC-RTR-01(config)#event manager policy flash:/scripts/eem_test.py
Apr 23 09:13:36.525: cli_history_entry_add: free_hist_list size=0, hist_list size=7
Apr 23 09:13:36.525: fh_fd_cli_event_match: fd_reg->cli_match_type = 1, match_info->match_type = 1
Apr 23 09:13:36.525: fh_fd_cli_event_match: fd_reg->cli_match_type = 1, match_info->match_type = 1
Apr 23 09:13:36.525: check_eem_cli_policy_handler: command_string=configure terminal
Apr 23 09:13:36.526: check_eem_cli_policy_handler: num_matches = 0, response_code = 1
POC-RTR-01(config)#event manager policy eem_test.py
EEM configuration: failed to retrieve intermediate registration result for policy eem_test.py
POC-RTR-01(config)#
Apr 23 09:13:40.022: cli_history_entry_add: free_hist_list size=0, hist_list size=7
Apr 23 09:13:40.022: fh_fd_cli_event_match: fd_reg->cli_match_type = 1, match_info->match_type = 1
Apr 23 09:13:40.022: fh_fd_cli_event_match: fd_reg->cli_match_type = 1, match_info->match_type = 1
Apr 23 09:13:40.022: check_eem_cli_policy_handler: command_string=event manager policy eem_test.py
Apr 23 09:13:40.022: check_eem_cli_policy_handler: num_matches = 0, response_code = 1
Apr 23 09:13:40.022: EEM Inside fh_set_policy()

Apr 23 09:13:40.022: fh_policyname = eem_test.py
Apr 23 09:13:40.022: type = 2
Apr 23 09:13:40.022: checksum type = FH_POLICY_CHECKSUM_UNKNOWN
Apr 23 09:13:40.023: found user policy absolute path flash:/scripts/eem_test.py
Apr 23 09:13:40.023: found type = 1
Apr 23 09:13:40.023: register eem policy flash:/scripts/eem_test.py
Apr 23 09:13:40.023: check 1: not duplicate registration
Apr 23 09:13:40.023: Checking security level: ECDSA 192
Apr 23 09:13:40.023: TCL secure mode OFF
Apr 23 09:13:40.023: No valid digital signature found or Tcl digital signatures are not supported in this image, registering as a user script.
Apr 23 09:13:40.024: waiting for mlang proc
Apr 23 09:13:40.025: fh_io_ipc_msg: received FH_MSG_API_INIT; jobid=19, processid=677, client=9, job name=EEM MLANG Proc
Apr 23 09:13:40.026: Could not open the file : eem_test.py
POC-RTR-01(config)#
Apr 23 09:13:40.026: fh_server: fh_io_ipc_msg: received msg FH_MSG_API_CLOSE from client 9 pclient 9
Apr 23 09:13:40.026: fh_io_ipc_msg: received FH_MSG_API_CLOSE client=9
Apr 23 09:13:40.026: No valid digital signature found or Tcl digital signatures are not supported in this image, registering as a user script.
Apr 23 09:13:40.026: fh_reg_policy_core failed: failed to retrieve intermediate registration result for policy eem_test.py

 

Highlighted
Rising star
Rising star

Re: EEM registration failed for python script

hi

not sure .. could it be directory permissions?

as a test .. can you try bootflash: instead of flash:

POC-RTR-01(config)#event manager policy bootflash:/scripts/eem_test.py

and test with copying and registering from flash..  flash:/eem_test.py instead of flash:/scripts/eem_test.py

 

HTH

Highlighted
Rising star
Rising star

Re: EEM registration failed for python script

Also, look at step 3 and 4 for a directory

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/1612/b_1612_programmability_cg/eem_python_module.html

 

Step 3

event manager directory user policy path

Example:

Device(config)# event manager directory user policy flash:/user_library

Specifies a directory to use for storing user library files or user-defined EEM policies.

Note 

You must have a policy in the specified path. For example, in this step, the eem_script.py policy is available in the flash:/user_library folder or path.

Step 4

event manager policy policy-filename

Example:

Device(config)# event manager policy eem_script.py

Registers a policy with EEM.

  • The policy is parsed based on the file extension. If the file extension is .py, the policy is registered as Python policy.

  • EEM schedules and runs policies on the basis of an event specification that is contained within the policy itself. When the event manager policy command is invoked, EEM examines the policy and registers it to be run when the specified event occurs.

 

 

 

Highlighted

Re: EEM registration failed for python script

This was solved with TACs assistance, currently cannot run EEM python scripts from a sub directory, they have to be run from the root

View solution in original post

Highlighted
Rising star
Rising star

Re: EEM registration failed for python script

Great stuff! 

i did suggest below .. but you have accepted your own solution .. no worries :)

 

not sure .. could it be directory permissions?

as a test .. can you try bootflash: instead of flash:

POC-RTR-01(config)#event manager policy bootflash:/scripts/eem_test.py

and test with copying and registering from flash..  flash:/eem_test.py instead of flash:/scripts/eem_test.py

This widget could not be displayed.