分类目录归档:未分类

普通用户也可重启nginx

1.修改nginx.conf为abc:root启动

  user  abc abc;  #以普通用户启,但实际上是master为root,worker进程是abc。
或 
  user abc root;

2.修改nginx

chown root nginx #nginx必须是root用户拥有者。
chmod a+s nginx  #把x属性改为s属性。
ll nginx
-rwsr-sr-x 1 root root 2030760 Mar  5 11:52 nginx

终端测试验证工具

https://misc.flogisoft.com/bash/home
终端配色:https://misc.flogisoft.com/bash/tip_colors_and_formatting
colors256.sh

#!/bin/bash
for fgbg in 38 48 ; do # Foreground / Background
    for color in {0..255} ; do # Colors
        # Display the color
        printf "\e[${fgbg};5;%sm  %3s  \e[0m" $color $color
        # Display 6 colors per lines
        if [ $((($color + 1) % 6)) == 4 ] ; then
            echo # New line
        fi
    done
    echo # New line
done
exit 0

colors_and_formatting.sh

#!/bin/bash
#Background
for clbg in {40..47} {100..107} 49 ; do
        #Foreground
        for clfg in {30..37} {90..97} 39 ; do
                #Formatting
                for attr in 0 1 2 4 5 7 ; do
                        #Print the result
                        echo -en "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m"
                done
                echo #Newline
        done
done
exit 0

——-
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
http://www.xfree86.org/current/ctlseqs.html
Linux环境下,主要都是泛VT102的终端,以下是vt102终端。
https://vt100.net/docs/vt102-ug/introduction.html
https://vt100.net/docs/vt102-ug/contents.html
微软的
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
VT100,VT101,
参考开源:https://konsole.kde.org/

headless vt100 emulator
https://github.com/JulienPalard/vt100-emulator
https://github.com/freanux/VTE

自动拉起服务脚本

crontab -e
*/1 * * * * sh /data/scripts/run-flow.sh start
#!/bin/sh

path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
mode=$1

logfile=/data/scripts/check.log
app_process=`ps -ef | grep "flowservice"| grep -v grep`
echo `date` >> $logfile
echo "ready to check...." >> $logfile
case "$mode" in
   'start')
        echo "$app_process" >> $logfile
        echo "it's ready to start op...."
        if test -n "$app_process"; then
                echo ""
                echo "$app_process"
                echo ""
        else
                cd $path_script   #进入脚本所在目录下,目的是使springboot的config目录生效。
                nohup /data/code/service.flow.wps.cn/flowservice --config=/data/code/service.flow.wps.cn/config/config-prod.toml > /data/code/service.flow.wps.cn/info.txt 2>&1 &
                echo "success to restart flowservice" >> $logfile
                cd $path_current

        fi

        echo 'success to start.'
        ;;
   'stop')
        echo "it's ready to check process..."
        if test -n "$app_process"; then
                echo "had find app process informaton"
                echo $app_process | awk '{print ($2)}' | xargs kill -9
        fi
        echo 'success to kill.'
        ;;
    *)
        basename=`basename "$0"`
        echo "Usage: $basename  {start|stop}  [ server options ]"
        exit 1
        ;;
esac
exit 1

终端开发文档参考

终端如VT100,VT50,VT220等终端,其相关的文档都汇聚在这个网站上。
https://vt100.net/
http://rtfm.etla.org/xterm/ctlseq.html重点推荐
http://man.he.net/man4/console_codes【Linux Console Codes】【Linux下的console文档,是vt102的子集】
Vt102是vt100家族的第二代指令,在原有vt100基础上增加了行插入行滚动的几个指令。

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"

解决WIN10显示文字模糊

主要原因是系统允许应的缩放比例生效,按如下修改可解决。
1.桌面右键->显示设置->高级缩放设置如下图:

2.在高级缩放设置中,开启“允许window尝试修复应用,使其不糊模”,及在自定义缩放比例上,填上100%的缩放显示。

etw的信息提取

https://docs.microsoft.com/en-us/windows-hardware/test/wpt/xperf-actions
xperf -tle –i myetw.etl -o providers.csv -a dumper -provider {CA80A0D7-6CA2-4F62-B22D-D0F88D79AE4B}


https://docs.microsoft.com/en-us/windows-hardware/test/weg/instrumenting-your-code-with-etw

Copy your component to the location that was specified in your manifest by the resourceFileName attribute:

xcopy /y MyProviderBinary.exe %temp%

Register the providers:

wevtutil um etwmanifest.man
wetvutil im etwmanifest.man

Verify that the provider is visible:

logman query providers

Your provider name/GUID will appear in the list.
1.Start tracing:
  xperf -start MySession -on MyEventProvider -f MySession.etl
  # In that command line, -start gives the event collection session a name, and -on tells ETW that you want to collect events from your provider in this session. (There can be multiple -on arguments.)
2.Execute your workload.
3.Stop tracing:
  xperf -stop MySession
@echo off
echo "clean session.."
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.."
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%
xperf -start -on Base
xperf -start app_session -on CA80A0D7-6CA2-4F62-B22D-D0F88D79AE4B

echo "请启动prometheus应用。"

timeout 100

xperf -stop app_session -d  app_tmp.etl
xperf -stop -d base_tmp.etl
xperf -merge base_tmp.etl app_tmp.etl prometheus_%now%.etl

xperf -tle -i abc_%now%.etl -o hardfaults_%now%.csv -a hardfault -file -bytes
xperf -tle -i abc_%now%.etl -o time_%now%.csv -a dumper -provider {CA80A0D7-6CA2-4F62-B22D-D0F88D79AE4B}
xperf -tle -i abc_%now%.etl -o pagefaults_%now%.csv -a dumper -provider {3D6FA8D3-FE05-11D0-9DDA-00C04FD7BA7C}
rem start wpa.exe abc_%now%.etl