aashley / nagios-livestatus-client
用于与MK Livestatus通信的面向对象的客户端
v1.0.0
2016-07-01 01:04 UTC
Requires
- php: >=5.3.1
- ext-json: *
- ext-sockets: *
Requires (Dev)
- phpunit/phpunit: @stable
This package is auto-updated.
Last update: 2024-09-17 16:52:18 UTC
README
本软件包实现了用于与Nagios事件代理MK Livestatus通信的PHP面向对象客户端。
此实现基于Lars Michelsen的LivestatusSlave。
要求
- PHP 5.3.1+
- 启用套接字
- 启用JSON
用法
<?php use Nagios\Livestatus\Client; $options = array( 'socketType' => 'tcp', 'socketAddress' => '10.253.14.22', 'socketPort' => '6557', ); $client = new Client($options); $response = $client ->get('hosts') ->column('host_name') ->column('state') ->execute(); foreach ($response as $host) { print $host[0] . ": " . $host[1] . "\n"; } $response = $client ->get('hosts') ->column('host_name') ->column('state') ->executeAssoc(); foreach ($response as $host) { print $host['host_name'] . ": " . $host['state'] . "\n"; } $client->command( array( 'ACKNOWLEDGE_SVC_PROBLEM', 'example.com', 'some service', 2, 0, 1, 'username', 'Example comment' ) );
安装
在composer中添加对aashley/nagios-livestatus-client
的依赖
composer require aashley/nagios-livestatus-client