Beispiel #1
0
    public function testAllMethod()
    {
        $dump = <<<EOF
Filter: state = 0
Filter: state = 1
Filter: state != 2
Filter: state ~ 3
Filter: state !~ 4
Filter: state < 5
Filter: state > 6
Filter: state <= 7
Filter: state >= 8
And: 1
Or: 2
Negate:

EOF;
        $mock = new Filter();
        $mock->set('state = 0')->equal('state', '1')->notEqual('state', '2')->match('state', '3')->notMatch('state', '4')->less('state', '5')->greater('state', '6')->lessEqual('state', '7')->greaterEqual('state', '8')->operatorAnd(1)->operatorOr(2)->negate();
        $this->assertEquals($dump, join('', $mock->get()));
        $mock->reset();
        $this->assertEquals('', join('', $mock->get()));
    }
Beispiel #2
0
<?php

use Kwkm\MkLiveStatusClient as mk;
require __DIR__ . '/vendor/autoload.php';
$client = new mk\Client(new mk\Configuration(array('socketType' => 'unix', 'socketPath' => '/var/run/nagios/rw/live')));
$parser = new mk\Parser();
$column = new mk\Column(array('host_name', 'description', 'state'));
$filter = new mk\Filter();
$filter->equal('description', 'PING');
$lql = new mk\Lql(mk\Table::SERVICES);
$lql->column($column)->filter($filter);
var_dump($parser->get($client->execute($lql)));
Beispiel #3
0
    public function testReadme16()
    {
        $lql = <<<EOF
GET services
Filter: host_groups >= windows
Filter: scheduled_downtime_depth = 0
Filter: host_scheduled_downtime_depth = 0
Filter: in_notification_period = 1
Stats: last_hard_state = 0
Stats: last_hard_state = 1
Stats: acknowledged = 0
StatsAnd: 2
Stats: last_hard_state = 1
Stats: acknowledged = 1
StatsAnd: 2
Stats: last_hard_state = 2
Stats: acknowledged = 0
StatsAnd: 2
Stats: last_hard_state = 2
Stats: acknowledged = 1
StatsAnd: 2
Stats: last_hard_state = 3
Stats: acknowledged = 0
StatsAnd: 2
Stats: last_hard_state = 3
Stats: acknowledged = 1
StatsAnd: 2
OutputFormat: json
ResponseHeader: fixed16


EOF;
        $stats = new Stats();
        $stats->equal('last_hard_state', '0')->equal('last_hard_state', '1')->equal('acknowledged', '0')->operatorAnd(2)->equal('last_hard_state', '1')->equal('acknowledged', '1')->operatorAnd(2)->equal('last_hard_state', '2')->equal('acknowledged', '0')->operatorAnd(2)->equal('last_hard_state', '2')->equal('acknowledged', '1')->operatorAnd(2)->equal('last_hard_state', '3')->equal('acknowledged', '0')->operatorAnd(2)->equal('last_hard_state', '3')->equal('acknowledged', '1')->operatorAnd(2);
        $filter = new Filter();
        $filter->greaterEqual('host_groups', 'windows')->equal('scheduled_downtime_depth', '0')->equal('host_scheduled_downtime_depth', '0')->equal('in_notification_period', '1');
        $mock = \TestMock::on(new Lql(Table::SERVICES));
        $mock->filter($filter)->stats($stats);
        $this->assertEquals($lql, $mock->build(), 'Combining with and/or.');
    }