2017 © Pedro Peláez
 

library zabbix-sender

image

zarplata/zabbix-sender

  • Tuesday, June 5, 2018
  • by tears-of-noobs
  • Repository
  • 5 Watchers
  • 2 Stars
  • 187 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Zabbix sender

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: - https://www.zabbix.com/documentation/3.4/manual/appendix/items/trapper - https://www.zabbix.com/documentation/3.4/manual/appendix/protocols/header_datalen, (*1)

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:, (*2)

<?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:, (*3)

<?php

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

License

MIT., (*4)

The Versions

05/06 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-sockets *

 

by Platonov Andrey

05/06 2018

v1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-sockets *

 

by Platonov Andrey

04/06 2018

v1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-sockets *

 

by Platonov Andrey

31/05 2018

v1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-socket *

 

by Platonov Andrey