libvirt 配置qemu coredump

 1 prlimit runtime set process coredump size
 2 
 3 prlimit -p pid --core
 4 
 5 prlimit -p pid --core=unlimited:unlimited
 6 
 7 /root/zone/bin/core.%e.%t
 8 
 9 kill -s SIGTRAP pid
10 
11 #https://man7.org/linux/man-pages/man2/getrlimit.2.html
12 
13 
14 echo "|/root/zone/bin/script/coredump.sh %p %t %e" > /proc/sys/kernel/core_pattern
15 
16 
17 /etc/libvirt/qemu.conf
18 
19 
20 #max_core = "unlimited"
21 #dump_guest_core = 1
22 
23 #coredump without guest memdump
24 sed -i "s/#max_core = \"unlimited\"/max_core = \"unlimited\"/g" /etc/libvirt/qemu.conf
25 
26 #coredump with guest memdump
27 sed -i "s/#dump_guest_core = 1/dump_guest_core = 1/g" /etc/libvirt/qemu.conf
28 
29 
30 
31 
32 zone16:
33 sed -i "s/#max_core = \"unlimited\"/max_core = \"unlimited\"/g" /etc/libvirt/qemu.conf
34 systemctl restart libvirtd
35 systemctl status libvirtd
36 
37 ROOT_PATH=/dev/shm/zone_20230313-10
38 echo "|${ROOT_PATH}/script/coredump.sh %p %t %e" > /proc/sys/kernel/core_pattern
39 
40 cp /dev/shm/zone_20230313-10/script/coredump.sh /dev/shm/zone_20230313-14/script/
41 echo "|/dev/shm/zone_20230313-14/script/coredump.sh %p %t %e" > /proc/sys/kernel/core_pattern
42 
43 
44 source /mnt/boot/jumper/zone_setup.conf
45 scp $opt coredump.sh root@$prefix.10:${ROOT_PATH}/script/
46 
47 
48 zone16:恢复
49 
50 sed -i "s/max_core = \"unlimited\"/#max_core = \"unlimited\"/g" /etc/libvirt/qemu.conf
51 systemctl restart libvirtd
52 systemctl status libvirtd
 1 #!/bin/bash
 2 current=${0}
 3 pid=${1}         #目标PID
 4 timesample=${2} #目标core时间
 5 comm=${3}        #目标comm
 6 
 7 
 8 
 9 current_pname=$(basename $current)
10 current_path=${current//\/script\/$current_pname/}
11 
12 # include zone config
13 source /dev/shm/system/setup.conf
14 source ${current_path}/user/zone${ZONE_ID}.conf
15 
16 # echo "coredump.sh $current, $current_pname, $current_path, ${MOUNT_DIR}" >> /root/zone/bin/test.log 
17 
18 hostname=$(hostname)
19 fs_mount_dir=${MOUNT_DIR}
20 RANDOM_NUMBER=${RANDOM}
21 dumpinfo_file=${fs_mount_dir}/hdd/core.${RANDOM_NUMBER}.info
22 
23 if [ "${comm}" != "qemu-kvm" ];then # these process are zone submodules
24     # core.%e.%t
25     dumpfile=${current_path}/core.${comm}.${timesample}.${pid}
26     cat > ${dumpfile}
27 else # qemu-kvm
28     dumpfile=${fs_mount_dir}/hdd/core.${RANDOM_NUMBER}
29     cat > ${dumpfile}
30     # 防止core名字过长
31     echo ${hostname}.${comm}.${timesample}.${pid}     > ${dumpinfo_file}
32     ls -al /proc/${pid}/cwd                         >>${dumpinfo_file}
33     cat /proc/${pid}/maps                             >>${dumpinfo_file}
34 fi
35 
36 logger "coredump.sh 严重错误,进程 coredump,dumpfile:$dumpfile" -p err
37 
38 # echo "coredump.sh 严重错误,进程coredump,dumpfile:$dumpfile" >> /root/zone/bin/test.log

 

posted @ 2023-03-14 15:51  maojun1998  阅读(154)  评论(0编辑  收藏  举报