LoginSignup
0
1

More than 5 years have passed since last update.

RANCIDでCiscoのコンフィグ取得時にTimestampが出力されるのを防ぐ方法

Posted at

はじめに

Catalyst等で vtyにexec prompt timestampを入れておくと、コマンドを叩いた時間が表示されるという便利機能があるが
この部分が日時バックアップ時に差分として記録されてしまっていたので、実際にコンフィグを変更した日付がわかり辛くなっていた。

  • コマンド実行時にタイムスタンプを残す設定例
line vty 0 4
 exec prompt timestamp

コマンドを叩くたびに日付と時間、CPU使用率等が変化するため、差分として記録されてしまう。

!Flash: Load for five secs: 36%/0%; one minute: 31%; five minutes: 31%      
!Flash: Time source is NTP, 23:01:08.558 JST Tue Sep 27 2016

RANCID 2.3.8の場合

/usr/local/rancid/bin/rancid内に次のような変更を加える

/usr/local/rancid/bin/rancid
  # dummy function
> #sub DoNothing {print STDOUT;}
> sub DoNothing {
>     print STDERR "    In DoNothing: $_" if ($debug);
>     while (<INPUT>) {
>   tr/\015//d;
>   last if (/^$prompt/);
>   next if (/^(\s*|\s*$cmd\s*)$/);
>     }
>     return 0;
> }
  # Main
  @commandtable = (
>   {'terminal no exec prompt timestamp' => 'DoNothing'},
    {'show version'         => 'ShowVersion'},

RANCID 3.4.1の場合

ファイル構成が変わっているが、やることは同じ。

/usr/loca/rancid/lib/rancid/ios.pm
> # clear exec timestamps 
> sub DoNothing {
>     my($INPUT, $OUTPUT, $cmd) = @_;
>     print STDERR "    In DoNothing: $_" if ($debug);
> 
>     while (<INPUT>) {
>       tr/\015//d;
>       if (/^$prompt/) { $found_version = 1; last};
>       next if (/^(\s*|\s*$cmd\s*)$/);
>       next if (/^\s+\^$/);
>     }
>     return 0;
> }
>


# This routine parses "show version"
sub ShowVersion {
/usr/loca/rancid/etc/rancid.types.base
  # Cisco IOS device & Allied Telesis AW+
  cisco;script;rancid -t cisco
  cisco;login;clogin
  cisco;module;ios
  cisco;inloop;ios::inloop
> cisco;command;ios::DoNothing;terminal no exec prompt timestamp
  cisco;command;ios::ShowVersion;show version

関連リソース

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1