文章目录
- 1.auto_dump.sh
- 2.auto_dump.cfg
- 3.auto_dump.sh
- 4.reload_fpga_uio_driver.sh
- 5.get_fpga_temp.sh
- 6.ethernet_port.sh
- 7.ddr_test.sh
1.auto_dump.sh
#!/bin/bash
work_path=$(pwd)
conf_file_path="${work_path}/auto_dump.cfg"
dst_dir_path=""
search_path="/var/log"
if [ $# -ne 1 ];then
program=$(basename "$0")
echo "Usage: $program <dst_dir_path>"
echo "Examples:$program /root/os_log/"
exit
else
dst_dir_path=$1
fi
cat $conf_file_path | while read conf_path_line
do
last_file_path=$(basename ${conf_path_line})
#last_file_path=${conf_path_line##*/}
tmp=${conf_path_line%/*}
last_dir_path=${tmp##*/} # network
find $search_path -name $last_file_path | while read search_path_line
do
mkdir -p $dst_dir_path
dst_file_path=$dst_dir_path/tmp/$last_dir_path/
mkdir -p $dst_file_path
cp $search_path_line $dst_file_path
done
cd $dst_dir_path/tmp/
if [ ! -f $conf_path_line ];then
echo $conf_path_line" not found"
fi
done
2.auto_dump.cfg
network/ip.log
network/netstate.log
network/route.log
network/arp.log
network/services.log
hardware/dmidecode.log
hardware/cmdline.log
hardware/cpuinfo.log
hardware/meminfo.log
hardware/lsblk.log
hardware/mount.log
hardware/interrupts.log
hardware/lspci.log
hardware/smartctl.log
hardware/modules.log
hardware/version.log
message/alert.log
message/audit.log
message/btmp.log
message/crit.log
message/debug.log
message/dmesg.log
message/err.log
message/info.log
message/messages.log
message/notice.log
message/syslog.log
message/warning.log
message/wtmp.log
3.auto_dump.sh
#!/bin/bash
dst_dir_path="/home/os_log"
dst_dir_path_filenum=10
mkdir_tmp(){
mkdir -p $dst_dir_path/tmp/network
mkdir -p $dst_dir_path/tmp/hardware
mkdir -p $dst_dir_path/tmp/message/var/log
}
write_network(){
ifconfig > $dst_dir_path/tmp/network/ip.log
netstat > $dst_dir_path/tmp/network/netstate.log
route > $dst_dir_path/tmp/network/route.log
arp > $dst_dir_path/tmp/network/arp.log
systemctl -all > $dst_dir_path/tmp/network/services.log
}
write_hardware(){
dmidecode > $dst_dir_path/tmp/hardware/dmidecode.log
cat /proc/cmdline > $dst_dir_path/tmp/hardware/cmdline.log
cat /proc/cpuinfo > $dst_dir_path/tmp/hardware/cpuinfo.log
cat /proc/meminfo > $dst_dir_path/tmp/hardware/meminfo.log
lsblk > $dst_dir_path/tmp/hardware/lsblk.log
mount > $dst_dir_path/tmp/hardware/mount.log
cat /proc/interrupts > $dst_dir_path/tmp/hardware/interrupts.log
lspci > $dst_dir_path/tmp/hardware/lspci.log
if [ -f $dst_dir_path/tmp/hardware/smartctl.log ];then
rm $dst_dir_path/tmp/hardware/smartctl.log
fi
fdisk -l | grep "/dev/sd" | awk '{print $2}' | awk -F ':' '{print $1}' > tmp
cat tmp | while read line
do
smartctl -a $line >> $dst_dir_path/tmp/hardware/smartctl.log
done
rm tmp
fdisk -l | grep "/dev/nvme" | head -1 | awk '{print $2}' | awk -F ':' '{print $1}' > tmp
cat tmp | while read line
do
smartctl -a $line >> $dst_dir_path/tmp/hardware/smartctl.log
done
rm tmp
cat /proc/modules > $dst_dir_path/tmp/hardware/modules.log
cat /proc/version > $dst_dir_path/tmp/hardware/version.log
}
tar_log(){
cp -rf /var/log/* $dst_dir_path/tmp/message/var/log
cd $dst_dir_path/tmp
tar -czf log.tar.gz *
mv log.tar.gz $dst_dir_path/log.tar.gz
rm -rf $dst_dir_path/tmp
}
mov_log(){
if [ -f $dst_dir_path/log.9.tar.gz ];then
rm $dst_dir_path/log.9.tar.gz
fi
if [ -f $dst_dir_path/log.tar.gz ] && [ ! -f $dst_dir_path/log.9.tar.gz ];then
for((i=$(($dst_dir_path_filenum-2));i>=1;i--))
do
if [ -f $dst_dir_path/log.$i.tar.gz ];then
mv $dst_dir_path/log.$i.tar.gz $dst_dir_path/log.$(($i+1)).tar.gz
fi
done
mv $dst_dir_path/log.tar.gz $dst_dir_path/log.1.tar.gz
fi
}
mkdir_tmp
write_network
write_hardware
mov_log
tar_log
################################################################################
if [ -f $dst_dir_path/log.9.tar.gz ];then
rm $dst_dir_path/log.1.tar.gz
for((j=2;j<=$(($dst_dir_path_file_num-1));j++))
do
mv $dst_dir_path/log.$j.tar.gz $dst_dir_path/log.$(($j-1)).tar.gz
done
mv $dst_dir_path/log.tar.gz $dst_dir_path/log.9.tar.gz
fi
if [ -f $dst_dir_path/log.tar.gz ] && [ ! -f $dst_dir_path/log.9.tar.gz ];then
for((i=1;i<=$(($dst_dir_path_file_num-1));i++))
do
if [ -f $dst_dir_path/log.$i.tar.gz ];then
continue
fi
mv $dst_dir_path/log.tar.gz $dst_dir_path/log.$i.tar.gz
break
done
fi
# filenum=$(ls -l | wc -l)
# if [ $filenum -eq 12 ];then
# rm -f `ls -tr | head -1`
# fi
i=0
filenum=0
for i in $(ls)
do
if [ -f $i ]
then
let filenum+=1
fi
if [ $filenum==10 ];then
rm `ls -tr $(find . -type f -name "log_*") | head -1`
break
fi
done
if [ -f $dst_dir_path/log.tar ];then
mv $dst_dir_path/log.tar $dst_dir_path/log_$(date "+%Y-%m-%d_%H:%M:%S")_bak.tar
fi
4.reload_fpga_uio_driver.sh
insmod与modprobe都是载入 kernel module,不过一般差别于modprobe能够处理module载入的相依问题。你要载入a module,但是a module要求系统先载入b module时,直接用insmod挂入通常都会出现错误讯息,不过modprobe倒是能够知道先载入b module后才载入a module,如此相依性就会满足。
#!/bin/bash
modprobe uio
cd /home
insmod ifc_uio.ko
echo 16 > /sys/bus/pci/devices/0000\:b1\:00.0/max_vfs
5.get_fpga_temp.sh
#!/bin/bash
echo "unload FPGA UIO driver"
echo 0 > /sys/bus/pci/devices/0000\:b1\:00.0/max_vfs
rmmod ifc_uio
rmmod uio
echo "get FPGA temperature"
cd /home/fpga_temperature_voltage/s10_rsu_over_pcie_ori
./install
cd ..
./fpga_temperature_voltage
./s10_rsu_over_pcie_ori/unload
6.ethernet_port.sh
#!/bin/bash
echo "**************************************Ethernet port test start*************************************"
modprobe uio
cd /home
insmod ifc_uio.ko
echo 16 > /sys/bus/pci/devices/0000\:b1\:00.0/max_vfs
for((i=1;i<=12;i++))
do
echo "******************************Do Port $i setup*******************************************************"
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen -P
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen -s
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen -c >/dev/null
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --chk -c >/dev/null
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --mux -c >/dev/null
sleep 1
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen --pkt --min 64 --max 64 --mode 256 --gap 1 -S
sleep 2
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen -s
done
while((1))
do
for((i=1;i<=12;i++))
do
echo "****************************Show port $i test log*******************************************"
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen -C
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --chk -C
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --mux -C
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --eth -p $i --gen -s
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --ver
sleep 3
done
done
7.ddr_test.sh
#!/bin/bash
echo "******************************* DDR stress start **********************************"
modprobe uio
cd /home
insmod ifc_uio.ko
echo 16 > /sys/bus/pci/devices/0000\:b1\:00.0/max_vfs
for((i=0;i<4;i++))
do
echo "*******************************Do DDR Channel $i setup******************************************"
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --ddr -n $i -c
sleep 1
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --ddr -n $i -1 0 -2 0 -3 0 -T 0 -S
sleep 2
done
while ((1))
do
for((i=0;i<4;i++))
do
echo "**************************** Show DDR Channel $i test log **************************"
./fpga_test /sys/bus/pci/devices/0000\:b1\:00.0/resource2 --ddr -n $i -C
sleep 2
done
done