loadrunner 场景设计-添加Unix、Linux Resources计数器
场景设计-添加Unix、Linux Resources计数器
by:授客 QQ:1033553122
A. 目的
监控要测试的Unix、Linux服务器的资源使用情况
Linux CentOS为例(Linux、Unix虽说大同小异,但是具体落实到配置等实际执行还是有差别的,以下仅供参考
注:关于Unix的配置,可以参见官方文档“How to Set up the UNIX Monitoring Environment”
B. 步骤
1、确认服务器是否配置并开启了rstatd守护进程
如果已经配置rstatd守护进程,当服务器收到rstatd请求时,inetd进程会自动激活rstatd进程
可以利用下文的方法在不进行配置的情况下,添加Unix Rescources监视器,查看是否返回相关数据,Scenario status返回错误则说明服务器未配置rstatd
2、安装rpc.rstatd
配置本第yum源(略)
[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# yum grouplist | grep rusers
[root@localhost ~]# yum list | grep rusers
rusers.x86_64 0.17-59.el6 centos
rusers-server.x86_64 0.17-59.el6 centos
[root@localhost ~]# yum install rusers-server
……
3.启动rstatd进程
[root@localhost ~]# /etc/init.d/rstatd start
Starting rstat services: [ OK ]
[root@localhost ~]# service rstatd status
rpc.rstatd dead but pid file exists
说明rstartd启动后并不能保持运行状态
[root@localhost ~]# rpcinfo -p localhost
rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused
原因分析:如下,未启动portmap服务/很多linux发行版已经用rpcbind代替portmap服务了
[root@localhost ~]# service rpcbind status
rpcbind is stopped
[root@localhost ~]# service rpcbind start
Starting rpcbind: [ OK ]
[root@localhost ~]# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
说明:
rpcinfo -p ,如果是远程连接必须指定IP地址,
比如# rpcinfo -p 172.25.75.14
4、添加视图,方法双击、拖动左侧的Unix Rescources到右边图形区,或右键右侧已有视图,Open a New Graph,找到Unix Rescource,添加
5.右键已经添加的Unix Resource, 选择Add Measurements...
6.弹出窗口中,点击Add,弹出Add Machine中添加要监控系统((通常是压测目标服务器)的IP
保存
结果提示错误消息:
Monitor name :UNIX Resources. Cannot initialize the monitoring on 172.25.75.14. Error while creating the RPC client. Ensure that the machine can be connected and that it runs the rstat daemon (use rpcinfo utility for this verification). Detailed error: RPC: Failed to create RPC client.
RPC-TCP: Failed to establish RPC server address.
RPC-TCP: Failed to communicate with the portmapper on host '172.25.75.14'.
RPC: RPC call failed.
RPC-TCP: recv()/recvfrom() failed.
RPC-TCP: Timeout reached. (entry point: CFactory::Initialize). [MsgId: MMSG-47190]
解决方法
1)安装xinetd服务
[root@localhost ~]# yum list | grep xinetd
xinetd.x86_64 2:2.3.14-29.el6 centos
[root@localhost ~]# yum install inetd
……
[root@localhost ~]# service xinetd status
xinetd is stopped
[root@localhost ~]# service xinetd start
Starting xinetd: [ OK ]
2)关闭防火墙
[root@localhost ~]# service iptables stop
3)重启服务
[root@localhost ~]# /etc/init.d/xinetd restart #service xinetd restart应该也可以
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@localhost ~]# service rstatd restart
Stopping rstat services: [FAILED]
Starting rstat services: [ OK ]
[root@localhost ~]# service rstatd restart
Stopping rstat services: [ OK ]
Starting rstat services: [ OK ]
[root@localhost ~]# service rstatd restart
说明:具体是否一定要按这个顺序重启服务就不清楚了,测试中,开放防火墙tcp\udp 111端口,重启过xinetd服务后添加再重新Unix rescource发现还是不行,接着,关闭防火墙->重启xinetd->重启rstatd服务,再次添加就可以了,这里根据上述执行情况,估计是之前启动rstatd后“rpc.rstatd dead but pid file exists”造成的(注意:后面测试发现,一开启防火墙就没数据了……
4)重复上述的5-6操作步骤,OK
作者:授客
微信/QQ:1033553122
全国软件测试QQ交流群:7156436
Git地址:https://gitee.com/ishouke
友情提示:限于时间仓促,文中可能存在错误,欢迎指正、评论!
作者五行缺钱,如果觉得文章对您有帮助,请扫描下边的二维码打赏作者,金额随意,您的支持将是我继续创作的源动力,打赏后如有任何疑问,请联系我!!!
微信打赏
支付宝打赏 全国软件测试交流QQ群
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库