X7ROOT File Manager
Current Path:
/usr/local/VMOptimizationTools_2.69.0
usr
/
local
/
VMOptimizationTools_2.69.0
/
📁
..
📄
LinuxUpdate.XML
(647 B)
📄
SangforVMSTool
(3.11 KB)
📄
SangforVMSTool.service
(194 B)
📄
action_common.sh
(13.34 KB)
📄
busybox_cmd_ln.sh
(2.24 KB)
📄
collect_test_data.sh
(1.16 KB)
📄
common_config.sh
(278 B)
📄
data_test_tool.sh
(16.62 KB)
📄
debian_vmconfig.sh
(13.48 KB)
📁
driver
📄
guest_system_config.sh
(1.82 KB)
📄
hostname_config
(1 B)
📄
ipv6_network_config
(94 B)
📄
log.sh
(1.36 KB)
📄
mod_test.sh
(3.69 KB)
📄
mod_test1.sh
(914 B)
📄
net_common.sh
(915 B)
📄
network_compat_flag
(0 B)
📄
network_config
(86 B)
📄
pwd_info_config
(1 B)
📄
redhat_vmconfig.sh
(17.93 KB)
📄
reset_duid_config
(21 B)
📄
sangfor_guest_datareport
(25.63 KB)
📄
sangfor_heartalive.sh
(2.37 KB)
📄
sangfor_module_update
(28.11 KB)
📄
sangfor_set_network.sh
(504 B)
📄
sangfor_sfping
(4.23 KB)
📄
sangfor_sshkey_gen
(1.29 KB)
📄
sangfor_update_ipc_callback
(5.29 KB)
📄
sangfor_vm_proxyd
(3.45 KB)
📄
sangfor_vm_proxyd_r
(4.4 KB)
📄
sangfor_vm_proxyd_w
(1.32 KB)
📄
sangfor_vmconfig
(3.55 KB)
📄
sangfor_vmconfig_common
(38.34 KB)
📄
sangfor_vmconfig_ipc_callback
(4.75 KB)
📄
sangfor_watchdog
(3.95 KB)
📄
sfping
(17.7 KB)
📄
sfping.pl
(8.57 KB)
📄
startall
(1.78 KB)
📄
stopall
(1.11 KB)
📄
suse_vmconfig.sh
(10.07 KB)
📁
tools_x64
📁
tools_x86
📄
uni_test.sh
(2.59 KB)
📄
update_common_func
(4.35 KB)
📄
update_common_header
(4.86 KB)
📄
update_config
(2.89 KB)
📄
update_install
(33.63 KB)
📄
update_network.flag
(1 B)
📄
virtio_nic_attr_set.sh
(2.42 KB)
📄
virtio_nic_compat.sh.old1610337499
(5.64 KB)
📄
vm_ip_recover.sh
(16.66 KB)
📄
vm_ipc.sh
(9.06 KB)
📄
vmconfig_common_func
(23.11 KB)
📄
vmconfig_common_header
(3.37 KB)
📄
vmconfig_config
(1.02 KB)
📄
vmtools-install.sh
(31.16 KB)
📄
watch_test.sh
(313 B)
📄
watchdog.sh
(1.39 KB)
📁
x64
📁
x86
Editing: sangfor_watchdog
#!/bin/bash # This document is for monitoring dog realize # The current directory declare g_shell_dir=`dirname "$0"` declare g_shell_name=`basename "$0"` . "${g_shell_dir}/watchdog.sh" . "${g_shell_dir}/log.sh" # The log file path. declare -r MY_LOG_FILE="/var/log/sangfor_watchdog.log" #The interval of restart service declare CHECK_INTERVAL=30 #Services are tested once every thirty seconds to hang declare RESTART_INTERVAL=60 #Within half an hour to reach the threshold of continuous service to restart,1800/30 declare MAX_RSS=20480 #The default is considered more than 20M of memory leaks # cloase all fd close_all_fd() { log "close all fd" for file in /proc/$$/fd/* do local fd=`basename ${file}` test ! -z "${fd}" && test -n "${fd}" || continue test ${fd} -gt 2 || continue test ${fd} -ne 255 || continue # Pay attention to close the handle to add eval, otherwise some environment will be in error test -e "${file}" && eval "exec ${fd}<&-" done exec 0<>"/dev/null" exec 1<>"/dev/null" exec 2<>"/dev/null" return 0 } # Close all files except outside the handle lock reset_fd() { local lockfd=`watchdog_lock_file_fd` log "reset fd expect lockfd=${lockfd}" for file in /proc/$$/fd/* do local fd=`basename ${file}` test ! -z "${fd}" && test -n "${fd}" || continue test ${fd} -gt 2 || continue test ${fd} -ne 255 || continue test ${fd} -ne ${lockfd} || continue # Pay attention to close the handle to add eval, otherwise some environment will be in error test -e "${file}" && eval "exec ${fd}<&-" done exec 0<>"/dev/null" exec 1<>"/dev/null" exec 2<>"/dev/null" return 0 } # reset signal reset_signal() { trap INT trap TERM trap USR1 trap USR2 return 0 } # fork child process fork_process() { local procname=$1 # If it is sdog, the need to retain the file lock if [ "${procname}" = "${g_shell_name}" ]; then reset_fd else close_all_fd fi # FIXME Gets the path from the configuration file "${g_shell_dir}/${procname}" & log "fork process ${procname}, my pid $$, fork $!" return 0 } # check monitor process check_once() { local use_busybox="" local tmpfile="${WATCHDOG_DIR__}/.ps.txt" ps -Ao pid,rss,command >"${tmpfile}" #busybox ps not support -o command if [ $? -ne 0 ];then local psAtmpfile="${WATCHDOG_DIR__}/.psA.txt" ps -A > "${psAtmpfile}" ps -Ao pid,rss > "${tmpfile}" sed -i 's/^[ ]*//g' "${tmpfile}" use_busybox=1 fi for file in ${WATCHDOG_DIR__}/* do local procname=`basename "${file}"` local service_rss=`grep "${procname}"$ "${tmpfile}" | awk '{print $2}'` if [ x"$use_busybox" == "x1" ];then local proc_pid=$(grep "${procname}"$ "${psAtmpfile}" | awk '{print $1}') if [ -z "$proc_pid" ] ;then service_rss="" else service_rss=$(grep "^${proc_pid}" "${tmpfile}" | awk '{print $2}') fi fi # FIXME: There will be error reading file? if [ ! "${service_rss}" ]; then log "${procname} is dead, restart it!" "${g_shell_dir}/${g_shell_name}" "${procname}" elif [ ${service_rss} -ge ${MAX_RSS} ]; then local max_count=`cat "${WATCHDOG_DIR__}/${procname}"` if [ ! "${max_count}" ]; then echo 0 > "${WATCHDOG_DIR__}/${procname}" else max_count=$((${max_count}+1)) if [ ${max_count} -eq ${RESTART_INTERVAL} ]; then #restart service log "the rss of ${procname} is greater than the max_rss, restart it!" "${g_shell_dir}/${g_shell_name}" "${procname}" max_count=0 fi echo ${max_count} > "${WATCHDOG_DIR__}/${procname}" fi else echo 0 > "${WATCHDOG_DIR__}/${procname}" fi done return 0 } # main main() { reset_signal && reset_fd || return 1 while true do check_once # Because the child processes inherit lock files, thus avoiding the use of sleep to long-term occupation of lock. local sleep_count=0 while [[ ${sleep_count} -lt ${CHECK_INTERVAL} ]] do sleep 1 sleep_count=$((${sleep_count}+1)) done done return 0 } set_log_filepath "${MY_LOG_FILE}" if [ $# -gt 0 ]; then fork_process $1 else main fi exit $?
Upload File
Create Folder