EEM CLI patterns are not context sensitive

When writing EEM applets or policies that act on CLI commands, keep in mind that the pattern matching is not context sensitive. For example, if you want to disable the reload command and use the EEM applet …

event manager applet NoReload
 event cli pattern "reload" sync no skip yes
… you cannot enter the action x.y reload configuration command any more (or any other command that includes the string reload).

To distinguish the reload command from other appearances of the same string, use the ^reload pattern (reload occuring at the beginning of the line).

Trivia: this actually occured to me when I was testing the setup described in the December IP Corner article. Sometimes we have to learn the hard way :)

6 comments:

  1. Hi, I would like to know if EEM policy applet or TCL script able to use the following

    action cli command "telnet xxx.xxx.xxx.xxx"

    remote terminal and send action cli command to that remote terminal ?

    Thx

    ReplyDelete
  2. In theory, it could be doable, but I need to test it in the lab to be sure.

    ReplyDelete
  3. So hows the test in the lab ? Is it doable ? Because i have tried and it failed.

    ReplyDelete
  4. EEM 3.0 has an enhanced cli event detector that allows you to specify the mode of the command. Unfortunately the mode values that you can use are not obvious and not documented. However, there is a hidden command to see the modes - 'show parser mode' - the name column lists the various parser modes. Since it's a hidden command, use it at your own risk.

    ReplyDelete
  5. hi ivan,

    i am totally confuse in sync yes|no skip yes|no. what is the mean of sync and skip, when we use these keywords and what is the mean of yes and no. please help me

    ReplyDelete

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.