PHP
window.parent.location='/kcgi-bin/publish/index.php';"; exit;}function log_write_file($user,$user_ip,$sel_ip="none",$pack_right="none"){ try{ $timenow=date("Y-m-d H:i:s",time()); $daynow=date("Y-m-d",time()); $fhandle=fopen("logs/operation_pack_right.log.$daynow","a"); fwrite($fhandle,$timenow."|".$user."|".$user_ip."|".$sel_ip."|".$pack_right."\n"); fflush($fhandle); fclose($fhandle); } catch(exception $e){ echo $e; } return 0;}?>打包权重
2. SHELL
#!/bin/bashUSER_NO=$(id |grep -P "richmail|root" )if [[ -z $USER_NO ]] ; then echo " run must in richmail user" exit 1 fiTIME=$(date "+%Y%m%d%H%M%S")DATE=$(date "+%Y-%m-%d")export PATH=/bin:/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin:/usr/local/bin/:$PATHexport LD_LIBRARY_PATH=:/home/richmail/oracle_client/lib:/home/richmail/lib:/home/richmail/oracle_client/lib:/home/richmail/libexport RICHMAIL_HOME=/home/richmailHOST_CONF=/home/richmail/newconf/hosts.confHOST_BAK_dir=/home/scripts/hostconf_bak/LOGFILE=${HOST_BAK_dir}/logs/ms_change_packlog.${DATE}#HOST_CONF=/tmp/hosts.conf#HOST_BAK_dir=/tmp/hostconf_bak/#LOGFILE=${HOST_BAK_dir}/logs/change_packlog.${DATE}if [ $# != 2 ];then echo "USAGE:$0 The two parameter" echo "USAGE:$0 incoming parameters digit 1 or 3 or 5 or 7:" echo "USAGE:$0 all_9qi|[192.168.220.1-38] 3" exit 1;fiIP_MS=$1PACK_R=$2if [[ "$IP_MS" == "check" && "$PACK_R" == "query" ]];then sed -rn '/^ip=192.168.220.1/,/cloud-ms-38\/logreport/p' $HOST_CONF|awk '{if($0~/^ip=192.168.220./){if(int(substr($0,16))<=38){printf "%s ",$0;flag=1}};if($1~/pack_thread_num/ && flag==1){printf "%d\n",$3}}' echo "end of query" exit 0fi if [[ ! -d ${HOST_BAK_dir} ]] ;then mkdir -p ${HOST_BAK_dir} chown richmail.richmail ${HOST_BAK_dir}fi if [[ ! -d ${HOST_BAK_dir}/logs ]] ;then mkdir -p ${HOST_BAK_dir}/logs chown richmail.richmail ${HOST_BAK_dir}/logsfi cp -avpR $HOST_CONF ${HOST_BAK_dir}/hosts.conf.${TIME} >> $LOGFILEchown richmail.richmail $LOGFILEif [[ $? -ne 0 ]] ;then echo "$TIME cp error, script quit ! ">> $LOGFILE exit 1 fi echo "$TIME pack_thread change $IP_MS $PACK_R" >> $LOGFILEif [[ "$IP_MS" == "all" ]] ;then # sed -ri '/^ip=192.168.220.1/,${/\bpack_thread_num\b/{s/ =.*/ = '"$PACK_R"'/g}}' $HOST_CONF sed -ri '/^ip=192.168.220.1/,/cloud-ms-38\/logreport/{/\bpack_thread_num\b/{s/ =.*/ = '"$PACK_R"'/g}}' $HOST_CONF diff $HOST_CONF ${HOST_BAK_dir}/hosts.conf.${TIME} # sed -rn '/^ip=192.168.220.1/,${/\bpack_thread_num\b/{s/ =.*/ = '"$PACK_R"'/gp}}' $HOST_CONF >> $LOGFILE echo 5 | /home/richmail/bin/confutil;echo 0 for((i=1;i<=38;i++)); do echo y | /home/richmail/bin/richmail --sys-restart 192.168.220.${i} mssvr >> /home/scripts/logs/ms_change_pack.log.${DATE} 2>&1 echo y | /home/richmail/bin/richmail --sys-restart 192.168.220.${i} mssvr echo "all: 192.168.220.${i} restart" done diff $HOST_CONF ${HOST_BAK_dir}/hosts.conf.${TIME} >> $LOGFILE #sed -rn '/^ip=192.168.220.1/,${/\bpack_thread_num\b/{s/ =.*/ = '"$PACK_R"'/gp}}' $HOST_CONF >> $LOGFILE exit 0 else if [[ -z $(echo $IP_MS|grep -P "^192\.168\.220\.([1-9]|1[0-9]|2[0-9]|3[0-8])$") ]];then echo "parameter not right all_9qi|[192.168.220.1-38]"; exit 1; fi #IP_MS_PLUS="192.168.220."$((${IP_MS##*.}+1)) IP_MS_PLUS=$((${IP_MS##*.}+1)) echo "${IP_MS}iiiiii${IP_MS_PLUS}" sed -ri '/^ip=\b'"${IP_MS}"'\b$/,/^ip=192.168.220.\b'${IP_MS_PLUS}'\b$/{/\bpack_thread_num\b/{s/ =.*/ = '"$PACK_R"'/g}}' $HOST_CONF diff $HOST_CONF ${HOST_BAK_dir}/hosts.conf.${TIME} echo 5 | /home/richmail/bin/confutil;echo 0 echo y | /home/richmail/bin/richmail --sys-restart $IP_MS mssvr echo "restart ${IP_MS}" diff $HOST_CONF ${HOST_BAK_dir}/hosts.conf.${TIME} >> $LOGFILE exit 0 fi