文章插圖

文章插圖
背景:
最近貨運倉庫訪問服務器有超時的情況 。
需求:
需要抓到客戶端訪問請求的具體id和其耗時 。
解決:
1、使用倉庫服務器中的一臺虛機作為代理,讓操作客戶端通過代理訪問服務端,通過日志記錄具體的請求信息和響應耗時 。
在代理服務器上安裝squid
yum -y install squidcat >> /etc/squid/squid.conf << EOFlogformat combined%tl %6tr %>a "%rm %ru %rp HTTP/%rv" %>Hs %<st%Ss:%Sh/%<aaccess_log /var/log/squid/access.log combinedEOFsystemctl enable squid --now具體的logformat釋義如下:在客戶端pc上設置代理服務器:
ts Seconds since epoch
tu subsecond time (milliseconds)
tr Response time (milliseconds)
>a Client source IP address
ui User name from ident
un A user name. Expands to the first available name
from the following list of information sources:
– authenticated user name, like %ul
– user name supplied by an external ACL, like %ue
– SSL client name, like %us
– ident user name, like %ui
tl Local time. Optional strftime format argument
default %d/%b/%Y:%H:%M:%S %z
[http::]rm Request method (GET/POST etc)
[http::]ru Request URL from client (historic, filtered for logging)
rp Request URL path excluding hostname
[http::]rv Request protocol version
[http::]>Hs HTTP status code sent to the client
[http::]<st Total size of reply sent to client (after adaptation)
[http::]>h Original received request header.
Usually differs from the request header sent by
Squid, although most fields are often preserved.
Accepts optional header field name/value filter
argument using name[:[separator]element] format.
Ss Squid request status (TCP_MISS etc)
Sh Squid hierarchy status (DEFAULT_PARENT etc)
l 直接搜索“代理”,點擊“代理服務器設置” 。
在服務器上/var/log/squid/access.log的輸出日志如下,
【什么叫用代理訪問 用代理訪問】能通過各種維度分析請求的數據,比如分析url請求耗時的統計排序,請求耗時分布等,非常有助于分析系統問題!
- 電腦顯示其他用戶登錄到這臺計算機怎么關閉 為什么電腦顯示其他用戶登錄到這臺計算機
- 活佛有什么特異功能 有沒有什么特異功能
- 圣誕節送什么禮物給女孩子 圣誕節送女孩什么禮物比力好撩妹大全
- 男主角叫羅甲成是什么電視劇
- 梁博女友姜薪資料 兩人為什么會分手
- 小滿節氣吃什么 祛濕效果好就吃這個
- 小滿吃什么 7款養生湯過好節氣
- 小滿節氣習俗 三鮮是什么
- 網易郵箱注冊不了是什么原因 網易郵箱注冊一直在處理中
- 小滿節氣養生 小滿節氣是什么時候
