承接 kwkm/mklivestatus-client 相关项目开发

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

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

kwkm/mklivestatus-client

Composer 安装命令:

composer require kwkm/mklivestatus-client

包简介

mkLiveStatus Client

README 文档

README

License Build Status Code Coverage Scrutinizer Code Quality

Client Setting.

In the case of localhost.

use Kwkm\MkLiveStatusClient as mk;

require __DIR__ . '/vendor/autoload.php';

$config = new mk\Configuration(
    array(
        'socketType' => 'unix',
        'socketPath' => '/var/run/nagios/rw/live',
    )
);

$client = new mk\Client($config);

$parser = new mk\Parser();

In the case of remote network.

use Kwkm\MkLiveStatusClient as mk;

require __DIR__ . '/vendor/autoload.php';

$config = new mk\Configuration(
    array(
        'socketType' => 'tcp',
        'socketAddress' => '192.168.0.100',
        'socketPort' => 6557,
    )
);

$client = new mk\Client($config);

$parser = new mk\Parser();

Example - LqlBuilder

Retrieve all contacts.

$lql = new mk\LqlBuilder(mk\Table::CONTACTS);

$result = $parser->get($client->execute($lql));

Retrieves just the columns name and alias.

$lql = new mk\LqlBuilder(mk\Table::CONTACTS);
$lql->columns(array('name', 'alias'));

$result = $parser->get($client->execute($lql));

Gets all services with the current state 2 (critical).

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->columns(array('host_name', 'description', 'state'))
    ->filterEqual('state', '2');

$result = $parser->get($client->execute($lql));

Gets all critical services which are currently within their notification period.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->columns(array('host_name', 'description', 'state'))
    ->filterEqual('state', '2')
    ->filterEqual('in_notification_period', '1');

$result = $parser->get($client->execute($lql));

Matching lists.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->columns(array('host_name', 'description', 'state', 'contacts'))
    ->filterGreaterEqual('contacts', 'harri');

$result = $parser->get($client->execute($lql));

Gets all hosts that do not have parents.

$lql = new mk\LqlBuilder(mk\Table::HOSTS);
$lql->column('name')
    ->filterEqual('parents', '');

$result = $parser->get($client->execute($lql));

Matching attribute lists

Find all hosts with modified attributes.

$lql = new mk\LqlBuilder(mk\Table::HOSTS);
$lql->columns(array('host_name', 'modified_attributes_list'))
    ->filterNotEqual('modified_attributes', '0');

$result = $parser->get($client->execute($lql));

Find hosts where notification have been actively disabled.

$lql = new mk\LqlBuilder(mk\Table::HOSTS);
$lql->columns(array('host_name', 'modified_attributes_list'))
    ->filterMatch('modified_attributes', 'notifications_enabled')
    ->filterEqual('notifications_enabled', '0');

$result = $parser->get($client->execute($lql));

Find hosts where active or passive checks have been tweaked.

$lql = new mk\LqlBuilder(mk\Table::HOSTS);
$lql->columns(array('host_name', 'modified_attributes_list'))
    ->filterSet('modified_attributes ~~ active_checks_enabled,passive_checks_enabled');

$result = $parser->get($client->execute($lql));

Combining Filters with And, Or and Negate.

Selects all services which are in state 1 or in state 3.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterEqual('state', '1')
    ->filterEqual('state', '3')
    ->filterOr(2);

$result = $parser->get($client->execute($lql));

Shows all non-OK services which are within a scheduled downtime or which are on a host with a scheduled downtime.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterGreater('scheduled_downtime_depth', '0')
    ->filterGreater('host_scheduled_downtime_depth', '0')
    ->filterOr(2);

$result = $parser->get($client->execute($lql));

All services that are either critical and acknowledged or OK.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterEqual('state', '2')
    ->filterEqual('acknowledged', '1')
    ->filterAnd(2)
    ->filterEqual('state', '0')
    ->filterOr(2);

$result = $parser->get($client->execute($lql));

Displays all hosts that have neither an a nor an o in their name.

$lql = new mk\LqlBuilder(mk\Table::HOSTS);
$lql->filterMatch('name', 'a')
    ->filterMatch('name', 'o')
    ->filterOr(2)
    ->filterNegate();

$result = $parser->get($client->execute($lql));

Stats and Counts.

The numbers of services which are OK, WARN, CRIT or UNKNOWN.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->statsEqual('state', '0')
    ->statsEqual('state', '1')
    ->statsEqual('state', '2')
    ->statsEqual('state', '3');

$result = $parser->decode($client->execute($lql));

The output to services to which the contact harri.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->statsEqual('state', '0')
    ->statsEqual('state', '1')
    ->statsEqual('state', '2')
    ->statsEqual('state', '3')
    ->filterGreaterEqual('contacts', 'harri');

$result = $parser->decode($client->execute($lql));

Combining with and/or.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterGreaterEqual('host_groups', 'windows')
    ->filterEqual('scheduled_downtime_depth', '0')
    ->filterEqual('host_scheduled_downtime_depth', '0')
    ->filterEqual('in_notification_period', '1')
    ->statsEqual('last_hard_state', '0')
    ->statsEqual('last_hard_state', '1')
    ->statsEqual('acknowledged', '0')
    ->statsAnd(2)
    ->statsEqual('last_hard_state', '1')
    ->statsEqual('acknowledged', '1')
    ->statsAnd(2)
    ->statsEqual('last_hard_state', '2')
    ->statsEqual('acknowledged', '0')
    ->statsAnd(2)
    ->statsEqual('last_hard_state', '2')
    ->statsEqual('acknowledged', '1')
    ->statsAnd(2)
    ->statsEqual('last_hard_state', '3')
    ->statsEqual('acknowledged', '0')
    ->statsAnd(2)
    ->statsEqual('last_hard_state', '3')
    ->statsEqual('acknowledged', '1')
    ->statsAnd(2);

$result = $parser->decode($client->execute($lql));

The number of services in the various states for each host in the host group windows.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterGreaterEqual('host_groups', 'windows')
    ->statsEqual('state', '0')
    ->statsEqual('state', '1')
    ->statsEqual('state', '2')
    ->statsEqual('state', '3')
    ->column('host_name');

$result = $parser->decode($client->execute($lql));

Counts the total number of services grouped by the check command.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->statsNotEqual('state', '9999')
    ->column('check_command');

$result = $parser->decode($client->execute($lql));

Counting the total number of services grouped by their states.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->statsNotEqual('state', '9999')
    ->column('state');

$result = $parser->decode($client->execute($lql));

Sum, Minimum, Maximum, Average, Standard Deviation.

Minimum, maximum and average check execution time of all service checks in state OK.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterEqual('state', '0')
    ->statsMin('execution_time')
    ->statsMax('execution_time')
    ->statsAvg('execution_time');

$result = $parser->decode($client->execute($lql));

Grouping host_name.

$lql = new mk\LqlBuilder(mk\Table::SERVICES);
$lql->filterEqual('state', '0')
    ->statsMin('execution_time')
    ->statsMax('execution_time')
    ->statsAvg('execution_time')
    ->column('host_name');

$result = $parser->decode($client->execute($lql));

Example - Lql

$column = new mk\Column(
    array(
        'host_name',
        'description',
        'state',
    )
);

$filter = new mk\Filter();
$filter->equal('state', '2')
       ->equal('acknowledged', '1')
       ->operatorAnd(2)
       ->equal('state', '0')
       ->operatorOr(2);

$lql = new mk\Lql(mk\Table::SERVICES);
$lql->column($column)->filter($filter);

$result = $parser->get($client->execute($lql));
$column = new mk\Column(
    array(
        'host_name',
    )
);

$stats = new mk\Stats();
$stats->equal('state', '0')
      ->equal('state', '1')
      ->equal('state', '2')
      ->equal('state', '3');

$lql = new mk\Lql(mk\Table::SERVICES);
$lql->stats($stats)->column($column);

$result = $parser->decode($client->execute($lql));

kwkm/mklivestatus-client 适用场景与选型建议

kwkm/mklivestatus-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「nagios」 「mklivestatus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kwkm/mklivestatus-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kwkm/mklivestatus-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 kwkm/mklivestatus-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-19