分类目录归档:bat批处理

centos7.4的网络内核优化参数

net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.ip_local_port_range = 1024 65535
 
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
net.ipv4.conf.eth1.arp_announce = 2
 
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.core.somaxconn = 20480
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

sed提取json中有用字符串

 
mytest='"summary":{"day":{"burstTotal":0,"dropTotal":135764,"flowTotal":69449},"input":{"spanCount":900,"spanInterval":10},"spanNow":{"burstTotal":0,"dropTotal":1,"flowTotal":4,"now":1548691410},"spans"'
echo $mytest| sed 's/\(.*\)"day":{"burstTotal":\([[:alnum:]]*\),"dropTotal":\([[:alnum:]]*\),"flowTotal":\([[:alnum:]]*\).*/\4/' && echo ":flow121"

ssh指令定制及自动补全

1.利用Git的git-bash来做ssh的交互终端
不再使用git-bash进行交互了,统一使用msys2工具包进行管理。它可以实现linux的子系统。
注:参考这文章http://www.kxtry.com/archives/2334
2.在git-bash终端中执行【vim .bashrc】,添加以下指令

complete -W "$(echo $(grep '^Host ' F:/tools/myssh/config  | sort -u | sed 's/^Host //'))" remote
complete -W "$(echo $(grep '^Host ' F:/tools/myssh/config  | sort -u | sed 's/^Host //'))" xscp

3.编辑ssh的config文件

Host logkaf67
    HostName 10.0.0.67
    Port 22
    User heguowen
    IdentityFile c:\tools\ssh\id_rsa
    ProxyJump jumpServer   #since ssh 7.3 supports.
    #ProxyCommand ssh abc@10.2.16.210 nc %h %p

4.编辑remote脚本

#!/bin/sh
 
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
cfg=$path_script/config
 
if [ $# -lt 0 ]; then
   awk '{if($1 == "Host"){print $2}}' $cfg
else
   ssh -F $cfg $*
fi

5.编辑xscp脚本

#!/bin/sh
 
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
cfg=$path_script/config
if [ $# -lt 1 ]; then
   awk '{if($1 == "Host"){print $2}}' $cfg
else
   scp -F $cfg $*
fi

Xperf与ETW脚本

@echo off
pushd %~dp0
set now=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set now=%now: =0%
echo %now%
set path_current=%~dp0
set path=%path%;%path_current%;%path_current%\wpt
 
set path_result=%path_current%\result
if not exist %path_result% (md "%path_result%")
 
set path_backup=%path_result%\backup
if not exist %path_backup% (md "%path_backup%")
set path_word=%path_result%\wps
if not exist %path_word% (md "%path_word%")
set path_et=%path_result%\et
if not exist %path_et% (md "%path_et%")
set path_ppt=%path_result%\_ppt
if not exist %path__ppt% (md "%path__ppt%")
 
set path_word_result=%path_result%\preread_word.txt
set path_ppt_result=%path_result%\preread_ppt.txt
set path_et_result=%path_result%\preread_et.txt
 
set path_test=%~1
if not exist %path_test%\wpstest.exe (
    echo "the path is wrong......"
    echo "can not find the wpstest.exe by that path."
    goto :exit
)
set softnode=SOFTWARE
IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" set softnode=SOFTWARE\WOW6432Node
reg query "HKLM\%softnode%\kxtry\test\6.0\Common\res">nul 2>nul && call :registry_clear
 
if not exist %path_word_result% (
    echo "ready to do wps preread info."
    pushd %path_word%
    call :dokswpt /kxtry /wps /runactions="sleep,10|closeapp" %path_current%/1.docx
    popd
    copy /Y %path_word%\prereaddata_%now%.txt %path_word_result% > nul 2>nul
) else if not exist %path_ppt_result% (
    echo "ready to do _ppt preread info."
    pushd %path__ppt%
    call :dokswpt /kxtry /_ppt /runactions="sleep,10|closeapp"  %path_current%/1.pptx
    popd
    copy /Y %path__ppt%\prereaddata_%now%.txt %path__ppt_result% > nul 2>nul
) else if not exist %path_et_result% (
    echo "ready to do et preread info."
    pushd %path_et%
    call :dokswpt /kxtry /et /runactions="sleep,10|closeapp"  %path_current%/1.xlsx
    popd
    copy /Y %path_et%\prereaddata_%now%.txt %path_et_result% > nul 2>nul
) else (
    echo "all job was finished."
)
 
echo "finish all..."
goto :exit
 
rem -------------
:registry_clear
echo "remove the preRead's infomation from registry."
reg export "HKEY_LOCAL_MACHINE\%softnode%\kxtry\test\6.0\Common\Res" %path_backup%\backup_%now%.reg /y
reg delete "HKEY_LOCAL_MACHINE\%softnode%\kxtry\test\6.0\Common\Res">nul 2>nul /f
reg delete "HKEY_CURRENT_USER\Software\kxtry\test\6.0\Common\Res" >nul 2>nul /f
goto :exit
 
 
rem --------
:dokswpt
xperf -stop app_session -d app_tmp.etl
xperf -stop -d base_tmp.etl
if exist app_tmp.etl (del app_tmp.etl)
if exist base_tmp.etl (del base_tmp.etl)
 
echo "open session.."
xperf -start -on Base
xperf -start app_session -on CA80A0D7-6CA2-4F62-B22D-D0F88D79AE4B
echo "%path_test%\wpstest.exe" %*
call "%path_test%\wpstest.exe" %*
 
xperf -stop app_session -d  app_tmp.etl
xperf -stop -d base_tmp.etl
xperf -merge base_tmp.etl app_tmp.etl kxtry_%now%.etl
 
xperf -tle -i kxtry_%now%.etl -o hardfaults_%now%.csv -a hardfault -file -bytes
xperf -tle -i kxtry_%now%.etl -o time_%now%.csv -a dumper -provider {CA80A0D7-6CA2-4F62-B22D-D0F88D79AE4B}
xperf -tle -i kxtry_%now%.etl -o pagefaults_%now%.csv -a dumper -provider {3D6FA8D3-FE05-11D0-9DDA-00C04FD7BA7C}
hardpage.py wpstest time_%now%.csv pagefaults_%now%.csv _%now%
goto :exit
 
rem ---------------
:exit
echo "exit now..."
popd