Your browser failed to load CSS style sheets. Your browser or web proxy might not support elliptic-curve TLS

Building network automation solutions

9 module online course

Start now!
back to overview

Stop accidental scheduled router reloads

Alexandra Stanovska wrote an excellent comment to my Schedule reload before configuring the router post:

It may come in handy creating some form of script that would display some basic upon logout - show debug, show reload etc.

The new capabilities of CLI event detector introduced in EEM 3.0 allow us to catch CLI commands in a particular parser mode. Writing an EEM applet that catches exec-mode exit or logout and performs a few checks is thus a trivial task.

The following applet is a proof of concept; it checks whether a reload is scheduled and prevents the user from exiting a telnet session before cancelling the scheduled reload. Feel free to extend it and add other checks you’d like to see performed.

event manager applet CheckScheduledReloadOnExit
 event cli pattern "^(ex|logo)" mode "exec" enter maxrun 1
 action 1.0 cli command "show reload"
 action 1.1 string first "No reload is scheduled" "$_cli_result"
 action 2.0 if $_string_result eq -1
 action 2.1  puts "Cannot allow you to exit, reload is scheduled"
 action 2.2 else
 action 2.3  set _exit_status 1
 action 2.9 end

Please read our Blog Commenting Policy before writing a comment.

1 comment:

  1. Dears its not works!

    The scrip wen applyed, if reload is not configured yet I cant exit router!

    1 - #show reload
    No reload is scheduled.
    2 - exit
    Cannot allow you to exit, reload is scheduled


    Could Help-me?


Constructive courteous comments are most welcome. Anonymous trolling will be removed with prejudice.