LoadRunner 作為業界標準的效能測試工具,若要監控 Linux 系統效能指標(CPU、記憶體、磁碟 I/O、網路等),需在被測 Linux 主機上部署 rstatd 服務,並配置 rsh/rexec 等遠端執行服務供 LoadRunner 控制器呼叫。本文提供從套件安裝、服務配置到驗證的完整步驟,適用於 RHEL/CentOS 等 RPM 系統。
LoadRunner Controller(Windows) → rsh/rexec → Linux 測機 → rpc.rstatd(RPC 程式號 100001) → 回傳效能數據。
核心依賴:rsh-server 提供遠端命令執行通道,rpc.rstatd 提供系統統計資訊 RPC 服務,xinetd 管理這些網路服務的啟動與存取控制。
需準備三個套件(版本號為範例,請依實際系統架構下載對應版本):
rsh-0.17-14.i386.rpm — 客戶端工具rsh-server-0.17-14.i386.rpm — 伺服端服務rpc.rstatd-4.0.1.tar.gz — 原始碼,需自行編譯安裝(無官方 RPM)下載來源建議: 官方鏡像站、EPEL 倉庫、或專案官網 https://sourceforge.net/projects/rstatd/。
rpm -q rsh # 查詢已安裝版本
rpm -e rsh-舊版本號 # 移除舊版 client
rpm -e rsh-server-舊版本號 # 移除舊版 server
rpm -ivh rsh-0.17-14.i386.rpm rsh-server-0.17-14.i386.rpm
# 解壓
gunzip rpc.rstatd-4.0.1.tar.gz
tar -xvf rpc.rstatd-4.0.1.tar
cd rpc.rstatd-4.0.1
# 編譯安裝(標準 GNU 流程)
./configure
make
make install
# 啟動驗證
rpc.rstatd
注意: make install 預設安裝至 /usr/sbin/rpc.rstatd,確保該路徑在 PATH 中或以絕對路徑啟動。
編輯 /etc/xinetd.conf,確認包含以下預設值:
defaults {
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
關鍵參數: instances 限制並發連線數,cps 限制每秒連線速率(25 次/秒,超過暫停 30 秒),防止 DoS。
service xinetd reload
或 /sbin/service xinetd restart。確保 xinetd 進程正常運行:
systemctl status xinetd
編輯 /etc/xinetd.d/ 目錄下三個服務檔案:
# 以 rsh 為例
vi /etc/xinetd.d/rsh
# 修改關鍵行
disable = no # 原為 yes,改為 no 啟用服務
# 或
# default: off # 取消註解並改為
default: on
對 rlogin、rexec 同樣操作。修改完成後再次 service xinetd reload。
rpc.rstatd &
建議加入開機自啟:
echo "rpc.rstatd" >> /etc/rc.local chmod +x /etc/rc.local
rpcinfo -p
輸出應包含以下程式號 100001(rstatd)的多版本註冊:
100001 5 udp 618 rstatd
100001 3 udp 618 rstatd
100001 2 udp 618 rstatd
100001 1 udp 618 rstatd
若出現上述內容,表示 RPC 服務已正常註冊至 portmapper,LoadRunner 即可透過 UDP 618 連接埠取得統計數據。
rsh/rexec/rlogin 傳輸明文密碼,且依賴 ~/.rhosts 或 /etc/hosts.equiv 進行弱認證,極不安全。iptables -A INPUT -s -p tcp --dport 512:514 -j ACCEPT ,其餘拒絕。/etc/hosts.allow 僅允許控制器 IP:rshd: 。service xinetd stop 或將 disable = yes。| 現象 | 可能原因 | 解決方向 |
|---|---|---|
rpcinfo -p 無 rstatd | rpc.rstatd 未啟動或 portmapper 未運行 | 檢查 service rpcbind status,手動啟動 rpc.rstatd |
| LoadRunner 連線逾時 | 防火牆阻擋 TCP 514 (rsh) / UDP 618 (rstatd) | 開放對應埠口或暫停防火牆測試 |
rsh 提示 "Permission denied" | ~/.rhosts 未設定或格式錯誤 | 在被測機 ~/.rhosts 加入 ,權限 600 |
| 編譯 rpc.rstatd 報錯 | 缺少 rpcgen 或 libtirpc 開發套件 | yum install libtirpc-devel rpcgen |
完成上述七個步驟後,Linux 主機即可被 LoadRunner 識別並監控。但鑑於 rsh/rstatd 協議古老且不安全,建議僅在隔離測試網路中短期使用。長期專案請規劃遷移至基於 SSH、HTTPS 或標準化協議(Prometheus/OpenMetrics)的現代監控架構。