summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2001-04-09 07:32:33 +0000
committerTar Committer <tar@ocjtech.us>2001-04-09 07:32:33 +0000
commit0e84b727786a16ade28bb081742e5c39c33ed7fa (patch)
tree12ee1a75666c0af32ecc7fbdc05c3a5833fb6fb8
parentb88919bea4b222a616adbdd2b82fc262a14afc8d (diff)
downloadrancid-rancid-2.2b.zip
rancid-rancid-2.2b.tar.gz
rancid-rancid-2.2b.tar.xz
Imported from rancid-2.2b.tar.gz.rancid-2.2b
-rw-r--r--CHANGES15
-rw-r--r--README16
-rwxr-xr-xbin/alogin.in488
-rwxr-xr-xbin/arancid.in281
-rwxr-xr-xbin/cat5rancid.in3
-rwxr-xr-xbin/clogin.in50
-rwxr-xr-xbin/control_rancid.in4
-rwxr-xr-xbin/elogin.in38
-rwxr-xr-xbin/erancid.in3
-rwxr-xr-xbin/flogin.in42
-rwxr-xr-xbin/francid.in3
-rwxr-xr-xbin/jlogin.in46
-rwxr-xr-xbin/jrancid.in5
-rwxr-xr-xbin/rancid-fe.in2
-rwxr-xr-xbin/rancid.in9
-rwxr-xr-xbin/rrancid.in3
-rwxr-xr-xconfigure6
-rw-r--r--configure.in6
-rw-r--r--man/Makefile.am3
-rw-r--r--man/Makefile.in2
-rw-r--r--man/alogin.11
-rw-r--r--man/clogin.15
-rw-r--r--man/cloginrc.51
-rw-r--r--man/rancid.15
-rw-r--r--man/rancid_intro.12
-rw-r--r--man/router.db.532
-rw-r--r--util/README1
-rwxr-xr-xutil/configure4
-rw-r--r--util/configure.in3
-rwxr-xr-xutil/downreport.in59
-rwxr-xr-xutil/rtrfilter.in2
31 files changed, 1012 insertions, 128 deletions
diff --git a/CHANGES b/CHANGES
index 172891d..6711320 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,18 @@
+2.2b
+ bin/alogin and changes of beta quality for Alteon WebOS switch
+ from andrew fort.
+
+ Check for more types of cisco 12000s. Also check for 2600s.
+
+ jrancid's show chassis hardware needs detail arg in junos 4.4
+
+ make *login print \n before errors, so rancid can use an anchored
+ match to find login errors and avoid such matches in router o/p.
+
+ make *login automatically add host keys with openssh's prompting
+
+ All routers not listed as 'up' in router.db are considered down.
+
2.1
Change default umask to 027 (it was 007) mainly as an
attempt to stop people from changing stuff in rancid's CVS
diff --git a/README b/README
index 9a663e2..5d29c9a 100644
--- a/README
+++ b/README
@@ -83,6 +83,8 @@ Quick Installation Guide (an example):
LIST_OF_GROUPS="backbone aggregation switches"
4) Put .cloginrc in the home directory of the user who will run rancid.
+ .cloginrc must be not be readable/writable/executable by "others",
+ i.e.: .cloginrc must be mode 0600 or 0640.
5) Modify .cloginrc.
@@ -113,8 +115,8 @@ Quick Installation Guide (an example):
for more information on handling of '+'.
7) Run create_cvs.
- This creates all of the CVS necessary directories and all of the
- config directories.
+ This creates all of the necessary directories and config files for
+ each of the groups in LIST_OF_GROUPS and imports them into CVS.
8) For each "group", modify the router.db file in the group directory.
The file is of the form "router:mfg:state" where "router" is
@@ -131,7 +133,11 @@ Quick Installation Guide (an example):
juniper-router.domain.com:juniper:up
redback-dsl-router.domain.com:redback:down
-9) Put do-diffs in cron to be called however often you want it to
+9) For first-time users or new installations, run bin/do-diffs (with no
+ arguments) and check the resulting log file(s) (in logs/*) for errors.
+ Repeat until there are no errors.
+
+10) Put do-diffs in cron to be called however often you want it to
run for each group (do-diffs [<GROUP>]). If you run it less
often than once/hour, check the setting of OLDTIME in bin/env.
E.g.:
@@ -140,7 +146,7 @@ Quick Installation Guide (an example):
# clean out config differ logs
50 23 * * * /usr/bin/find <BASEDIR>/logs -mtime +2 -exec rm {} \;
-10) Note: If you are using any of these programs (other than
+11) Note: If you are using any of these programs (other than
do-diffs) out of cron, make sure that you set your $PATH
correctly so that they work. E.g.: if you are using clogin,
it can call id, telnet, ssh, and/or rsh.
@@ -150,7 +156,7 @@ Quick Installation Guide (an example):
50 23 * * * . /usr/local/rancid/bin/env; clogin -c 'sh vers' router
-11) Send any bugs, suggestions or updates to rancid@shrubbery.net.
+12) Send any bugs, suggestions or updates to rancid@shrubbery.net.
See the web page at http://www.shrubbery.net/rancid. We have
created the standard mailing lists for those interested;
rancid-announce@shrubbery.net and rancid-discuss@shrubbery.net.
diff --git a/bin/alogin.in b/bin/alogin.in
new file mode 100755
index 0000000..fe55787
--- /dev/null
+++ b/bin/alogin.in
@@ -0,0 +1,488 @@
+#!@EXPECT_PATH@ --
+##
+##
+## Copyright (C) 1997 by Henry Kilmer, Erik Sherk and Pete Whiting.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## There is no warranty or other guarantee of fitness of this software.
+## It is provided solely "as is". The author(s) disclaim(s) all
+## responsibility and liability with respect to this software's usage
+## or its effect upon hardware, computer systems, other software, or
+## anything else.
+##
+##
+#
+# alogin - Alteon WebOS switch login
+#
+# afort@choqolat.org is responsible for this particular mess
+# (andrew fort)
+#
+
+# Usage line
+set usage "Usage: $argv0 \[-c command\]\
+\[-f cloginrc-file\]\
+\[-s script-file\] \[-t timeout\] \[-u username\]\
+\[-v vty-password\] \[-x command-file\]\
+\[-y ssh_cypher_type\] router \[router...\]\n"
+
+# env(CLOGIN) may contain:
+# x == do not set xterm banner or name
+
+# Password file
+set password_file $env(HOME)/.cloginrc
+# Default is to login to the router
+set do_command 0
+set do_script 0
+# The default is to automatically enable
+set enable 1
+# The default is that you login non-enabled (tacacs can have you login already enabled)
+set autoenable 0
+# The default is to look in the password file to find the passwords. This
+# tracks if we receive them on the command line.
+set do_passwd 1
+
+# Find the user in the ENV, or use the unix userid.
+if {[ info exists env(CISCO_USER) ] } {
+ set default_user $env(CISCO_USER)
+} elseif {[ info exists env(USER) ]} {
+ set default_user $env(USER)
+} else {
+ # This uses "id" which I think is portable. At least it has existed
+ # (without options) on all machines/OSes I've been on recently -
+ # unlike whoami or id -nu.
+ if [ catch {exec id} reason ] {
+ send_error "Error: could not exec id: $reason\n"
+ exit 1
+ }
+ regexp {\(([^)]*)} "$reason" junk default_user
+}
+
+# Sometimes routers take awhile to answer (the default is 10 sec)
+set timeout 45
+
+# Process the command line
+for {set i 0} {$i < $argc} {incr i} {
+ set arg [lindex $argv $i]
+
+ switch -glob -- $arg {
+ # Username
+ -u* -
+ -U* {
+ if {! [ regexp .\[uU\](.+) $arg ignore user]} {
+ incr i
+ set username [ lindex $argv $i ]
+ }
+ # VTY Password
+ } -v* -
+ -v* {
+ if {! [ regexp .\[vV\](.+) $arg ignore passwd]} {
+ incr i
+ set passwd [ lindex $argv $i ]
+ }
+ set do_passwd 0
+ # Enable Username
+ } -w* -
+ -W* {
+ # ignore -w
+ # Enable Password
+ } -e* -
+ -E* {
+ # ignore -e
+ # Command to run.
+ } -c* -
+ -C* {
+ if {! [ regexp .\[cC\](.+) $arg ignore command]} {
+ incr i
+ set command [ lindex $argv $i ]
+ }
+ set do_command 1
+ # Expect script to run.
+ } -s* -
+ -S* {
+ if {! [ regexp .\[sS\](.+) $arg ignore sfile]} {
+ incr i
+ set sfile [ lindex $argv $i ]
+ }
+ if { ! [ file readable $sfile ] } {
+ send_user "Error: Can't read $sfile\n"
+ exit 1
+ }
+ set do_script 1
+ # 'ssh -c' cypher type
+ } -y* -
+ -Y* {
+ if {! [ regexp .\[eE\](.+) $arg ignore cypher]} {
+ incr i
+ set cypher [ lindex $argv $i ]
+ }
+ # alternate cloginrc file
+ } -f* -
+ -F* {
+ if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
+ incr i
+ set password_file [ lindex $argv $i ]
+ }
+ # Timeout
+ } -t* -
+ -T* {
+ if {! [ regexp .\[tT\](.+) $arg ignore timeout]} {
+ incr i
+ set timeout [ lindex $argv $i ]
+ }
+ # Command file
+ } -x* -
+ -X {
+ if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} {
+ incr i
+ set cmd_file [ lindex $argv $i ]
+ }
+ set cmd_fd [open $cmd_file r]
+ set cmd_text [read $cmd_fd]
+ close $cmd_fd
+ set command [join [split $cmd_text \n] \;]
+ set do_command 1
+ # Do we enable?
+ } -noenable {
+ # ignore -noenable
+ # Does tacacs automatically enable us?
+ } -autoenable {
+ # ignore -autoenable
+ } -* {
+ send_user "Error: Unknown argument! $arg\n"
+ send_user $usage
+ exit 1
+ } default {
+ break
+ }
+ }
+}
+# Process routers...no routers listed is an error.
+if { $i == $argc } {
+ send_user "Error: $usage"
+}
+
+# Only be quiet if we are running a script (it can log its output
+# on its own)
+if { $do_script } {
+ log_user 0
+} else {
+ log_user 1
+}
+
+#
+# Done configuration/variable setting. Now run with it...
+#
+
+# Sets Xterm title if interactive...if its an xterm and the user cares
+proc label { host } {
+ global env
+ # if CLOGIN has an 'x' in it, don't set the xterm name/banner
+ if [info exists env(CLOGIN)] {
+ if {[string first "x" $env(CLOGIN)] != -1} { return }
+ }
+ # take host from ENV(TERM)
+ if [info exists env(TERM)] {
+ if [regexp \^(xterm|vs) $env(TERM) ignore ] {
+ send_user "\033]1;[lindex [split $host "."] 0]\a"
+ send_user "\033]2;$host\a"
+ }
+ }
+}
+
+# This is a helper function to make the password file easier to
+# maintain. Using this the password file has the form:
+# add password sl* pete cow
+# add password at* steve
+# add password * hanky-pie
+proc add {var args} { global int_$var ; lappend int_$var $args}
+proc include {args} {
+ global env
+ regsub -all "(^{|}$)" $args {} args
+ if { [ regexp "^/" $args ignore ] == 0 } {
+ set args $env(HOME)/$args
+ }
+ source_password_file $args
+}
+
+proc find {var router} {
+ upvar int_$var list
+ if { [info exists list] } {
+ foreach line $list {
+ if { [string match [lindex $line 0] $router ] } {
+ return [lrange $line 1 end]
+ }
+ }
+ }
+ return {}
+}
+
+
+# Loads the password file. Note that as this file is tcl, and that
+# it is sourced, the user better know what to put in there, as it
+# could install more than just password info... I will assume however,
+# that a "bad guy" could just as easy put such code in the clogin
+# script, so I will leave .cloginrc as just an extention of that script
+proc source_password_file { password_file } {
+ global env
+ if { ! [file exists $password_file] } {
+ send_user "Error: password file ($password_file) does not exist\n"
+ exit 1
+ }
+ file stat $password_file fileinfo
+ if { [expr ($fileinfo(mode) & 007)] != 0000 } {
+ send_user "Error: $password_file must not be world readable/writable\n"
+ exit 1
+ }
+ if [ catch {source $password_file} reason ] {
+ send_user "Error: $reason\n"
+ exit 1
+ }
+}
+
+
+# Log into the router.
+proc login { router user userpswd passwd prompt cmethod cyphertype } {
+ global spawn_id in_proc do_command do_script
+ global u_prompt p_prompt
+ set in_proc 1
+ set tryssh 1
+
+ # try each of the connection methods in $cmethod until one is successful
+ set progs [llength $cmethod]
+ foreach prog [lrange $cmethod 0 end] {
+ if ![string compare $prog "telnet"] {
+ if [ catch {spawn telnet $router} reason ] {
+ send_user "Error: telnet failed: $reason\n"
+ exit 1
+ }
+ } elseif ![string compare $prog "ssh"] {
+ if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
+ send_user "Error: ssh failed: $reason\n"
+ exit 1
+ }
+ } elseif ![string compare $prog "rsh"] {
+ if [ catch {spawn rsh -l $user $router} reason ] {
+ send_user "Error: rsh failed: $reason\n"
+ exit 1
+ }
+ } else {
+ puts "ERROR: unknown connection method: $prog"
+ return 1
+ }
+ incr progs -1
+ sleep 0.3
+
+ # This helps cleanup each expect clause.
+ expect_after {
+ timeout {
+ send_user "\nError: TIMEOUT reached\n"
+ catch {close}; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ } eof {
+ send_user "\nError: EOF received\n"
+ catch {close}; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ }
+ }
+
+ expect {
+ "Connection refused" {
+ close; wait
+ sleep 0.3
+ expect eof
+ send_user "Error: Connection Refused\n"; wait; return 1
+ } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ } "Unknown host\r\n" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ } "Host is unreachable" {
+ expect eof
+ send_user "Error: Host Unreachable!\n"; wait; return 1
+ } "No address associated with name" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ }
+ -re "$u_prompt" { send "$user\r"
+ expect {
+ "Login incorrect" { send_user "Error: Couldn't login\n";
+ catch {close}; wait; return 1 }
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ -re "$p_prompt" { send "$userpswd\r" }
+ "$prompt" { set in_proc 0; return 0 }
+ }
+ exp_continue
+ }
+ -re "$p_prompt" { send "$passwd\r"
+ expect {
+ "Password incorrect" { send_user "Error: Couldn't login\n";
+ catch {close}; wait; return 1 }
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ "$prompt" { set in_proc 0; return 0 }
+ "Confirm seeing above note" { send "y\r" }
+ }
+ exp_continue
+ }
+ -re "^Confirm seeing above note" { send "y\r" }
+ "Password incorrect" { send_user "Error: Check your password for $router\n";
+ catch {close}; wait; return 1 }
+ "$prompt" { }
+ denied { send_user "Error: Check your passwd for $router\n"
+ if { $do_command || $do_script } {
+ send "exit\r"
+ wait
+ return 1
+ } else {
+ return 1
+ }
+ }
+ "\r\n" { exp_continue; }
+ }
+ set in_proc 0
+ return 0
+}
+}
+
+# Run commands given on the command line.
+proc run_commands { prompt command } {
+ global in_proc
+ set in_proc 1
+
+ send "lines 0\r"
+ expect $prompt {}
+
+ regsub -all "\[)(]" $prompt {\\&} reprompt
+
+ # Is this a multi-command?
+ if [ string match "*\;*" "$command" ] {
+ set commands [split $command \;]
+ set num_commands [llength $commands]
+
+ for {set i 0} {$i < $num_commands} { incr i} {
+ send "[subst -nocommands [lindex $commands $i]]\r"
+ expect {
+ -re "^\[^\n\r]*$reprompt." {}
+ -re "^\[^\n\r ]*>>.*$reprompt" { exp_continue }
+ -re "\[\n\r]" { exp_continue }
+ }
+ }
+ } else {
+ send "[subst -nocommands $command]\r"
+ expect {
+ -re "^\[^\n\r]*$reprompt." {}
+ -re "^\[^\n\r ]*>>.*$reprompt" { exp_continue }
+ -re "\[\n\r]" { exp_continue }
+ }
+ }
+ send "exit\r"
+ expect {
+ -re "^WARNING: There are unsaved configuration changes."
+ {
+ send "y\r"
+ exp_continue
+ }
+ "\n" { exp_continue }
+ "\[^\n\r *]*Session terminated" { return 0 }
+ timeout { return 0 }
+ eof { return 0 }
+ }
+ set in_proc 0
+}
+
+#
+# For each router... (this is main loop)
+#
+source_password_file $password_file
+set in_proc 0
+foreach router [lrange $argv $i end] {
+ set router [string tolower $router]
+ send_user "$router\n"
+
+ # Figure out prompt.
+ set prompt "#"
+ set autoenable 1
+ set enable 0
+
+ # Figure out passwords
+ if { $do_passwd } {
+ set pswd [find password $router]
+ if { [llength $pswd] == 0 } {
+ send_user "Error - no password for $router in $password_file.\n"
+ continue
+ }
+ set passwd [lindex $pswd 0]
+ }
+
+ # Figure out username
+ if {[info exists username]} {
+ # command line username
+ set ruser $username
+ } else {
+ set ruser [find user $router]
+ if { "$ruser" == "" } { set ruser $default_user }
+ }
+
+ # Figure out username's password (if different from the vty password)
+ if {[info exists userpasswd]} {
+ # command line username
+ set userpswd $userpasswd
+ } else {
+ set userpswd [find userpassword $router]
+ if { "$userpswd" == "" } { set userpswd $passwd }
+ }
+
+ # Figure out prompts
+ set u_prompt [find userprompt $router]
+ if { "$u_prompt" == "" } { set u_prompt "(Username|login| Login):" }
+ set p_prompt [find passprompt $router]
+ if { "$p_prompt" == "" } { set p_prompt "\[Pp]assword:" }
+
+ # Figure out cypher type
+ if {[info exists cypher]} {
+ # command line cypher type
+ set cyphertype $cypher
+ } else {
+ set cyphertype [find cyphertype $router]
+ if { "$cyphertype" == "" } { set cyphertype "3des" }
+ }
+
+ # Figure out connection method
+ set cmethod [find method $router]
+ if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }
+
+ # Login to the router
+ if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype]} {
+ continue
+ }
+
+ if { $do_command } {
+ if {[run_commands $prompt $command]} {
+ continue
+ }
+ } elseif { $do_script } {
+ send "lines 0\r"
+ expect $prompt {}
+ source $sfile
+ close
+ } else {
+ label $router
+ log_user 1
+ interact
+ }
+
+ # End of for each router
+ wait
+ sleep 0.3
+}
+exit 0
diff --git a/bin/arancid.in b/bin/arancid.in
new file mode 100755
index 0000000..5003ddd
--- /dev/null
+++ b/bin/arancid.in
@@ -0,0 +1,281 @@
+#!@PERLV_PATH@
+##
+## Hacked version of rancid for Alteon WebOS switches
+## tested with: ad3 v8.1.18
+## afort@choqolat.org (andrew fort)
+##
+##
+## Copyright (C) 1997 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## There is no warranty or other guarantee of fitness of this software.
+## It is provided solely "as is". The author(s) disclaim(s) all
+## responsibility and liability with respect to this software's usage
+## or its effect upon hardware, computer systems, other software, or
+## anything else.
+##
+##
+#
+# RANCID - Really Awesome New Cisco confIg Differ
+#
+# arancid - Alteon WebOS plugin for rancid
+#
+# usage: arancid [-d] [-l] [-f filename | $host]
+#
+use Getopt::Std;
+getopts('dflm');
+$log = $opt_l;
+$debug = $opt_d;
+$file = $opt_f;
+$host = $ARGV[0];
+$clean_run = 0;
+$found_end = 0;
+$prompt = "#";
+$timeo = 90; # clogin timeout in seconds
+
+# This routine is used to print out the router configuration
+sub ProcessHistory {
+ my($new_hist_tag,$new_command,$command_string,@string)=(@_);
+ if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
+ && defined %history) {
+ print eval "$command \%history";
+ undef %history;
+ }
+ if (($new_hist_tag) && ($new_command) && ($command_string)) {
+ if ($history{$command_string}) {
+ $history{$command_string} = "$history{$command_string}@string";
+ } else {
+ $history{$command_string} = "@string";
+ }
+ } elsif (($new_hist_tag) && ($new_command)) {
+ $history{++$#history} = "@string";
+ } else {
+ print "@string";
+ }
+ $hist_tag = $new_hist_tag;
+ $command = $new_command;
+ 1;
+}
+
+sub numerically { $a <=> $b; }
+
+# This is a sort routing that will sort numerically on the
+# keys of a hash as if it were a normal array.
+sub keynsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort numerically keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# keys of a hash as if it were a normal array.
+sub keysort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# values of a hash as if it were a normal array.
+sub valsort{
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort values %lines) {
+ $sorted_lines[$i] = $key;
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a numerical sort routing (ascending).
+sub numsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $num (sort {$a <=> $b} keys %lines) {
+ $sorted_lines[$i] = $lines{$num};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routine that will sort on the
+# ip address when the ip address is anywhere in
+# the strings.
+sub ipsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $addr (sort sortbyipaddr keys %lines) {
+ $sorted_lines[$i] = $lines{$addr};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# These two routines will sort based upon IP addresses
+sub ipaddrval {
+ my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);
+ $a[3]+256*($a[2]+256*($a[1]+256*$a[0]));
+}
+sub sortbyipaddr {
+ &ipaddrval($a) <=> &ipaddrval($b);
+}
+
+# This routine parses "/info/sys" (cf. show version)
+sub ShowVersion {
+ print STDERR " In ShowVersion: $_" if ($debug);
+
+ while (<INPUT>) {
+ tr/\015//d;
+ last if (/^>>.*$prompt/);
+ next if(/^(\s*|\s*$cmd\s*)$/);
+
+ /^(ACEdirector.*|ACEswitch.*|Alteon.*)/i &&
+ ProcessHistory("COMMENTS","keysort","A1", "\/\*Model: $1\n") && next;
+ /^Software Version\s+(.*?)\s\((.*)\)/i &&
+ ProcessHistory("COMMENTS","keysort","B1", "\/\*Image: Software: $1 ($2)\n") && next;
+ /^Hardware Part No:\s+(.*?)\s+/i &&
+ ProcessHistory("COMMENTS","keysort","A2", "\/\*Hardware part no: $1\n") && next;
+ /^MAC address:\s+([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})/i &&
+ ProcessHistory("COMMENTS","keysort","C1", "\/\*Base MAC address: $1\n") && next;
+ }
+ return(0);
+}
+
+# This routine processes a "/cfg/dump"
+sub WriteTerm {
+ print STDERR " In WriteTerm: $_" if ($debug);
+
+ # eat the header line
+ #$junk = <INPUT>;
+
+ # now just copy it verbatim to the history file
+ while (<INPUT>) {
+ tr/\015//d;
+ last if(/^>>.*$prompt/);
+ chop;
+ print $ENV{'NOCOMMSTR'};
+ /(rcomm|wcomm|t1com|t2com)(\s+)(.*)/ &&
+ ProcessHistory("","","","\/\*\t$1$2\"<removed>\"\n") && next;
+ #if (/^\s*snmp/ && defined($ENV{'NOCOMMSTR'})) {
+ # /snmp (getcomm|setcomm|trapcomm)(\s+)(\S*)/ &&
+ # ProcessHistory("","","","- snmp $1$2\"<removed>\"\n") && next;
+ #}
+ next if (/^\/\* Configuration dump taken/i);
+ next if (/^\/\* Version.*Base MAC.*/i);
+
+ if (/^\/script end/) {
+ $found_end = 1;
+ ProcessHistory("","","","$_\n");
+ return(1);
+ }
+
+ ProcessHistory("","","","$_\n");
+ }
+ return(0);
+}
+
+# dummy function
+sub DoNothing {print STDOUT;}
+
+# Main
+%commands=(
+ '/info/sys' => "ShowVersion",
+ '/cfg/dump' => "WriteTerm",
+);
+# keys() doesnt return things in the order entered and the order of the
+# cmds is important (show version first and write term last). pita
+@commands=(
+ "/info/sys",
+ "/cfg/dump",
+);
+$cisco_cmds=join(";",@commands);
+$cmds_regexp=join("|",@commands);
+
+open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
+select(OUTPUT);
+# make OUTPUT unbuffered if debugging
+if ($debug) { $| = 1; }
+
+if ($file) {
+ print STDERR "opening file $host\n" if ($debug);
+ print STDOUT "opening file $host\n" if ($log);
+ open(INPUT,"<$host") || die "open failed for $host: $!\n";
+} else {
+ print STDERR "executing alogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($debug);
+ print STDOUT "executing alogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($log);
+ if (defined($ENV{NOPIPE})) {
+ system "alogin -t $timeo -c \"$cisco_cmds\" $host </dev/null > $host.raw 2>&1" || die "alogin failed for $host: $!\n";
+ open(INPUT, "< $host.raw") || die "alogin failed for $host: $!\n";
+ } else {
+ open(INPUT,"alogin -t $timeo -c \"$cisco_cmds\" $host </dev/null |") || die "alogin failed for $host: $!\n";
+ }
+}
+
+ProcessHistory("","","","\/\*RANCID-CONTENT-TYPE: alteon\n\/\*\n");
+ProcessHistory("COMMENTS","keysort","B0","\/\*\n");
+ProcessHistory("COMMENTS","keysort","F0","\/\*\n");
+TOP: while(<INPUT>) {
+ tr/\015//d;
+ if (/^>>.*$prompt exit/) {
+ $clean_run=1;
+ last;
+ }
+
+ while (/>>.*$prompt\s*($cmds_regexp)\s*$/) {
+ $cmd = $1;
+ if (!defined($prompt)) {$prompt = ($_ =~ /^([^#]+#)/)[0]; }
+ print STDERR ("HIT COMMAND:$_") if ($debug);
+ if (!defined($commands{$cmd})) {
+ print STDERR "found unexpected command - \"$cmd\"\n";
+ $clean_run = 0;
+ last TOP;
+ }
+ $rval = &{$commands{$cmd}};
+ delete($commands{$cmd});
+ if ($rval == -1) {
+ $clean_run = 0;
+ last TOP;
+ }
+ }
+}
+print STDOUT "Done $logincmd: $_\n" if ($log);
+# Flush History
+ProcessHistory("","","","");
+# Cleanup
+close(INPUT);
+close(OUTPUT);
+
+if (defined($ENV{NOPIPE})) {
+ unlink("$host.raw") if (! $debug);
+}
+
+# check for completeness
+if (scalar(%commands) || !$clean_run || !$found_end) {
+ if (scalar(%commands)) {
+ printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
+ printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ }
+ if (!$clean_run || !$found_end) {
+ print STDOUT "End of run not found\n";
+ print STDERR "End of run not found\n" if ($debug);
+ system("/usr/bin/tail -1 $host.new");
+ }
+ unlink "$host.new" if (! $debug);
+}
diff --git a/bin/cat5rancid.in b/bin/cat5rancid.in
index cf0583d..c5406b0 100755
--- a/bin/cat5rancid.in
+++ b/bin/cat5rancid.in
@@ -1047,8 +1047,7 @@ TOP: while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/clogin.in b/bin/clogin.in
index 40d0d57..d1894b6 100755
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -60,7 +60,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -128,7 +128,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -173,7 +173,7 @@ for {set i 0} {$i < $argc} {incr i} {
set autoenable 1
set enable 0
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -183,7 +183,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -249,16 +249,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -274,21 +274,21 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
foreach prog [lrange $cmethod 0 end] {
if ![string compare $prog "telnet"] {
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: telnet failed: $reason\n"
+ send_user "\nError: telnet failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "ssh"] {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "Error: ssh failed: $reason\n"
+ send_user "\nError: ssh failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "rsh"] {
if [ catch {spawn rsh -l $user $router} reason ] {
- send_user "Error: rsh failed: $reason\n"
+ send_user "\nError: rsh failed: $reason\n"
exit 1
}
} else {
- puts "ERROR: unknown connection method: $prog"
+ puts "\nError: unknown connection method: $prog"
return 1
}
incr progs -1
@@ -328,29 +328,29 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
if !$progs {
send_user "\nError: Connection Refused ($prog)\n"; return 1
}
- } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ } eof { send_user "\nError: Couldn't login\n"; wait; return 1
} -nocase "unknown host\r" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
catch {close};
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
- -re "Host key not found .* \(yes\/no\)\?" {
+ -re "(Host key not found |The authenticity of host .* be established).*\(yes\/no\)\?" {
send "yes\r"
- send_user "Host $router added to the list of known hosts.\n"
+ send_user "\nHost $router added to the list of known hosts.\n"
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
return 1 }
-re "$u_prompt" { send "$user\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
- "Login invalid" { send_user "Error: Invalid login\n"; vatch {close}; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
+ "Login invalid" { send_user "\nError: Invalid login\n"; vatch {close}; wait; return 1 }
-re "$p_prompt" { send "$userpswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
@@ -363,14 +363,14 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
send "$passwd\r"
}
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-re "$e_prompt" { send "$enapasswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
"$prompt" { break; }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "exit\r"
wait
@@ -379,7 +379,7 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
return 1
}
}
- "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
}
set in_proc 0
@@ -398,8 +398,8 @@ proc do_enable { enauser enapasswd } {
-re "$e_prompt" { send "$enapasswd\r"; exp_continue}
"#" { set prompt "#" }
"(enable)" { set prompt "> (enable) " }
- denied { send_user "Error: Check your Enable passwd\n"; return 1}
- "% Bad passwords" { send_user "Error: Check your Enable passwd\n"
+ denied { send_user "\nError: Check your Enable passwd\n"; return 1}
+ "% Bad passwords" { send_user "\nError: Check your Enable passwd\n"
return 1
}
}
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index 58f6211..c61a0a4 100755
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -76,8 +76,8 @@ grep -v '^#' router.db > routers.db
cut -d: -f1,2 routers.db | sort -u > routers.all.new
if [ ! -f routers.all ] ; then touch routers.all; fi
diff routers.all routers.all.new > /dev/null 2>&1; RALL=$?
-@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print "$F[0]:$F[1]\n")
- if ($F[2] =~ /^down$/i);}' routers.db | sort -u > routers.down.new
+@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print join(":", @F)."\n")
+ if ($F[2] !~ /^up$/i);}' routers.db | sort -u > routers.down.new
if [ ! -f routers.down ] ; then touch routers.down; fi
diff routers.down routers.down.new > /dev/null 2>&1; RDOWN=$?
@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print "$F[0]:$F[1]\n")
diff --git a/bin/elogin.in b/bin/elogin.in
index 89f7a99..46f459d 100755
--- a/bin/elogin.in
+++ b/bin/elogin.in
@@ -54,7 +54,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -115,7 +115,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -159,7 +159,7 @@ for {set i 0} {$i < $argc} {incr i} {
} -autoenable {
# ignore -autoenable
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -169,7 +169,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -236,16 +236,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -260,7 +260,7 @@ proc login { router user userpswd passwd prompt cyphertype } {
# Telnet to the router & try to login.
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: failed to telnet: $reason\n"
+ send_user "\nError: failed to telnet: $reason\n"
exit 1
}
sleep 0.3
@@ -291,23 +291,23 @@ proc login { router user userpswd passwd prompt cyphertype } {
close; wait
sleep 0.3
expect eof
- send_user "Error: Connection Refused\n"; wait; return 1
- } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ send_user "\nError: Connection Refused\n"; wait; return 1
+ } eof { send_user "\nError: Couldn't login\n"; wait; return 1
} "Unknown host\r\n" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
expect eof
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
-re "$u_prompt" { send "$user\r"
expect {
- "Login incorrect" { send_user "Error: Couldn't login\n";
+ "Login incorrect" { send_user "\nError: Couldn't login\n";
catch {close}; wait; return 1 }
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-re "$p_prompt" { send "$userpswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
@@ -315,17 +315,17 @@ proc login { router user userpswd passwd prompt cyphertype } {
}
-re "$p_prompt" { send "$passwd\r"
expect {
- "Password incorrect" { send_user "Error: Couldn't login\n";
+ "Password incorrect" { send_user "\nError: Couldn't login\n";
catch {close}; wait; return 1 }
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
- "Password incorrect" { send_user "Error: Check your password for $router\n";
+ "Password incorrect" { send_user "\nError: Check your password for $router\n";
catch {close}; wait; return 1 }
"$prompt" { }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "exit\r"
wait
diff --git a/bin/erancid.in b/bin/erancid.in
index 1106018..0377612 100755
--- a/bin/erancid.in
+++ b/bin/erancid.in
@@ -247,8 +247,7 @@ while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host elogin error: $_");
print STDERR ("$host elogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/flogin.in b/bin/flogin.in
index 6c82594..ac60bf3 100755
--- a/bin/flogin.in
+++ b/bin/flogin.in
@@ -62,7 +62,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -130,7 +130,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -171,7 +171,7 @@ for {set i 0} {$i < $argc} {incr i} {
set autoenable 1
set enable 0
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -181,7 +181,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -247,16 +247,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -269,7 +269,7 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
# Telnet to the router & try to login.
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: failed to telnet: $reason\n"
+ send_user "\nError: failed to telnet: $reason\n"
exit 1
}
sleep 0.3
@@ -307,7 +307,7 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
close; wait
if { $tryssh } {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "Error: failed to ssh: $reason\n"
+ send_user "\nError: failed to ssh: $reason\n"
exit 1
}
set tryssh 0
@@ -315,18 +315,18 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
exp_continue
} else {
expect eof
- send_user "Error: Connection Refused\n"; wait; return 1
+ send_user "\nError: Connection Refused\n"; wait; return 1
}
- } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ } eof { send_user "\nError: Couldn't login\n"; wait; return 1
} "Unknown host\r\n" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
expect eof
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
-re "Host key not found .* \(yes\/no\)\?" {
send "yes\r"
@@ -334,13 +334,13 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
return 1 }
-re "(Username:|login:|Name :)" {
sleep 1;
send "$user\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-re "\[Pp]assword:" { send "$userpswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
@@ -348,14 +348,14 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
}
"\[Pp]assword:" { send "$passwd\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
"Password:" { send "$enapasswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
"$prompt" { }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "quit"
wait
@@ -364,7 +364,7 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
return 1
}
}
- "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
set in_proc 0
return 0
@@ -381,8 +381,8 @@ proc do_enable { enauser enapasswd } {
-re "(Username|User Name):" { send "$enauser\r"; exp_continue}
"Password:" { send "$enapasswd\r"; exp_continue}
"#" { }
- denied { send_user "Error: Check your Enable passwd\n"; return 1}
- "% Bad passwords" { send_user "Error: Check your Enable passwd\n"
+ denied { send_user "\nError: Check your Enable passwd\n"; return 1}
+ "% Bad passwords" { send_user "\nError: Check your Enable passwd\n"
return 1
}
}
diff --git a/bin/francid.in b/bin/francid.in
index 560d959..66c4b75 100755
--- a/bin/francid.in
+++ b/bin/francid.in
@@ -341,8 +341,7 @@ TOP: while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host flogin error: $_");
print STDERR ("$host flogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/jlogin.in b/bin/jlogin.in
index e0ac844..a74cff4 100755
--- a/bin/jlogin.in
+++ b/bin/jlogin.in
@@ -54,7 +54,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -106,7 +106,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -144,7 +144,7 @@ for {set i 0} {$i < $argc} {incr i} {
set cypher [ lindex $argv $i ]
}
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -154,7 +154,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -220,16 +220,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -244,7 +244,7 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
foreach prog [lrange $cmethod 0 end] {
if ![string compare $prog "telnet"] {
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: telnet failed: $reason\n"
+ send_user "\nError: telnet failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "ssh"] {
@@ -253,22 +253,22 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
# spaces correctly.
if {$identfile != ""} {
if [ catch {spawn ssh -c $cyphertype -x -l $user -i $identfile $router} reason ] {
- send_user "Error: failed to ssh: $reason\n"
+ send_user "\nError: failed to ssh: $reason\n"
exit 1
}
} else {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "Error: failed to ssh: $reason\n"
+ send_user "\nError: failed to ssh: $reason\n"
exit 1
}
}
} elseif ![string compare $prog "rsh"] {
if [ catch {spawn rsh -l $user $router} reason ] {
- send_user "Error: rsh failed: $reason\n"
+ send_user "\nError: rsh failed: $reason\n"
exit 1
}
} else {
- puts "ERROR: unknown connection method: $prog"
+ puts "\nError: unknown connection method: $prog"
return 1
}
incr progs -1
@@ -308,32 +308,32 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
send_user "\nError: Connection Refused ($prog)\n"; return 1
}
}
- eof { send_user "Error: Couldn't login\n"; wait; return 1
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1
} -nocase "unknown host\r\n" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
catch {close};
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
-re "Enter passphrase for RSA key '\[^'\]*': " {
send_user "\nKey has passphrase!\n"
send "$passphrase\r"
exp_continue }
- -re "Host key not found .* \(yes\/no\)\?" {
+ -re "(Host key not found |The authenticity of host .* be established).*\(yes\/no\)\?" {
send "yes\r"
- send_user "Host $router added to the list of known hosts.\n"
+ send_user "\nHost $router added to the list of known hosts.\n"
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
return 1 }
-re "(Username|\[\r\n]login):" { send "$user\r"
expect {
- eof { send_user "Error: Couldn't login\n";
+ eof { send_user "\nError: Couldn't login\n";
wait; return 1 }
-re "\[Pp]assword:" { send "$passwd\r" }
"$prompt" { set in_proc 0; return 0 }
@@ -342,13 +342,13 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
}
"\[Pp]assword:" { send "$passwd\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
"$prompt" { break; }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "quit"
wait
@@ -357,7 +357,7 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
return 1
}
}
- "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
}
set in_proc 0
diff --git a/bin/jrancid.in b/bin/jrancid.in
index 6e2311f..91bbf54 100755
--- a/bin/jrancid.in
+++ b/bin/jrancid.in
@@ -392,7 +392,7 @@ sub DoNothing {print STDOUT;}
"show chassis environment" => "ShowChassisEnvironment",
"show chassis firmware" => "ShowChassisFirmware",
"show chassis fpc detail" => "ShowChassisFpcDetail",
- "show chassis hardware" => "ShowChassisHardware",
+ "show chassis hardware detail" => "ShowChassisHardware",
"show chassis routing-engine" => "ShowChassisRoutingEngine",
"show chassis scb" => "ShowChassisSCB",
"show chassis sfm detail" => "ShowChassisSCB",
@@ -407,7 +407,7 @@ sub DoNothing {print STDOUT;}
"show chassis environment",
"show chassis firmware",
"show chassis fpc detail",
- "show chassis hardware",
+ "show chassis hardware detail",
"show chassis routing-engine",
"show chassis scb",
"show chassis sfm detail",
@@ -447,7 +447,6 @@ ProcessHistory("","","","# RANCID-CONTENT-TYPE: juniper\n#\n");
TOP: while(<INPUT>) {
tr/\015//d;
if (/^Error:/) {
- s/^.*Error:/Error:/;
print STDOUT ("$host jlogin error: $_");
print STDERR ("$host jlogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/rancid-fe.in b/bin/rancid-fe.in
index 8e5d333..7a6c7ff 100755
--- a/bin/rancid-fe.in
+++ b/bin/rancid-fe.in
@@ -37,6 +37,8 @@ if ($vendor =~ /^cisco$/i) {
exec('francid', $router);
} elsif ($vendor =~ /^redback$/i) {
exec('rrancid', $router);
+} elsif ($vendor =~ /^alteon$/i) {
+ exec('arancid', $router);
}
printf(STDERR "unknown router manufacturer for $router: $vendor\n");
diff --git a/bin/rancid.in b/bin/rancid.in
index 065697a..d8b3694 100755
--- a/bin/rancid.in
+++ b/bin/rancid.in
@@ -194,6 +194,8 @@ sub ShowVersion {
$type = "AGS+";
} elsif ( $1 eq "2511" || $1 eq "2524" || $1 eq "AS2511-RJ") {
$type = "2500";
+ } elsif ( $1 =~ /261[01]/ || $1 =~ /262[01]/ ) {
+ $type = "2600";
} elsif ( $1 eq "3620" || $1 eq "3640") {
$type = "3600";
} elsif ( $1 eq "RSP7000") {
@@ -208,6 +210,8 @@ sub ShowVersion {
$type = "7200";
} elsif ( $1 =~ /1200[48]\/GRP/ || $1 =~ /1201[26]\/GRP/) {
$type = "12000";
+ } elsif ( $1 =~ /1201[26]-8R\/GRP/) {
+ $type = "12000";
} elsif ( $1 =~ /WS-C29/) {
$type = "2900XL";
$device = "switch";
@@ -429,7 +433,7 @@ sub DirSlotN {
return(1) if /\%Error: No such file or directory/;
return(1) if /No space information available/;
return(-1) if /\%Error calling/;
- return(-1) if /: device being squeezed/; # Flash is busy
+ return(-1) if /(: device being squeezed|ATA_Status time out)/i; # busy
return(-1) if (/command authorization failed/i);
return(1) if /(Open device \S+ failed|Error opening \S+:)/;
ProcessHistory("FLASH","","","!Flash: $dev: $_");
@@ -1112,8 +1116,7 @@ TOP: while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/rrancid.in b/bin/rrancid.in
index 9d40591..9d2663b 100755
--- a/bin/rrancid.in
+++ b/bin/rrancid.in
@@ -266,9 +266,6 @@ sub FlailHelplessly {
"show slot table",
"show config"
);
-# dir /flash
-# dir /pcmcia0
-# dir /pcmcia1
$redback_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
diff --git a/configure b/configure
index 1662bc5..789b238 100755
--- a/configure
+++ b/configure
@@ -794,7 +794,7 @@ PACKAGE=rancid
# VERSION needs to be updated such that 'make dist' uses the correct
# filename for the directory name and tarball.
-VERSION=2.1
+VERSION=2.2b
echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
echo "configure:801: checking whether to enable maintainer-specific portions of Makefiles" >&5
@@ -1508,14 +1508,14 @@ rd_cv_rd_bin_datas=$RD_BIN_DATAS
# RD_BIN_PROGS are bin/ .in's that need to be installed with execute perms.
RD_BIN_PROGS="cat5rancid control_rancid \
-clogin create_cvs do-diffs elogin erancid \
+alogin arancid clogin create_cvs do-diffs elogin erancid \
flogin francid jlogin jrancid par rancid-fe \
rancid rename rrancid"
rd_cv_rd_bin_progs=$RD_BIN_PROGS
# RD_UTIL_PROGS are util/ .in's that need to be installed with execute perms.
-RD_UTIL_PROGS="rtrfilter"
+RD_UTIL_PROGS="rtrfilter downreport"
rd_cv_rd_util_progs=$RD_UTIL_PROGS
diff --git a/configure.in b/configure.in
index b69b5a1..cf3bd4f 100644
--- a/configure.in
+++ b/configure.in
@@ -14,7 +14,7 @@ PACKAGE=rancid
# VERSION needs to be updated such that 'make dist' uses the correct
# filename for the directory name and tarball.
AC_SUBST(VERSION)
-VERSION=2.1
+VERSION=2.2b
AM_MAINTAINER_MODE()
@@ -157,14 +157,14 @@ rd_cv_rd_bin_datas=$RD_BIN_DATAS
# RD_BIN_PROGS are bin/ .in's that need to be installed with execute perms.
RD_BIN_PROGS="cat5rancid control_rancid \
-clogin create_cvs do-diffs elogin erancid \
+alogin arancid clogin create_cvs do-diffs elogin erancid \
flogin francid jlogin jrancid par rancid-fe \
rancid rename rrancid"
AC_SUBST(RD_BIN_PROGS)
rd_cv_rd_bin_progs=$RD_BIN_PROGS
# RD_UTIL_PROGS are util/ .in's that need to be installed with execute perms.
-RD_UTIL_PROGS="rtrfilter"
+RD_UTIL_PROGS="rtrfilter downreport"
AC_SUBST(RD_UTIL_PROGS)
rd_cv_rd_util_progs=$RD_UTIL_PROGS
diff --git a/man/Makefile.am b/man/Makefile.am
index 828fa06..c0af44c 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -6,7 +6,8 @@ AUTOMAKE_OPTIONS=foreign no-dependencies
@SET_MAKE@
man_gen_MANS = env.5 lg.conf.5 lg_intro.1
-man_nogen_MANS = do-diffs.1 clogin.1 control_rancid.1 create_cvs.1 rancid.1 \
+man_nogen_MANS = do-diffs.1 alogin.1 clogin.1 control_rancid.1 create_cvs.1 \
+ rancid.1 \
rancid_intro.1 cloginrc.5 router.db.5 \
elogin.1 flogin.1 jlogin.1 \
jrancid.1 francid.1 cat5rancid.1 erancid.1
diff --git a/man/Makefile.in b/man/Makefile.in
index 36aff3e..c74034e 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -96,7 +96,7 @@ VERSION = @VERSION@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_gen_MANS = env.5 lg.conf.5 lg_intro.1
-man_nogen_MANS = do-diffs.1 clogin.1 control_rancid.1 create_cvs.1 rancid.1 rancid_intro.1 cloginrc.5 router.db.5 elogin.1 flogin.1 jlogin.1 jrancid.1 francid.1 cat5rancid.1 erancid.1
+man_nogen_MANS = do-diffs.1 alogin.1 clogin.1 control_rancid.1 create_cvs.1 rancid.1 rancid_intro.1 cloginrc.5 router.db.5 elogin.1 flogin.1 jlogin.1 jrancid.1 francid.1 cat5rancid.1 erancid.1
man_MANS = $(man_gen_MANS) $(man_nogen_MANS)
diff --git a/man/alogin.1 b/man/alogin.1
new file mode 100644
index 0000000..4c83247
--- /dev/null
+++ b/man/alogin.1
@@ -0,0 +1 @@
+.so man1/clogin.1
diff --git a/man/clogin.1 b/man/clogin.1
index e40224b..909adc6 100644
--- a/man/clogin.1
+++ b/man/clogin.1
@@ -47,8 +47,9 @@ router
is an
.BR expect (1)
script to automate the process of logging into a Cisco router, catalyst
-switch, or Redback router. There are complementary scripts for Juniper,
-Foundry, and ADC-kentrox EZ-T3 mux named
+switch, or Redback router. There are complementary scripts for Alteon,
+Juniper, Foundry, and ADC-kentrox EZ-T3 mux named
+.B alogin,
.B jlogin,
.B flogin,
and
diff --git a/man/cloginrc.5 b/man/cloginrc.5
index 9933a50..d9ee4ed 100644
--- a/man/cloginrc.5
+++ b/man/cloginrc.5
@@ -6,6 +6,7 @@
.SH DESCRIPTION
.B .cloginrc
contains configuration information for
+.BR alogin (1),
.BR clogin (1),
.BR elogin (1),
.BR flogin (1),
diff --git a/man/rancid.1 b/man/rancid.1
index dd860df..fcb88bd 100644
--- a/man/rancid.1
+++ b/man/rancid.1
@@ -23,8 +23,9 @@ and so on.
product is a file with the name of it's last argument plus the suffix .new.
For example, hostname.new.
.PP
-There are complementary scripts for Cisco catalyst switch, Juniper, Foundry,
-and ADC-kentrox EZ-T3 mux named
+There are complementary scripts for Alteon WebOS switches, Cisco catalyst
+switch, Juniper, Foundry, and ADC-kentrox EZ-T3 mux named
+.B arancid,
.B cat5rancid,
.B jrancid,
.B francid,
diff --git a/man/rancid_intro.1 b/man/rancid_intro.1
index 3d866c1..0bdf1ba 100644
--- a/man/rancid_intro.1
+++ b/man/rancid_intro.1
@@ -6,7 +6,7 @@ rancid_intro \- introduction to the Really Awesome New Cisco confIg Differ
.SH INTRODUCTION
.B rancid
is really more than just a Cisco configuration differ. It handles several
-different device's configurations; currently including Cisco, Foundry,
+different device's configurations; currently including Alteon, Cisco, Foundry,
Juniper, Redback, and the ADC-Kentrox EZ-T3 mux.
.PP
.B rancid
diff --git a/man/router.db.5 b/man/router.db.5
index b51153b..873497b 100644
--- a/man/router.db.5
+++ b/man/router.db.5
@@ -14,7 +14,7 @@ One device is listed per-line, where the syntax is:
.PP
.in +1i
.nf
-<device_name>:<device_type>:<state>[:]
+<device_name>:<device_type>:<state>[:][comments]
.fi
.in -1i
.PP
@@ -48,6 +48,9 @@ Domain Name) works best, as in the example above.
The type of device from the set:
.RS 8n
.TP
+.B alteon
+A Alteon WebOS switches.
+.TP
.B cat5
A cisco catalyst switch (ie: running the catalyst OS, not IOS).
.TP
@@ -71,9 +74,30 @@ A Redback router, NAS, etc.
.\"
.TP
.B <state>
-The state is either "up" or "down". If the device is marked "down", the
-device's
-configuration will not be collected.
+The state is either "up", or some other arbitrary value, e.g. "down".
+If the device is not marked "up" the device's configuration will not be
+collected.
+It is highly recommended that comments are made for
+any router not listed as up, so as to indicate the
+reason a router is not to be polled, e.g.:
+.TP
+.PP
+dial1.paris:cisco:up:
+core1.paris:cisco:down:in testing until 5/5/2001.
+core2.paris:cisco:ticketed:Ticket 6054234, 5/3/2001
+border1.paris:juniper:up:
+.TP
+.PP
+Please see the script "downreport" in util/ for a
+daily report of routers in router.db that aren't
+marked "up".
+.PP
+.TP
+.B [comments]
+.TP
+.PP
+Freeform string to describe the current state of
+the router.
.PP
A ``#'' at the begining of a line is a comment; the entire line is
ignored.
diff --git a/util/README b/util/README
index cecb9df..1a579d6 100644
--- a/util/README
+++ b/util/README
@@ -5,3 +5,4 @@ sources included for convenience.
README This file.
lg looking glass pkg
rtrfilter mail filter for diffs
+downreport Daily report of routers not listed as up in router.db
diff --git a/util/configure b/util/configure
index 8d59fa6..fb8e766 100755
--- a/util/configure
+++ b/util/configure
@@ -620,6 +620,9 @@ PERLV_PATH=$ac_cv_path_PERLV_PATH
EXPECT_PATH=$ac_cv_path_EXPECT_PATH
+MAILPLUS=$rd_cv_MAILPLUS
+
+
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
@@ -772,6 +775,7 @@ s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@RD_UTIL_PROGS@%$RD_UTIL_PROGS%g
s%@PERLV_PATH@%$PERLV_PATH%g
s%@EXPECT_PATH@%$EXPECT_PATH%g
+s%@MAILPLUS@%$MAILPLUS%g
CEOF
EOF
diff --git a/util/configure.in b/util/configure.in
index 17f7b4e..c23c556 100644
--- a/util/configure.in
+++ b/util/configure.in
@@ -17,6 +17,9 @@ AC_SUBST(PERLV_PATH)
EXPECT_PATH=$ac_cv_path_EXPECT_PATH
AC_SUBST(EXPECT_PATH)
+MAILPLUS=$rd_cv_MAILPLUS
+AC_SUBST(MAILPLUS)
+
AC_OUTPUT(Makefile $RD_UTIL_PROGS)
# fix permissions on scripts.
diff --git a/util/downreport.in b/util/downreport.in
new file mode 100755
index 0000000..2926c5c
--- /dev/null
+++ b/util/downreport.in
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# Reports the list of routers not listed as 'up'.
+
+# Put this in your crontab to run once a day:
+# 0 0 * * * /where/rancid/lives/util/downreport
+
+# It can optionally
+# take a space list of groups on the command line
+# It will use the list of groups defined in env otherwise.
+
+
+ENVFILE="`dirname $0`../bin/env"
+
+. $ENVFILE
+
+if [ $# -ge 1 ] ; then
+ LIST_OF_GROUPS="$*"
+elif [ "$LIST_OF_GROUPS" = "" ] ; then
+ echo "LIST_OF_GROUPS is empty in $ENVFILE"
+ exit 1
+fi
+
+
+for GROUP in $LIST_OF_GROUPS; do
+ (
+ DIR=$BASEDIR/$GROUP
+ if [ -s $DIR/routers.down ]; then
+ (
+
+ cat << EOM
+
+ The following $GROUP routers are listed as other than up.
+
+ Routers listed as "up" in rancid's router.db are polled several
+times daily. This list is of routers that are not listed as up and therefore
+not polled.
+
+EOM
+
+ cat $DIR/routers.down;
+
+ )
+
+ else
+ (
+
+ cat << EOM
+
+ No routers are down/ticketed for router group $GROUP (yay).
+
+EOM
+
+ )
+ fi
+ ) |\
+ Mail -s "Down router report - $GROUP" @MAILPLUS@admin-$GROUP
+
+done
diff --git a/util/rtrfilter.in b/util/rtrfilter.in
index d1fa45f..8826047 100755
--- a/util/rtrfilter.in
+++ b/util/rtrfilter.in
@@ -133,7 +133,7 @@ sub filter {
sub usage {
print STDERR <<USAGE;
-usage: $me [-h] [-i <perl regex>] [-x <perl regex>] [-f <regex file>] [-u <From: address> [-s <subject>] <mail rcpt> [<rcpt> ...]
+usage: $me [-h] [-i <perl regex>] [-x <perl regex>] [-f <regex file>] [-u <From: address>] [-s <subject>] <mail rcpt> [<rcpt> ...]
-h prints this message
-f file containing perl regex matching router names (mind the cwd())
-i perl regex matching router names (inclusive)