はじめに
ここでは、Nexus Switch でのログ取得時に有用な Redirect 機能について説明します。
Redirect 機能とは
Nexus の CLI での Redirect とは以下の2コマンドを指します。
> : Redirect it to a file
>> : Redirect it to a file in append mode
上記を使うと通常 CLI に表示されていたログを、Redirect コマンドに続くファイルに書き込みます。
メリットとしては、CLIに長く出力されるログ取得を禁止している環境でのログ取得や、一定時間で timeout する環境でも長く出力されるログを取得することができるなどが挙げられます。
使用例
使い方1「 > 」
N9K-C93180YC-EX# show tech-support > bootflash:show_tech.txt
上記は bootflash:上に、show_tech.txt を作成し、その中に show tech-support で表示されるはずだったログを書き込んでいます。
なお、> を使用する際に既に同名ファイルが有る場合は、内容を上書きします。
使い方2「 >> 」
N9K-C93180YC-EX# show interface counter >> bootflash:show_interface_counter.txt
上記は bootflash:上に存在する show_interface_counter.txt に追記 ( append ) しています。
なお、>> を使用する際に指定したファイルがない場合は、新規で作成されます。
例えば、以下の様に複数回使用しますと、show_interface_counter.txt 内には、取得時刻と、該当の show ログが複数回記載されます。
N9K-C93180YC-EX# show clock >> bootflash:show_interface_counter.txt
N9K-C93180YC-EX# show interface counter >> bootflash:show_interface_counter.txt
N9K-C93180YC-EX#
N9K-C93180YC-EX# show clock >> bootflash:show_interface_counter.txt
N9K-C93180YC-EX# show interface counter >> bootflash:show_interface_counter.txt
本 Redirect 機能 のオプションとして、ファイル保存先を指定することができます。
N9K-C93180YC-EX# show running-config > ?
bootflash: Destination filesystem path
ftp: Destination filesystem path
scp: Destination filesystem path
sftp: Destination filesystem path
tftp: Destination filesystem path
usb1: Destination filesystem path
volatile: Destination filesystem path