承接 building5/apache-exporter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

building5/apache-exporter

Composer 安装命令:

composer require building5/apache-exporter

包简介

A library for exporting Apache status for Prometheus

README 文档

README

PHP port of apache_exporter. Slightly more convenient for PHP apps, since it does not require running the additional exporter process.

Installation

$ composer require building5/apache-exporter

Usage

Be sure to have the Apache server-status page enabled and configured.

Enable the status module using a2enmod status. It probably already has a status.conf configured in /etc/apache2/mods-enabled, but if not, you'll need that, too

<IfModule mod_status.c>
	<Location /server-status>
		SetHandler server-status
		Require local
	</Location>
	ExtendedStatus On

	<IfModule mod_proxy.c>
		# Show Proxy LoadBalancer status in mod_status
		ProxyStatus On
	</IfModule>
</IfModule>

You can test the status page by running curl http://localhost/server-status?auto on the web server to see if it's service the status page.

Simple usage

In your PHP application, or in whatever webroot you choose, create a metrics.php script that calls ApacheExporter\Exporter::simple(). The use of .htaccess to restrict access, add passwords, etc. is left as an exercise.

<?php
ApacheExporter\Exporter::simple();

Non-simple usage

If you have other stats you'd like to report, you can use the ApacheExporter\Exporter::export() method to export stats to the registry of your own choosing.

The use of APC or Redis storage is not recommended. The counter fields like accesses, kilobytes and uptime will accumulate wildly if you do.

See prometheus_client_php#68.

<?php
use ApacheExporter\Exporter;
use Prometheus\CollectorRegistry;
use Prometheus\RenderTextFormat;
use Prometheus\Storage\InMemory;

$registry = new CollectorRegistry(new InMemory());
$renderer = new RenderTextFormat();

Exporter::export($registry);

// register other stats you want here

header('Content-type: ' . RenderTextFormat::MIME_TYPE);
echo $renderer->render($registry->getMetricFamilySamples());

License

apache-exporter-php is licensed under the MIT license.

统计信息

  • 总下载量: 1.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固