このページで
例:Opスクリプトを使用してFPCを再起動する
この例では、 op スクリプト を使用して フレキシブル PIC コンセントレータ (FPC)を再起動します。
要件
この例では、FPC(フレキシブルPICコンセントレータ)または同等のコンポーネントを含むJunos OSを実行しているデバイスを使用しています。
概要と運用スクリプト
XSLT と SLAX の両方の形式で表示される次のスクリプトは、FPC が存在するスロット番号を指定して FPC を再起動します。スクリプトの呼び出し時に、ユーザーは CLI(コマンドライン インターフェイス)にスロット番号を入力します。このスクリプトは、スロット番号をパラメーターslotの値として格納し、再起動するFPCのスロット番号を含むコマンド文字列を構築request chassis fpcします。コマンドに相当する request chassis Junos 拡張マークアップ言語(XML)はありません。そのため、このスクリプトはリモート プロシージャ コール(RPC)を使用してコマンドを直接呼び出request chassis fpcします。
XSLT 構文
<?xml version="1.0" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:junos="http://xml.juniper.net/junos/*/junos"
xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm"
xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0">
<xsl:import href="../import/junos.xsl"/>
<xsl:variable name="arguments">
<argument>
<name>slot</name>
<description>Slot number of the FPC</description>
</argument>
</xsl:variable>
<xsl:param name="slot"/>
<xsl:template match="/">
<op-script-results>
<xsl:variable name="restart">
<command>
<xsl:value-of select="concat('request chassis fpc slot ', $slot,'
restart')"/>
</command>
</xsl:variable>
<xsl:variable name="result" select="jcs:invoke($restart)"/>
<output>
<xsl:text>Restarting the FPC in slot </xsl:text>
<xsl:value-of select="$slot"/>
<xsl:text>. </xsl:text>
<xsl:text>To verify, issue the "show chassis fpc" command.</xsl:text>
</output>
</op-script-results>
</xsl:template>
</xsl:stylesheet>
SLAX 構文
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
var $arguments = {
<argument> {
<name> "slot";
<description> "Slot number of the FPC";
}
}
param $slot;
match / {
<op-script-results> {
var $restart = {
<command> 'request chassis fpc slot ' _ $slot _ ' restart';
}
var $result = jcs:invoke($restart);
<output> {
expr "Restarting the FPC in slot ";
expr $slot;
expr ". ";
expr "To verify, issue the \"show chassis fpc\" command.";
}
}
}
構成
手順
手順
スクリプトをダウンロード、有効化、テストするには、以下の手順にしたがっています。
XSLT または SLAX スクリプトをテキスト ファイルにコピーし、必要に応じてファイル restart-fpc.xsl または restart-fpc.slax に名前を付け、デバイス上の /var/db/scripts/op/ ディレクトリにダウンロードします。
Junos OS
super-userログインクラスに属するユーザーのみが、このディレクトリ内のファイルにアクセスおよび編集できます。設定モードでは、 階層レベルで ステートメントを
file[edit system scripts op]含め、必要に応じて restart-fpc.xsl または restart-fpc.slax を含めます。[edit system scripts op] user@host# set file restart-fpc.(slax | xsl)
コマンドを
commit and-quit発行して設定をコミットし、動作モードに戻ります。[edit] user@host# commit and-quit
運用モード コマンドを発行して、op スクリプトを
op restart-fpc slot slot-number実行します。
検証
Op スクリプト実行の検証
目的
FPC が再起動され、現在オンラインになっていることを確認します。
アクション
運用モード コマンドを発行して、op スクリプトを op filename 実行します。FPC の slot 番号を引数として指定します。
user@host> op restart-fpc slot 0
スクリプトを実行すると、次のような出力が表示されます。
Restarting the FPC in slot 0. To verify, issue the "show chassis fpc" command.
動作モード コマンドを show chassis fpc detail fpc-slot 発行します。
user@host> show chassis fpc detail 0 Slot 0 information: State Online Temperature 36 degrees C / 96 degrees F Total CPU DRAM 1024 MB Total RLDRAM 256 MB Total DDR DRAM 4096 MB Start time: 2009-08-11 21:20:30 PDT Uptime: 0 hours, 1 minutes, 50 seconds Max Power Consumption 335 Watts
意味
コマンド出力は show chassis fpc detail 、FPCの状態、開始時間、稼働時間、および特性を表示します。FPCの開始時間と稼働時間を確認して、FPCが再起動されたことを確認します。状態を確認して、再起動されたFPCのステータスを確認します。ステータスが の Present場合、FPC は表示されますが、まだオンラインではありません。ステータスが の場合、 OnlineFPC はオンラインで動作しています。