Apache 插件

Apache 是各种操作系统广泛使用的网络服务器。 如需了解详情,请访问 http://httpd.apache.org/

此功能仅适用于在 Linux 上运行的代理。不适用于 Windows。

《发现》杂志

即使未配置 Apache 插件,Cloud Monitoring 也可通过以下方式发现在 Cloud Platform 项目中运行的 Apache 服务:

  • 搜索实例名称中是否包括 apache

  • 检查是否通过防火墙规则开放了 80443 端口

如需查看 Apache 的指标,请执行以下操作:

  1. 在 Google Cloud 控制台的导航面板中,选择 Monitoring,然后选择  信息中心

    前往信息中心

  2. 从列表中选择 Apache HTTP Server 信息中心。

配置 Monitoring 以监控 Apache

安装 Monitoring 代理后,请按照以下说明在您的实例上配置 Apache 插件。

前提条件

Apache 插件要求您在 Apache 中启用 mod_status 插件。很多情况下,安装 Apache 时会默认启用此插件。要查看您的虚拟机实例上是否启用了该插件,请运行以下请求:

curl http://local-stackdriver-agent.stackdriver.com:80/server-status?auto

如果已启用该插件,则输出将包含类似于以下内容的行:

 Total Accesses: 2
 Total kBytes: 1
 BusyWorkers: 1
 IdleWorkers: 4

如果您看到的是 404 Not Found 网页,则表明 mod_status 未启用。

以下是启用 mod_status 插件的几个选项:

  • 下载 status.conf 并将其放在虚拟机实例上的 Apache 配置目录中,通常位于 /etc/httpd/conf.d//etc/apache2/conf.d 中。如需详细了解如何启用 mod_status 插件,请参阅 Apache 2.4Apache 2.2 文档:

    (cd /etc/httpd/conf.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/httpd/conf.d/status.conf)
    
  • status.conf 的内容附加到主 Apache 配置文件(通常位于虚拟机实例上的 /etc/httpd/conf/httpd.conf/etc/apache2/apache2.conf)。

通过运行以下命令重新加载 Apache 配置:

  • 对于 Debian,Ubuntu 和 SLES:

    sudo a2enmod mod_status
    sudo a2enmod mod_access_compat
    sudo service apache2 reload
    
  • 其他 Linux 发行版:

    sudo service httpd reload
    

启用 Apache 监控插件

要启用 Apache 监控插件,请完成以下步骤:

  1. 在虚拟机实例上,下载 apache.conf 并将其放在 /etc/stackdriver/collectd.d/ 目录中:

    (cd /etc/stackdriver/collectd.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/apache.conf)
    

    如果您未以 root 身份使用 Google Cloud Observability 提供的默认或 Google Cloud Observability 提供的 Apache mod_status 配置,请按照文件顶部的说明修改 apache.conf

  2. 重新启动监控代理:

    sudo service stackdriver-agent restart
    

如需详细了解 collectd apache 插件,请参阅插件:Apache

监控的内容

Apache 插件监控的指标的完整列表位于代理指标:apache