Linux Tips for Operator

下面这些多是本人日常开发运维会用到的tips,希望也能对读者有所帮助

netstat

比如要看8001端口被哪个进程使用可以通过命令netstat -a -p |grep $pid

top

top -p $pid

top -> x-> b -> <>

eE

ls /proc/$pid/fd/* |wc -l

让ssh走本地http代理

需要安装corkscrew这个工具

Host    jialinwu.com
Hostname        176.122.163.100
ProxyCommand /usr/local/bin/corkscrew 127.0.0.1 1087 %h %p
IdentityFile ~/.ssh/id_rsa
port 22
User    "root"

curl 测试websocket链接

curl --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Host: example.com:80" \
     --header "Origin: http://example.com:80" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     http://192.168.1.47:1443/ast

curl 测试链接耗时,DNS, connection establishment

curl -w "@parameters.txt" -o /dev/null -s -L "http://192.168.1.47:6004/ast"

parameters.txt 文件内容如下:

time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_redirect: %{time_redirect}\n
time_pretransfer: %{time_pretransfer}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n

2021-01-02