使用Zabbix监控Apache

本文介绍如何使用Zabbix监控Apache服务状态。通过配置Apache的server-status模块,并借助zapache脚本及自定义Zabbix模板实现监控指标收集。适用于CentOS 6.5环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文对zabbix如何监控apache进行简单描述

 环境:

服务操作系统IP地址
Zabbix ServerCentOS 6.5192.168.153.181
Apache CentOS 6.5192.168.153.151

 

 192.168.153.151上已经安装了Zabbix Agent

  本文就是针对192.168.153.151 的apache服务的监控

 

 步骤:

  修改httpd配置文件

         

 vi /etc/httpd/conf/httpd.conf

 

   在配置文件最后添加以下内容:

ExtendedStatus On
<location /server-status>
   SetHandler server-status
   Order allow,deny
   Allow from localhost
</location>

 

    重启apache服务,浏览器输入http://ip/server-status ,确认配置生效

   

 

 

   下载zapache https://github.com/lorf/zapache

     

wget https://github.com/lorf/zapache/archive/master.zip

 

unzip master.zip

 

   

[root@localhost zapache-master]# ls
httpd-server-status.conf.sample  README.md  userparameter_zapache.conf.sample  
zapache  zapache-template-active.xml  zapache-template.xml

 

     httpd-server-status.conf.sample 是用于配置server-status的上个步骤已经配置过了

     userparameter_zapache.conf.sample 、zapache 关键的文件
     zapache-template-active.xml  zapache-template.xml模板

 

  将解压出来的几个重要文件放到相应目录

   

 cp userparameter_zapache.conf.sample  /usr/local/etc/zabbix_agentd.conf.d/

 

   

cd  /usr/local/etc/zabbix_agentd.conf.d/
mv userparameter_zapache.conf.sample userparameter_zapache.conf

 

    查看配置userparameter_zapache.conf内容

   

cat /usr/local/etc/zabbix_agentd.conf.d/userparameter_zapache.conf

 

    

# This is a sample zabbix_agentd config file.
# Put it to /etc/zabbix_agentd.conf.d or otherwise integrate into agent config.
# Edit to your needs.
#
UserParameter=zapache[*],/var/lib/zabbixsrv/externalscripts/zapache \$1

    可以看到应当把解压出来的zapache文件放到/var/lib/zabbixsrv/externalscripts/目录下,当然也可以修改这个目录位置,改为自定义的,我这里就用默认配置文件里的目录,因此,创建这个目录

    

mkdir -p /var/lib/zabbixsrv/externalscripts/

     将zapache文件拷贝至/var/lib/zabbixsrv/externalscripts/目录

     

 cp zapache /var/lib/zabbixsrv/externalscripts/

  

   增加可执行权限

chmod +x /var/lib/zabbixsrv/externalscripts/zapache

  

 修改zabbix agentd配置文件

 

vi /usr/local/etc/zabbix_agentd.conf

 

   使得zabbix agentd可以找到userparameter_zapache.conf配置文件

### Option: Include
#       You may include individual files or all files in a directory in the configuration file.
#       Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
# Mandatory: no
# Default:
# Include=

#Include=/usr/local/etc/zabbix_agentd.userparams.conf
Include=/usr/local/etc/zabbix_agentd.conf.d  #这把里的注释去掉

   

     

 导入模板

 

 



 

对要监控的主机的设置监控模板

 

 

现在就可以看监控到的数据了



 

 

 

 

 

 

 

参考:

http://www.infoscoop.org/blogjp/2014/09/01/zabbix-apache-monitoring/

https://www.zabbix.org/wiki/Docs/howto/apache_monitoring_script#Method_3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值