loadrunner 监控windows和linux系统

监控windows

1、监视连接前的准备工作

1)进入被监视windows系统,开启以下二个服务Remote Procedure Call(RPC) 和Remote Registry Service (开始—)运行 中输入services.msc,开启对应服务即可)。

2)在被监视的WINDOWS机器上:右击我的电脑,选择管理->共享文件夹->共享 在这里面要有C$这个共享文件夹(要是没有自己手动加上)。

3)在安装LR的机器上,开始—》运行,输入 \\被监视机器IP\C$ 然后输入管理员帐号和密码,如果能看到被监视机器的C盘了,就说明你得到了那台机器的管理员权限,可以使用LR去连接了。(LR要连接WINDOWS机器进行监视要有管理员帐号和密码才行。)

问题:在执行步骤3)时,输入 \\被监视机器IP\C$,出现不能以administrator身份访问被监控系统(若采用这种方式用LR对其监控的话,会提示:“找不到网络路径”)的情况,现象就是用户名输入框是灰色的,并且默认用户是guest。

解决办法:这是安全策略的设置问题(管理工具 -> 本地安全策略 -> 安全选项 ->“网络访问:本地帐户的共享和安全模式”)。默认情况下,XP的访问方式是“仅来宾”的方式,如果你访问它,当然就固定为Guest来访问,而guest账户没有监控的权限,所以要把访问方式改为“经典”模式,这样就可以以administrator的身份登陆了。修改后,再次执行步骤3),输入管理员用户名和密码,就可以访问被监控机器C盘了。

若这样都不行的话(可能是其它问题引起的),那只好采取别的方法了。在服务器的机子上,通过windows自带的“性能日志和警报”下的“计数器日志”中新增加一个监控日志(管理工具—)性能—)性能日志和警报),配置好日志,也能监控服务器的cpu、memory、disk等计数器。当然,这种方法就不是用LR来监控了。

2、用LR监视windows的步骤

在controller 中,Windows Resources窗口中右击鼠标选择Add Measurements,添加被监控windows的IP地址,选择所属系统,然后选择需要监控的指标就可以开始监控了。

监控unix/linux

loadrunner是通过linux、unix系统的rstatd守护进程实现的,如果服务器上没有该进程,则不能获取相关数据

注释:有些linux系统在资源不足的情况下会自动停止rstatd的运行,表现为突然无法获取linux服务器的相关信息,此时需要在linux服务器上重新启动rstat进程即可。

 
1.    前期准备:
 
 
1,rstatd文件解压到要监控的机器上。
2,打开终端,定位到rstatd文件夹下:查看文件夹中的内容如下:
[root@localhost rpc.rstatd]# ls
aclocal.m4    COPYING     Makefile.am    README        rstat_proc.c rup.1
config.h.in   CVS         Makefile.in    rpc.rstatd.8 rstat.x       rup.c
configure     INSTALL     missing        rstatd.8      rsysinfo.1    stamp-h.in
configure.in install-sh mkinstalldirs rstat_main.c rsysinfo.c
 
 
 
2.    执行如下步骤:
 
 
2.1.                   执行:./configure 命令(确保已安装gcc编译器,yum install gcc)
 
 
[root@localhost rpc.rstatd]# ./configure
creating cache ./config.cache
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking for gawk... gawk
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for a BSD compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether make sets ${MAKE}... (cached) yes
checking how to run the C preprocessor... gcc -E
checking for sys/ioctl.h... yes
checking for syslog.h... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether gcc needs -traditional... no
checking for ANSI C header files... yes
checking return type of signal handlers... void
updating cache ./config.cache
creating ./config.status
kcreating Makefile
creating config.h
 
 
 
2.2.                   执行:make 命令。
 
 
[root@localhost rpc.rstatd]# make
rm -f rstat.h
rpcgen -h -o rstat.h rstat.x
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rup.c
rup.c: In function 'ointopoint_v5':
rup.c:256: warning: passing argument 6 of 'client->cl_ops->cl_call'?from incompatible pointer type
rup.c: In function 'ointopoint_v3'?
rup.c:292: warning: passing argument 6 of 'client->cl_ops->cl_call'?from incompatible pointer type
rup.c: In function 'main'?
rup.c:317: warning: return type of 'main'?is not 'int'?rm -f rstat_xdr.c
rpcgen -c -o rstat_xdr.c rstat.x
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rstat_xdr.c
rm -f rstat_clnt.c
rpcgen -l -o rstat_clnt.c rstat.x
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rstat_clnt.c
gcc -g -O2 -o rup rup.o rstat_xdr.o rstat_clnt.o 
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rsysinfo.c
rsysinfo.c: In function 'ointopoint_v3'?
rsysinfo.c:136: warning: passing argument 6 of 'client->cl_ops->cl_call'?from incompatible pointer type
rsysinfo.c: In function 'main'?
rsysinfo.c:160: warning: return type of 'main'?is not 'int'?gcc -g -O2 -o rsysinfo rsysinfo.o rstat_xdr.o rstat_clnt.o 
rm -f rstat_svc.c
rpcgen -m -o rstat_svc.c rstat.x
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rstat_svc.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rstat_proc.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c rstat_main.c
rstat_main.c: In function 'main'?
rstat_main.c:82: warning: return type of 'main'?is not 'int'?gcc -g -O2 -o rpc.rstatd rstat_svc.o rstat_xdr.o rstat_proc.o rstat_main.o 
这之后可以执行:make check检查一下。
 
 
2.3.                   执行:make install 命令。
 
 
[root@localhost rpc.rstatd]# make install
make[1]: Entering directory `/opt/rpc.rstatd'
/bin/sh ./mkinstalldirs /usr/local/bin
 /usr/bin/install -c rup /usr/local/bin/rup
 /usr/bin/install -c rsysinfo /usr/local/bin/rsysinfo
/bin/sh ./mkinstalldirs /usr/local/sbin
 /usr/bin/install -c rpc.rstatd /usr/local/sbin/rpc.rstatd
make[1]: Nothing to be done for `install-data-am'.
make[1]: Leaving directory `/opt/rpc.rstatd'
 
 
2.4.                   执行:./rpc.rstatd 命令。启动rpc服务。
 
 
注:无回显为成功。
 
[root@localhost rpc.rstatd]# ./rpc.rstatd
 
 
 
2.5.                   执行:rpcinfo –p 命令。检查rpc服务的状态.
 
 
[root@localhost rpc.rstatd]# rpcinfo -p
   program vers proto   port
    100000    2   tcp    111 portmapper
    100000    2   udp    111 portmapper
    100024    1   udp    797 status
    100024    1   tcp    800 status
    100001    5   udp    900 rstatd
    100001    3   udp    900 rstatd
    100001    2   udp    900 rstatd
    100001    1   udp    900 rstatd
[root@localhost rpc.rstatd]#
 
 
3.    可能会出现的错误:
 
1,若RPC服务没有成功启动。
2,若目标主机上开启了防火墙,阻挡了RPC服务。
在LR中添加时可能会出现如下错误:
Monitor name :UNIX Resources. Cannot initialize the monitoring on 10.1.200.65. 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: RPC Server <100001, 3, 17> is not registered on host '10.1.200.65'. (entry point: CFactory::Initialize).   [MsgId: MMSG-47190]
 
Monitor name :UNIX Resources. Internal rpc error (error code:2). Machine: 10.1.200.65. Hint: Check that RPC on this machine is up and running. Check that rstat daemon on this machine is up and running (use rpcinfo utility for this verification). Details: RPC: RPC call failed.
RPC-TCP: recv()/recvfrom() failed.
RPC-TCP: Timeout reached. (entry point: Factory::CollectData). [MsgId: MMSG-47197]

关闭防火墙:/etc/init.d/iptables stop

 
至此完毕。
原文地址:https://www.cnblogs.com/lu215225/p/2980796.html