コード例 #1
0
ファイル: threshold_test.php プロジェクト: pauln/local_nagios
 public function testParseRange()
 {
     $t1 = threshold::from_string('10');
     $this->assertEquals(10, $t1->end);
     $this->assertFalse($t1->startinfinity);
     $t2 = threshold::from_string('~:10');
     $this->assertEquals(10, $t2->end);
     $this->assertTrue($t2->startinfinity);
     $t3 = threshold::from_string('@~:10');
     $this->assertEquals(10, $t3->end);
     $this->assertTrue($t3->startinfinity);
     $this->assertEquals(threshold::INSIDE, $t3->alerton);
 }
コード例 #2
0
ファイル: check.php プロジェクト: pauln/local_nagios
if ($options['help']) {
    print_help();
}
if (empty($options['plugin']) || empty($options['service'])) {
    print_help();
}
$plugin = $options['plugin'];
$service = $options['service'];
$warning = $options['warning'];
$critical = $options['critical'];
$thresholds = new thresholds();
if ($options['warning']) {
    $thresholds->warning = threshold::from_string($options['warning']);
}
if ($options['critical']) {
    $thresholds->critical = threshold::from_string($options['critical']);
}
if (empty($thresholds->critical) && empty($thresholds->warning)) {
    echo "No valid thresholds given";
    exit(service::NAGIOS_STATUS_UNKNOWN);
}
try {
    $service = service::get_service($plugin, $service);
    if (empty($service)) {
        echo "Unable to get service {$service} from {$plugin}";
        exit(3);
    }
    $params = cli_get_params($service->get_param_defs());
    $status = $service->check_status($thresholds, $params[0]);
    if (is_null($status)) {
        throw new Exception("Service check returned no status");