NETWORK ENGINEER BLOG

Tips and Reviews for Engineers

Cisco ASR で再起動を繰り返すスクリプト

使い道があるかわかりませんが、任意の間隔で再起動を繰り返すスクリプトを作成しました。

使用方法
  1. event timer countdown time に任意の時間(秒)を設定する。
  2. スクリプトを開始する際は、特権モードで[start]と入力し実行する。
  3. 次に特権モードで[restart]と入力し実行する。※再起動します。
  4. スクリプトを停止する際は、特権モードで[stop]と入力し実行する。
設定方法

監視用 Loopback インターフェースの作成

interface Loopback0
 ip address 1.1.1.1 255.255.255.0

監視用 SLA と Track の定義

ip sla 1
 icmp-echo 1.1.1.1 source-interface Loopback0
ip sla schedule 1 life forever start-time now
track 1 ip sla 1
 delay up 10

実行コマンドの定義

alias exec restart event manager run restart
alias exec stop event manager run stop
alias exec start event manager run start

再起動用 EEM の作成

event manager applet restart
 event none
 action 1.0 syslog msg "Router will restart by itself."
 action 2.0 reload

タイマー用 EEM の作成

event manager applet timer
 event track 1 state up
 action 1.0 cli command "enable"
 action 1.1 cli command "conf t"
 action 1.2 cli command "event manager applet restart"
 action 1.3 cli command "event timer countdown time 180"
 action 1.4 cli command "end"

スクリプト開始用 EEM の作成

event manager applet start
 event none
 action 1.0 cli command "enable"
 action 1.1 cli command "conf t"
 action 1.2 cli command "interface loopback0"
 action 1.3 cli command "no shutdown"
 action 1.4 cli command "end"
 action 1.5 cli command "wr"

スクリプト停止用 EEM の作成

event manager applet stop
 event none
 action 1.0 cli command "enable"
 action 1.1 cli command "conf t"
 action 1.2 cli command "interface loopback0"
 action 1.3 cli command "shutdown"
 action 1.4 cli command "event manager applet restart"
 action 1.5 cli command "event none"
 action 1.6 cli command "end"
 action 1.7 cli command "wr"

以上