发一个取M/T路由器信息的script
发一个取M/T路由器信息的script,要求加精
在各位购买的JUNIPER M/T系列骨干路由器出了故障以后,如果不是配置问题,则需要escalate到JTAC[JUNIPER TECHNICAL ASSISTANCE CENTER] 来处理,JTAC工程师在接收到CASE以后,一般会要求提供各种软硬件信息,下面这个SCRIPT就是用来收集这样的信息的, 这样可以省得大家敲命令了.
#! /bin/sh
# ------------ what's showtac ---------------
# showtac is a script to collect Juniper router current status information
# the output is saved in a log file under the log directory
# the log file name reflects the time the log is taken
# ------------ version info ---------------
# this is version 6
# differences between version 5
# 1. added M320 commands
# differences between version 4
# 1. added T640/T320/M7i/M10i commands
# 2. added IS-IS commands
# 3. added additional statistics gathering commands
# differences between version 3
# 1. added m40e commands
# differences between version 2
# 1. added 'show chassis environment routing-engine' for M160
# differences between version 1
# 1. detailed installation steps
# differences between prior versions
# 1. added comments on script installation on older versions JUNOS
# 2. added missing 'hour' in log filename
# ------------ installation ---------------
# this is an example of installation which puts the script under your home directory
# you can also put the script in other directories if you are familiar with Unix
# user@router> start shell
# % cat >showtac
# ...... <--- copy and paste the complete content of this script file here
# ^D <--- then ^D ( Ctrl + D ) on a new line
# % chmod +x showtac
# % exit
# user@router>
# this is an example of running the script, assuming that you've put the script under your home directory
# user@router> start shell
# % ./showtac
# % exit
# you should be able to see the log file by:
# user@router> show log ?
# on some older versions JUNOS, /var/log directory doesn't allow you to create log file
# thus when you use the script it will abort the script and says
# ......showtac: cannot create /var/log/...... : permission denied
# you need to fix the /var/log directory permission bits by
# % su
# % chmod go+w /var/log
# ------------ script definition ---------------
# log filename is in the format of /var/log/hostname-log-YYYY-MM-DD-HH-MM-SS
filename="/var/log/"`hostname`"-log-"`date +%Y-%m-%d-%H-%M-%S`
# prompt is in the format of username@hostname>
prompt=`whoami`"@"`hostname`">"
# subroutine to log the prompt & command , then the command output, then a blank line
# $@ doesn't work so need workaround, thus assumes no more than 9 words on CLI command line
run() {
echo $prompt $1 $2 $3 $4 $5 $6 $7 $8 $9 >>$filename
cli -c "$1 $2 $3 $4 $5 $6 $7 $8 $9" >>$filename
echo >>$filename
}
# here begins the actual script, you can add your commands here
run show version
# get router model from 'show version' output
model=`grep -i model $filename | awk '{print $2}'`
run show chassis hardware
run show chassis routing-engine
# model dependent PFE commands
case $model in
m5|m10)
run show chassis feb
;;
m7i|m10i)
run show chassis cfeb
;;
m20)
run show chassis ssb
;;
m40)
run show chassis scb
;;
m160|m40e)
run show chassis sfm
run show chassis sfm detail
;;
t640|t320|m320)
run show chassis sibs
run show chassis spmb
;;
esac
run show chassis fpc
run show chassis fpc detail
run show chassis environment
# model dependent environment commands
case $model in
m160|m40e)
run show chassis environment pem
run show chassis environment pcg
run show chassis environment mcs
run show chassis environment sfm
run show chassis environment fpc
run show chassis environment fpm
;;
t640|t320|m320)
run show chassis environment pem
run show chassis environment scg
run show chassis environment cb
run show chassis environment sib
run show chassis environment fpc
run show chassis environment fpm
;;
esac
run show chassis alarm
# routing-engine general health
run show task memory
run show system buffer
run show system process extensive
run show system queue
run show system virtual-memory
run show system connections
# general routing and routing protocols
run show route summary
run show ospf interface extensive
run show ospf neighbor extensive
run show ospf statistics
run show isis interface extensive
run show isis adjacency extensive
run show isis statistics
run show isis spf log
run show bgp summary
run show bgp neighbor
# traffic statistics
run show system statistics
run show pfe statistics error
run show pfe statistics dma
run show pfe statistics notification
run show pfe statistics traffic
run show pfe statistics ip icmp
# miscellaneous
run show system storage
run file list /var/log detail
run file list /var/crash detail
run file list /var/tmp detail