承接 zarplata/zabbix-sender 相关项目开发

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

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

zarplata/zabbix-sender

最新稳定版本:1.1.0

Composer 安装命令:

composer require zarplata/zabbix-sender

包简介

README 文档

README

Zabbix sender it's a PHP implementation of Zabbix sender protocol. With this library you can send any metric to Zabbix server. Additional information about Zabbix sender protocol and request/response you can be found in official documentation:

Installation

composer require zarplata/zabbix-sender

Usage

<?php

use \Zarplata\Zabbix\ZabbixSender;
use \Zarplata\Zabbix\Request\Packet as ZabbixPacket;
use \Zarplata\Zabbix\Request\Metric as ZabbixMetric;

// At first you must initialize ZabbixSender object
// with address of Zabbix Server. If your Zabbix Server
// don't listen default port (10051) you can define it in constructor
// $sender = new ZabbixSender(
//     $serverAddress='ZABBIX_SERVER_HOSTNAME',
//     $serverPort=12345
// );
$sender = new ZabbixSender('ZABBIX_SERVER_HOSTNAME');

// After you define the $sender you must create ZabbixPacket
// it's just accumulator of your metrics which you will add.
$packet = new ZabbixPacket();

// Define your metrinc
$packet->addMetric(new ZabbixMetric('my.super.text.item.key', 'OK'));
$packet->addMetric(new ZabbixMetric('my.super.int.item.key', 1));

// And finally send to Zabbix Server
$sender->send($packet);

Advanced usage options

Sometimes it may be necessary to provide hostname and/or timestamp of metric. By default construction:

<?php

new ZabbixMetric('my.super.text.item.key', 'OK');

take your current hostname and set object creation time as a metric timestamp. If you want define another hostname or/and timestamp you must write the following code:

<?php

(new ZabbixMetric('my.super.text.item.key', 'OK'))
    ->withHostname('my_non_local_hostname')
    ->withTimestamp(662637600); //Timestamp in past 

License

MIT.

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 9
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-31