Git Product home page Git Product logo

zabbix-sender-php's Introduction

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:

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.

zabbix-sender-php's People

Contributors

idr0id avatar mattlibera avatar tears-of-noobs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zabbix-sender-php's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.