#!/bin/bash

#used for cli command "show tech_support"
#no input and output var

dev_name=`hostname`
timeString=`date +%Y%m%d%H%M`
fileName=/tmp/$dev_name-$timeString-techSupport.log

echo "Start......"

echo ""

echo "==========/pica/bin/shell/show_version.sh" > $fileName
/pica/bin/shell/show_version.sh >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 1: Display system version finished!"

echo "==========/pica/bin/sif/tools/print_interfaces -d" >> $fileName
/pica/bin/sif/tools/print_interfaces -d >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 2: Display system interface finished!"

echo "==========cat /pica/config/pica.conf" >> $fileName
if [ -f /pica/config/pica.conf ]; then
cat /pica/config/pica.conf >> $fileName
echo "" >> $fileName
sleep 1
fi
echo "Item 3: Display system configuration finished!"

echo "==========ls /pica/config -l" >> $fileName
ls /pica/config -l >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 4: Display system config files finished!"

echo "==========ps" >> $fileName
ps >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 5: Display system process finished!"

echo "==========/pica/bin/sif/tools/print_fdb -table" >> $fileName
/pica/bin/sif/tools/print_fdb -table >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 6: Display system fdb table finished!"

echo "==========/pica/bin/sif/tools/print_fdb -t -d -f 2" >> $fileName
/pica/bin/sif/tools/print_fdb -t -d -f 2 >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 7: Display system fdb entries finished!"

echo "==========/pica/bin/ospf/tools/print_neighbours -d" >> $fileName
/pica/bin/ospf/tools/print_neighbours -d >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 8: Display system ospf neighbors finished!"

echo "==========/pica/bin/ospf/tools/show_ospf_interface -d" >> $fileName
/pica/bin/ospf/tools/show_ospf_interface -d >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 9: Display system ospf interfaces finished!"

echo "==========IPv4 route" >> $fileName
/sbin/ip -4 route >> $fileName
echo "" >> $fileName
sleep 1
echo "==========IPv4 route table 252" >> $fileName
/sbin/ip -4 route list table 252 >> $fileName
echo "" >> $fileName
sleep 1
echo "==========IPv6 route" >> $fileName
/sbin/ip -6 route >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 10: Display system route table finished!"

echo "==========grep err or warning message from ramdisk log" >> $fileName
if [ -f /tmp/log/messages ];then
grep -E "err|warning" /tmp/log/messages >> $fileName
fi
sleep 1
echo "==========grep err or warning message from cf-card log" >> $fileName
if [ -f /var/log/messages ];then
grep -E "err|warning" /var/log/messages >> $fileName
fi
echo "" >> $fileName
sleep 1
echo "Item 11: Get error event from log!"

echo "==========/pica/bin/sif/tools/print_hw_routes -t ROUTE4 -i ALL" >> $fileName
/pica/bin/sif/tools/print_hw_routes -t ROUTE4 -i ALL >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 12: Display system hard-route table finished!"

echo "==========/pica/bin/sif/tools/print_hw_routes -t HOST4 -i ALL" >> $fileName
/pica/bin/sif/tools/print_hw_routes -t HOST4 -i ALL >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 13: Display system hard-route for host finished!"

echo "==========/pica/bin/mstp/tools/print_mstp -f port -p 1 -b -a" >> $fileName
/pica/bin/mstp/tools/print_mstp -f port -p 1 -b -a >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 14: Dispaly system spanning tree interfaces finished!"

echo "==========/pica/bin/mstp/tools/print_mstp -f bridge -p 1 -b -a" >> $fileName
/pica/bin/mstp/tools/print_mstp -f bridge -p 1 -b -a >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 15: Dispaly system spanning tree  bridge finished!"

echo "==========/pica/bin/sif/tools/print_vlans" >> $fileName
/pica/bin/sif/tools/print_vlans >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 16: Display system vlans table finished!"

echo "==========/pica/bin/sif/tools/print_vlan_interfaces -i all" >> $fileName
/pica/bin/sif/tools/print_vlan_interfaces -i all >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 17: Display system vlan-interfaces finished!"

echo "==========ls -l /pica/core/ " >> $fileName
ls -l /pica/core/ >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 18: Display system core-dump finished!"

echo "==========uptime" >> $fileName
uptime >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 19: Display system uptime finished!"

echo "==========ip -4 neigh" >> $fileName
/sbin/ip -4 neigh >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 20: Display system ipv4 neigh table finished!"

echo "==========ip -6 neigh" >> $fileName
/sbin/ip -6 neigh >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 21: Display system ipv6 neigh table finished!"

echo "==========/pica/bin/sif/tools/print_arp -m ARP" >> $fileName
/pica/bin/sif/tools/print_arp -m ARP >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 22: Display arp infomation!"

echo "==========/pica/bin/sif/tools/print_arp -m NEIGHBOUR" >> $fileName
/pica/bin/sif/tools/print_arp -m NEIGHBOUR >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 23: Display neighbor infomation!"

echo "==========/pica/bin/sif/tools/show_routes ribout all" >> $fileName
/pica/bin/sif/tools/show_routes ribout all >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 24: Display routes!"

echo "==========/pica/bin/sif/tools/print_hw_routes -t ROUTE4 -i ALL" >> $fileName
/pica/bin/sif/tools/print_hw_routes -t ROUTE4 -i ALL >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 25: Display all of ipv4 routes in hardware table!"

echo "==========/pica/bin/sif/tools/print_hw_routes -t ROUTE6 -i ALL" >> $fileName
/pica/bin/sif/tools/print_hw_routes -t ROUTE6 -i ALL >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 26: Display all of ipv6 routes in hardware table!"

echo "==========copp statistics" >> $fileName
/pica/bin/sif/tools/print_copp >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 27: Display copp statistics!"

echo "==========license -s" >> $fileName
license -s >> $fileName
echo "" >> $fileName
sleep 1
echo "Item 28: Display license!"

echo ""
echo "The information has been stored in $fileName, please forward to support@pica8.com"

exit 0

