# implement "show tech-support" # usage: tech-support [ save [ ] ] # NOTE: this file is sourced, NOT executed function header { echo echo ---------------- echo "$*" echo ---------------- } # by default send to stdout OUT=1 DEFAULT_PATH=/opt/vyatta/etc/config/support DEFAULT_GROUP=users do_rotate () { local count=`ls -t $DEFAULT_PATH/*.tech-support.* 2>/dev/null |wc -l` if (( count >= 10 )); then local dfile=`ls -t $DEFAULT_PATH/*.tech-support.* 2>/dev/null |tail -1` rm -f $dfile >&/dev/null \ && echo "Removed old tech-support output file '$dfile'" fi } HOSTNAME=`hostname` CURTIME=`date +%F-%H%M%S` if [ "$1" == "save" ]; then # "save" is specified. save output to file. if [ -n "$2" ]; then # "" is specified. use it as the prefix. OUT="$2.$HOSTNAME.tech-support.$CURTIME" else OUT="$HOSTNAME.tech-support.$CURTIME" fi if [[ $OUT != /* ]]; then # it's not absolute path. save in default path. mkdir -p $DEFAULT_PATH >& /dev/null chgrp $DEFAULT_GROUP $DEFAULT_PATH >& /dev/null chmod 775 $DEFAULT_PATH >& /dev/null OUT="$DEFAULT_PATH/$OUT" do_rotate fi if ! touch $OUT >& /dev/null; then echo "Cannot create tech-support file '$OUT'" exit 1 fi echo "Saving output to '$OUT'..." fi ( export PATH=/sbin:/usr/sbin:$PATH header Current time date header Vyatta Version and Package Changes show version all header Installed Packages dpkg -l header Modules cat /proc/modules header "Kernel messages at boot time (/var/log/dmesg)" cat /var/log/dmesg header "Recent Kernel messages (dmesg)" dmesg header CPU Info cat /proc/cpuinfo header Mem Info cat /proc/meminfo header PCI Info sudo lspci -vvx header System Info ${vyatta_bindir}/vyatta-show-dmi header Interfaces show interfaces header Interface statistics ip -s link show for eth in $(cd /sys/class/net; echo eth*) do header "Ethtool statistics for $eth" sudo ethtool -S $eth done header Devices cat /proc/devices header Partitions cat /proc/partitions disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]$" | egrep -v "^$"` for disk in $disks; do header "Partitioning for disk $disk" fdisk -l /dev/$disk done header Mounts cat /proc/mounts header Diskstats cat /proc/diskstats header Kernel command line cat /proc/cmdline header Interrupts cat /proc/interrupts header Load Average cat /proc/loadavg header /opt/vyatta/etc/config/config.boot cat /opt/vyatta/etc/config/config.boot header Running configuration show configuration header \''ps -ef'\' ps -ef header \''df -h -x squashfs'\' df -h -x squashfs header \''lsof -P -n -i'\' sudo lsof -P -n -i header \'free\' free header /etc/apt/sources.list cat /etc/apt/sources.list header /etc/ipsec.conf cat /etc/ipsec.conf if [ -r /etc/ipsec.secrets ]; then header /etc/ipsec.secrets cat /etc/ipsec.secrets fi header \''ls -l /etc/rc?.d'\' ls -l /etc/rc?.d header /etc/rc.local cat /etc/rc.local header \''iptables -L -vn'\' sudo /sbin/iptables -L -vn header \''iptables -t nat -L -vn'\' sudo /sbin/iptables -t nat -L -vn header \''iptables -t mangle -L -vn'\' sudo /sbin/iptables -t mangle -L -vn header \''iptables -t raw -L -vn'\' sudo /sbin/iptables -t raw -L -vn function show_route_limit () { NUM=$(show $1 route $2 | wc -l) # subtract 3 lines of header [ $NUM -gt 3 ] && NUM=$[$NUM - 3] OUTPUT=$(echo show $1 route $2 \(total $NUM\)) CMD="show $1 route $2" if [ $3 -eq 0 ] then header $OUTPUT vtysh -c "$CMD" else header "$OUTPUT- limit $3" vtysh -c "$CMD" | head -n $3 fi } # # show all connected/static, limit the output others and include a total # show_route_limit ip connected 0 show_route_limit ip static 0 show_route_limit ip rip 500 show_route_limit ip ospf 500 show_route_limit ip bgp 500 show_route_limit ip '' 500 show_route_limit ipv6 connected 0 show_route_limit ipv6 static 0 show_route_limit ipv6 ripng 500 show_route_limit ipv6 ospf6 500 show_route_limit ipv6 bgp 500 show_route_limit ipv6 '' 500 header $HOME/.bash_history cat $HOME/.bash_history header \''show vrrp'\' show vrrp header \''last -ix'\' last -ix header wanrouter hwprobe wanrouter hwprobe header wanrouter version wanrouter version header wanrouter debug wanrouter debug header wanrouter summary wanrouter summary header wanrouter status wanrouter status header wanrouter modules wanrouter modules if [ -e /etc/wanpipe/wanrouter.rc ]; then header /etc/wanpipe/wanrouter.rc cat /etc/wanpipe/wanrouter.rc fi wanifs=( /sys/class/net/wan* ) wanifs=`echo -n ${wanifs[@]##*/}` echo "wanifs are $wanifs" for ifname in $wanifs ; do header "wanpipemon -i $ifname -c sc" sudo wanpipemon -i $ifname -c sc header "wanpipemon -i $ifname -c so" sudo wanpipemon -i $ifname -c so header "wanpipemon -i $ifname -c xcv" sudo wanpipemon -i $ifname -c xcv header "wanpipemon -i $ifname -c xru" sudo wanpipemon -i $ifname -c xru header "wanpipemon -i $ifname -c xm" sudo wanpipemon -i $ifname -c xm header "wanpipemon -i $ifname -c xl" sudo wanpipemon -i $ifname -c xl header "wanpipemon -i $ifname -c Ta" sudo wanpipemon -i $ifname -c Ta done for i in /etc/wanpipe/wanpipe*.conf ; do if [ -e $i ]; then header $i cat $i fi done header wanrouter conflog wanrouter conflog header /var/log/messages tail -n 250 /var/log/messages header "END OF TECH-SUPPORT FILE" ) 1>&$OUT 2>&1 if [ $OUT != "1" ]; then chgrp $DEFAULT_GROUP $OUT >& /dev/null chmod 664 $OUT >& /dev/null echo "Done" fi