2017 © Pedro Peláez
 

library nagios-php

Nagios php plugin

image

dubture/nagios-php

Nagios php plugin

  • Wednesday, March 18, 2015
  • by pulse00
  • Repository
  • 2 Watchers
  • 3 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

nagios-php

Build Status Scrutinizer Code Quality, (*1)

Simple utility to help writing nagios plugins in PHP inspired by the Silex microframework., (*2)

Usage:

Example - check_hello :, (*3)

<?php 

require_once __DIR__ . '/nagios.phar';

use Dubture\Nagios\Plugin;

$plugin = new Plugin();
$plugin->run(function($name, $foo = 'bar') use ($plugin) {

    return array(Plugin::OK, array('hello' => $name, $foo));

});

Running the above plugin using check_hello pulse00 will result in an nagios service state OK and the multiline output:, (*4)

hello | pulse00
bar

The Dubture\Nagios\Plugin::run() method expects a Closure whose method signature determines the nagios plugin arguments. A parameter without a default value represents a mandatory argument, a parameter with a default value represents an optional argument., (*5)

The plugin in the above example has one mandatory argument name and an optional argument foo with the default value bar., (*6)

The Closure should return an array with the status code as the first element and the output as the second argument, which will be formatted after the following rules:, (*7)

  • If the second array element is a string, the output is a single-line message
  • If the second array element is an array, the output is a multi-line message.
  • Every element of the multiline message can either be a simple message (literal value), or a message / performance output if the array paramater is a key/value pair.

Installation

Download and include the nagios.phar file. That's all., (*8)

The Versions