loadrunner 场景设计-添加Unix、Linux Resources计数器

时间:2021-12-02 19:51:11

场景设计-添加UnixLinux Resources计数器

by:授客 QQ1033553122

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,添加

loadrunner 场景设计-添加Unix、Linux Resources计数器loadrunner 场景设计-添加Unix、Linux Resources计数器

5.右键已经添加的Unix Resource, 选择Add Measurements...

loadrunner 场景设计-添加Unix、Linux Resources计数器loadrunner 场景设计-添加Unix、Linux Resources计数器

6.弹出窗口中,点击Add,弹出Add
Machine中添加要监控系统((通常是压测目标服务器)的IP

loadrunner 场景设计-添加Unix、Linux Resources计数器loadrunner 场景设计-添加Unix、Linux Resources计数器

loadrunner 场景设计-添加Unix、Linux Resources计数器

loadrunner 场景设计-添加Unix、Linux Resources计数器

保存

结果提示错误消息:

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

loadrunner 场景设计-添加Unix、Linux Resources计数器

loadrunner 场景设计-添加Unix、Linux Resources计数器