Skip to content

Latest commit

 

History

History
54 lines (33 loc) · 1.21 KB

README.md

File metadata and controls

54 lines (33 loc) · 1.21 KB

php-gearman-status

Library for getting status and statistic data of a Gearman Jobserver

Requirements

  • php >=5.3.0

Installation

$ composer require t3sec/gearman-status

Usage

Namespacing

use T3sec\GearmanStatus\GearmanMetrics;
use T3sec\GearmanStatus\GearmanServer;

Basic Example

$server = new GearmanServer();
$gearmanMetrics = new GearmanMetrics($server);

var_dump($gearmanMetrics->getRawData());

Uses default configuration of a Gearman Jobserver and returns raw metrics as array.

Advanced Example

$server = new GearmanServer('192.1.1.10', 4444);
$gearmanMetrics = new GearmanMetrics($server);

$numWorkers = $gearmanMetrics->getNumberOfWorkersByFunction('ReverseIpLookup');
$unfinishedTasks = $gearmanMetrics->getUnfinishedTasksByFunction('ReverseIpLookup');

Retrieves metrics of a Gearman jobserver at IP 192.1.1.10 listening at port 4444. Number of connected workers and unfinished tasks are returned.

Exception handling

  • \InvalidArgumentException is thrown if a GermanServer is configured with invalid settings
  • T3sec\GearmanStatus\Exception\GearmanStatusException is thrown if the connection to the Gearman jobserver cannot be established