sar+awk+curl 的幾個用法

如果要查詢 CPU (User Usage) 大於 10 的可以這樣查
#  sar -f /var/log/sa/sa02 |awk '$4>10 {print $1,$2,": "$4,$6,$7,$9}'

sar_awk_study-01

有時需要去算訪問或監控特定網站的回應是否正常或時間

先建立一個 text 然後讓 curl 在調用時將相關的參數取回

[jerryw@nuc5 ~]$ cat curl-format.txt 
    time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
   time_pretransfer:  %{time_pretransfer}\n
      time_redirect:  %{time_redirect}\n
 time_starttransfer:  %{time_starttransfer}\n
                    ----------\n
         time_total:  %{time_total}\n

[jerryw@nuc5 ~]$ curl -w '@curl-format.txt' -o /dev/null -s "http://bd-api.xxx.com:80/api/v1/dmp/tvlog"
    time_namelookup:  0.125
       time_connect:  0.141
    time_appconnect:  0.000
   time_pretransfer:  0.141
      time_redirect:  0.000
 time_starttransfer:  0.512
                    ----------
         time_total:  0.512
[jerryw@nuc5 ~]$ 

curl_check_response_time

Author: jerryw1974

learning and focus on computer science, cloud infrastructure, virtualization and information security, technical, networking,platform system and cyber-security related topic.