Skip to content

Commit

Permalink
update Diag V2.0.6 and add logCollect.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Dai committed Jun 9, 2020
1 parent f117778 commit 1f405fb
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 3 deletions.
5 changes: 4 additions & 1 deletion files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ sudo cp $IMAGE_CONFIGS/poap/poap.service $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable poap.service

# Copy diag_app configuration files and templates
sudo cp $IMAGE_CONFIGS/diag_app/Ali_Diag_V2.0.4.deb $FILESYSTEM_ROOT/home/
sudo cp $IMAGE_CONFIGS/diag_app/Ali_Diag_V2.0.6.deb $FILESYSTEM_ROOT/home/

# Copy logCollect.sh
sudo cp $IMAGE_CONFIGS/diag_app/logCollect.sh $FILESYSTEM_ROOT/usr/bin/

# Copy port_led configuration files and templates
sudo cp $IMAGE_CONFIGS/port_led/port-led $FILESYSTEM_ROOT/usr/bin/
Expand Down
Binary file added files/image_config/diag_app/Ali_Diag_V2.0.6.deb
Binary file not shown.
160 changes: 160 additions & 0 deletions files/image_config/diag_app/logCollect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/bin/bash

rmalogpath="/tmp/logAll"
bmclogdir="/tmp/bmcLogAll"
soniclogdir="/tmp/sonicLogAll"

bmcloglist=("/var/log/syslog"
"/var/log/syslog.1"
'/var/log/syslog.[2-9].gz'
"/var/log/console_syslog.log"
"/var/log/console_syslog.log.1"
"/var/log/console_syslog.log.[2-9].gz"
"/var/log/cpumon.log"
"/var/log/fand.log"
"/var/log/dcdcmon.log"
"/var/log/powermon.log"
"/mnt/data/autodump.tar.gz"
"/var/log/autodump/autodump.tar.gz")

sonicloglist=("/var/log/syslog"
"/var/log/syslog.1"
'/var/log/syslog.[2-19].gz'
"/var/log/swss/sairedis.rec"
"/var/log/swss/sairedis.rec.1"
"/var/log/swss/sairedis.rec.[2-19].gz"
"/var/log/swss/swss.rec"
"/var/log/swss/swss.rec.1"
"/var/log/swss/swss.rec.[2-19].gz"
"/var/log/bmc/bmc_console.log"
"/var/log/bmc_feed_watchdog.log"
"/var/log/kern.*")

bmcloglistN=()
sonicloglistN=()


arrayExtend(){
#echo "bmc srcArr is: ${bmcloglist[@]}"
for (( i = 0 ; i < ${#bmcloglist[@]} ; i++ ))
do
#echo "${bmcloglist[$i]}"
str=`echo "${bmcloglist[$i]}" | grep -oE "[0-9]+\-[0-9]+"`
if [ $str ]; then
a=`echo $str |cut -d "-" -f1`
b=`echo $str |cut -d "-" -f2`
for((j=$a;j<=$b;j++)){
bmcloglistN[${#bmcloglistN[*]}]=`echo "${bmcloglist[$i]}" | sed -r "s/\[[0-9]+\-[0-9]+\]/$j/"`
}
else
bmcloglistN[${#bmcloglistN[*]}]=${bmcloglist[$i]}
fi
done
#echo ${bmcloglistN[*]}

#echo "sonic srcArr is: ${sonicloglist[@]}"
for (( i = 0 ; i < ${#sonicloglist[@]} ; i++ ))
do
#echo "${sonicloglist[$i]}"
str=`echo "${sonicloglist[$i]}" | grep -oE "[0-9]+\-[0-9]+"`
if [ $str ]; then
a=`echo $str |cut -d "-" -f1`
b=`echo $str |cut -d "-" -f2`
for((j=$a;j<=$b;j++)){
sonicloglistN[${#sonicloglistN[*]}]=`echo "${sonicloglist[$i]}" | sed -r "s/\[[0-9]+\-[0-9]+\]/$j/"`
}
else
sonicloglistN[${#sonicloglistN[*]}]=${sonicloglist[$i]}
fi
done
#echo ${sonicloglistN[*]}
}

scpFileFromBmc(){
expect -c "
#spawn scp -r root@240.1.1.1:$1 $2
spawn sudo scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@240.1.1.1:$1 $2
expect {
\"*assword\" { set timeout 300; send \"0penBmc\r\"; exp_continue; }
\"yes/no\" { send \"yes\r\"; }
}"
}

bmcLogCollect(){
echo "BMC log collect ..."

if [ -d $bmclogdir ]; then
rm -rf $bmclogdir
fi
mkdir -p $bmclogdir

for file in ${bmcloglistN[@]}
do
#echo "$file"
scpFileFromBmc $file $bmclogdir
done
}

sonicLogCollect(){
echo "SONiC log collect ..."

if [ -d $soniclogdir ]; then
rm -rf $soniclogdir
fi
mkdir -p $soniclogdir

for file in ${sonicloglistN[@]}
do
if [ -f $file ]; then
#echo "$file"
cp $file $soniclogdir
fi
done
}

checkfile(){
echo "BMC log file check exist test ..."
for file in ${bmcloglist[@]}
do
echo $file
if ssh root@240.1.1.1 test -e $file; then
echo "$file exist"
fi
done

}


arrayExtend
echo "bmcloglist:"
for line in ${bmcloglistN[*]}; do
echo $line
done

echo ""
echo "sonicloglist:"
for line in ${sonicloglistN[*]}; do
echo $line
done


bmcLogCollect
sonicLogCollect

rmalogdir=`echo $rmalogpath | awk -F "/" '{print $NF}'`

if [ -d $rmalogpath ]; then
rm -rf $rmalogpath
fi

if [ -f $rmalogpath.tar.gz ]; then
rm -rf $rmalogpath.tar.gz
fi

mkdir -p $rmalogpath
mv $bmclogdir $rmalogpath
mv $soniclogdir $rmalogpath

cd /tmp
tar -zcf $rmalogdir.tar.gz $rmalogdir
rm -rf $rmalogpath
3 changes: 1 addition & 2 deletions files/image_config/platform/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ update_mgmt_interface_macaddr() {

diag_install() {
echo "Diag install start ..."
sleep 200
dpkg -i /home/Ali_Diag_V2.0.4.deb
dpkg -i /home/Ali_Diag_V2.0.6.deb
}

boot_action() {
Expand Down

0 comments on commit 1f405fb

Please sign in to comment.