LR监控Apache资源

前提本文使用的是lampp环境下自带的Apache服务

步骤1、修改Apache中Httpd.conf文件,添加如下代码;文件位置为:/opt/lampp/etc/httpd.conf,如下图:

<Location /server-status>
    SetHandler server-status
    Order deny,allow
#    Deny from all
    Allow from .localhost
</Location>

注意:以上代码在有的httpd.conf文件中都有,只要取消注释就好了

在该代码的后边添加ExtendedStatus--如果没有,则添加,并且设置状态为on

ExtendedStatus On

步骤2、取消注释

在配置文件中取消该条语句的注释,lampp下默认为被注销

LoadModule status_module modules/mod_status.so

步骤3、重启Apache服务

步骤4、验证是否成功

输入下面的地址进行监控数据(192.168.0.108为本机IP)

http://192.168.0.108/server-status/?auto

发现出现如下错误信息,见图:

解决办法:

1、 编辑vim /opt/lampp/etc/extra/httpd-xampp.conf 该文件将该文件下的Require local  注释掉。如下图:

 

2、 重启lampp,/opt/lampp/lampp restart

3、 在浏览器输入http://localhost/server-status/?auto,验证是否成,如果出现如下图所示表示配置成功

步骤5、 LR配置说明

切换到LoadRunner的Controller中在Web Server Resource Graphs下配置监控目标,将鼠标放到Apache视图  右击选择 AddMeasurements,点击add,输入服务器IP地址和服务器操作系统。如下图:

运行后的效果图如下所示:

运行后发下有错误提示内容如下:

收到如下消息Monitor name :Apache. Parsing error, cannot find token: CPULoad. Measurement: CPULoad|192.168.0.108. Hints: 1) Such a measurement does not exist, or the html page may be different from the supported one. 2) Try to replace the Apache.cfg with appropriate Apache_<version>.cfg file in <Installation>datmonitors and rerun the application (entry point: CApacheMeasurement::NewData).    [MsgId: MMSG-47479]

错误分析:

这是由于要监视Apache的版本提供的计数器与LoadRunner默认的计数器不一致导致的。

解决办法:

建议先关闭Controller,打开C:Program Files (x86)HPLoadRunnerdatmonitors下的apache.cfg文件(其它文件名类似Apache_<version>.cfg的是Apache监视配置的备份,只有apache.cfg是生效的):

1、  修改Counter0=IdleServers为Counter0=IdleWorkers,同时修改注释信息Label0=#Idle Servers (Apache)为Label0=#Idle Workers (Apache),描述信息也建议修改;

2、 修改Counter4=BusyServers为Counter4=BusyWorkers,同时修改注释信息Label4=#Busy Servers (Apache)为Label4=#Busy Workers (Apache) ,描述信息也建议修改。

3、然后保存并关闭该文件,重新打开Controller并添加计数器,这样监视就正常了。

运行结果如果:

其他的问题:

解决办法:

修改配置文件httpd.conf,对新 添加的内容进行修改,修改后如下:

<location /c-server-status>
         SetHandler server-status
         Order Deny,Allow
         Deny from nothing
         Allow from all
</location>

修改完成重启Apache服务,OK

****************************************************************************************

参考文档:

http://blog.csdn.net/jsship/article/details/43770311

http://blog.csdn.net/vikesgao/article/details/53693547

http://blog.csdn.net/wyingquan/article/details/538850

原文地址:https://www.cnblogs.com/beginner-boy/p/7748375.html