X7ROOT File Manager
Current Path:
/var/VMOptimizationToolsLinux
var
/
VMOptimizationToolsLinux
/
π
..
π
LinuxUpdate.XML
(645 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
(12.59 KB)
π
debian_vmconfig.sh
(10.74 KB)
π
guest_system_config.sh
(1.82 KB)
π
log.sh
(1.36 KB)
π
mod_test.sh
(3.69 KB)
π
mod_test1.sh
(914 B)
π
net_common.sh
(915 B)
π
redhat_vmconfig.sh
(11.14 KB)
π
sangfor_guest_datareport
(21.66 KB)
π
sangfor_heartalive.sh
(2.37 KB)
π
sangfor_module_update
(28.11 KB)
π
sangfor_set_network.sh
(504 B)
π
sangfor_sfping
(3.85 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
(2.4 KB)
π
sangfor_vmconfig_common
(27.99 KB)
π
sangfor_vmconfig_ipc_callback
(4.75 KB)
π
sangfor_watchdog
(3.95 KB)
π
sfping.c
(15.68 KB)
π
sfping.pl
(6.15 KB)
π
startall
(1.78 KB)
π
stopall
(1.11 KB)
π
suse_vmconfig.sh
(6.19 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
(28.84 KB)
π
virtio_nic_attr_set.sh
(2.42 KB)
π
virtio_nic_compat.sh
(5.28 KB)
π
vm_ip_recover.sh
(16.66 KB)
π
vm_ipc.sh
(9.06 KB)
π
vmconfig_common_func
(10.76 KB)
π
vmconfig_common_header
(3.37 KB)
π
vmconfig_config
(805 B)
π
vmtools-install.sh
(31.16 KB)
π
watch_test.sh
(313 B)
π
watchdog.sh
(1.39 KB)
π
x64
π
x86
Editing: sangfor_sfping
#!/bin/bash shell_dir=`dirname "${BASH_SOURCE[0]}"` proc_name=`basename "${BASH_SOURCE[0]}"` #report_log_file=`basename "${BASH_SOURCE[0]}"` . "${shell_dir}/vm_ipc.sh" . "${shell_dir}/watchdog.sh" declare SEND_INTERVAL=1 #the interval of send packet #ζΆζ―η±»ε declare -r MSGID_PING_SEND_LINUX=20001 #ειicmpε declare -r MSGID_PING_SEND_RES_LINUX=20002 #θΏεη»ζδΏ‘ζ― declare -r VMODID_PING=7 declare -r INST_ID=0 declare -r ENV_FAILED=245 LOG_NAME="/var/log/sfping.log" sf_debug() { echo "[D] $*" | tee -a $LOG_NAME; } sf_lerror() { echo "[E] $*" | tee -a $LOG_NAME; } # kill proccess # if the name of proccess is the same with the name of script,it won't kill itself # param $1: name of proccess(don't include path) # return if success then return 0 or return 1 kill_process() { if [ $# -ne 1 ]; then sf_lerror "parameter error!" return 1 fi local pid=$$ local procname=${1} #this is pipe,should't execute with awk,because the Shuffle local ps_list=`ps ax | grep "${procname}\>" | grep -v grep | grep -v "\<${pid}\>"` if [ ! -z "${ps_list}" ]; then echo "${ps_list}" | awk '{print "kill " $1 " 2>/dev/null"}' | sh fi return $? } ping_icmp_send_callback() { if [ $# -lt 3 ]; then sf_lerror "parameter error!" return 1 fi MSGBUF=`cat $3` #msg is save in file that $3 specified if [ ${MSGBUF} = "" ];then sf_lerror "recv empty msg" return 1 fi sf_debug "msgbuf = $MSGBUF" #msg format: "ctrl_cmd":"shutdown","vmid":"6476227890258" VERSION=`echo ${MSGBUF} | tr ',' '\n' | grep "version" | cut -d: -f 2 | sed s/[\"{}]//g` VMID=`echo ${MSGBUF} | tr ',' '\n' | grep "vmid" | cut -d: -f 2 | sed s/[\"{}]//g` HOSTID=`echo ${MSGBUF} | tr ',' '\n' | grep "hostid" | cut -d: -f 2 | sed s/[\"{}]//g` PKT_ID=`echo ${MSGBUF} | tr ',' '\n' | grep "pkt_id" | cut -d: -f 2 | sed s/[\"{}]//g` IFID=`echo ${MSGBUF} | tr ',' '\n' | grep "ifid" | cut -d: -f 2 | sed s/[\"{}]//g` DSTIP=`echo ${MSGBUF} | tr ',' '\n' | grep "dstip" | cut -d: -f 2 | sed s/[\"{}]//g` if [ x"$VERSION" = x"" -o x"$VMID" = x"" -o x"$HOSTID" = x"" -o x"$PKT_ID" = x"" -o x"$IFID" = x"" -o -z "$DSTIP" ]; then sf_lerror "VERSION = $VERSION,VMID = $VMID,HOSTID = $HOSTID,PKT_ID = $PKT_ID,IFID = $IFID,DSTIP = $DSTIP has illegal param!" return 1 fi sf_debug "VERSION = $VERSION,VMID = $VMID,HOSTID = $HOSTID,PKT_ID = $PKT_ID,IFID = $IFID,DSTIP = $DSTIP" #test ping δΈδΈ ping -c 1 -i 1 "$DSTIP" if [ -e "${shell_dir}/sfping" ]; then sf_debug "begin to ${shell_dir}/sfping" ${shell_dir}/sfping "$VERSION" "$VMID" "$HOSTID" "$PKT_ID" "$IFID" "$DSTIP" ret=$? else perl_path=`which perl` if [ -z "$perl_path" ]; then ret=${ENV_FAILED}; else echo "$perl_path" | grep "no perl" ret=$? if [ $ret -ne 0 ];then sf_debug "begin to ${shell_dir}/sfping.pl" ${shell_dir}/sfping.pl "$VERSION" "$VMID" "$HOSTID" "$PKT_ID" "$IFID" "$DSTIP" ret=$? if [ $ret != 0 ]; then sf_lerror "${shell_dir}/sfping.pl failed! ret = $ret" fi else ret=${ENV_FAILED} fi fi fi MSG_INFO_DATA="{\"version\":${VERSION},\"pkt_id\":${PKT_ID},\"hostid\":\"${HOSTID}\",\"vmid\":\"${VMID}\",\"ifid\":${IFID},\"res\":${ret}}" sf_debug "to local host = $MSG_INFO_DATA" vm_ipc_to_local_host ${VMODID_PING} ${INST_ID} ${MSGID_PING_SEND_RES_LINUX} "${MSG_INFO_DATA}" || return 1; return 0; } main() { #initialize the environment kill_process "${proc_name}" #join the monitor watchdog_reg_proccess "${proc_name}" #initialize vm_ipc_init ${VMODID_PING} ${INST_ID} if [ $? -ne 0 ]; then log "vm_ipc_init() failed! modid='${modid}' instid='${instid}'" return 1 fi sf_debug "vm_ipc_init success." #Registration message callback function vm_ipc_reg_callback ${MSGID_PING_SEND_LINUX} ping_icmp_send_callback sf_debug "start while send_data_to_host" while true do vm_ipc_event_loop_once watchdog_check_once sleep ${SEND_INTERVAL} done } main
Upload File
Create Folder