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uLcuY88R4ec58W/po4k6SwoZ1EobTqNS2trhcv7zd/N78NwFqHaYmSxMwh |
RPWLhOCIlPeCyTO2tGWVxCatC9mDY9yXaK2cpWBdJxawZFoEcVvJDkkRqjXbpjbk9 |
dbGeI+RecwUqi9/F6dQlKyGdLuGjgLDQBGfeQbeAFFpnO7hMw8jlBS0/pP/PNZAyS |
4zW61qZY8mdSWK2UGh/S3mcfkizFTnHQzqzhNDnfiFkMfIJelPxl+XzCBzemQ1WGL |
n0ejvPQQomKTBN28ue4HflIEnqfhnHycUHv7mONgtbYSxGKolzyLWjzvmexfM4kSw |
SfGx42xckQkmnxAalQHgfb69/6PxQ1tsGY0sovuz10IXSMI9OZCTn0MsgVZ8tjy7Z |
TOTFOmhWHTWyhLpyJTIPNsEjXoXRKPozppUO7JTwXRo8gLPis/YoIZUMSQij12Cyi |
fsAl0m/3LTvQ/VG6ZYMFsnXjglA5DOQ8vkI/tiC75l3ht3v0oUx566uSE30xwkzPx |
OBNfsKJmqn0V4M8vl6tTA9RlzFKLYSEX2ypgFZzLGq0eH5OLKz9YeZ9+uyInLacxT |
RGhwTLWcOzkEizvQONq7Qq/G9JGQgjp6PSO/IbJYMfgPYmtJ727uKn241Z8PVOrTR |
XJeXJvR9MnHrixMbaO2YsImllvHO+wmJvU2JK2wibrWhxx3RW/f+7jch0qkXVVmUb |
Q== |
</ViaThinkSoftSignature> */ ?> |
<?php |
|
/* |
|
VNag - Nagios Framework for PHP (C) 2014-2019 |
VNag - Nagios Framework for PHP (C) 2014-2020 |
__ ___ _____ _ _ _ ____ __ _ |
\ \ / (_) __ |_ _| |__ (_)_ __ | | __/ ___| ___ / _| |_ |
\ \ / /| |/ _` || | | '_ \| | '_ \| |/ /\___ \ / _ \| |_| __| |
35,7 → 35,7 |
|
Developed by Daniel Marschall www.viathinksoft.com |
Licensed under the terms of the Apache 2.0 license |
Revision 2019-11-12 |
Revision 2020-04-14 |
|
*/ |
|
335,39 → 335,38 |
$OVERWRITE_ARGUMENTS = null; |
|
function _empty($x) { |
if (is_array($x)) debug_print_stacktrace(); |
// Returns true for '' or null. Does not return true for value 0 or '0' (like empty() does) |
return trim($x) == ''; |
} |
|
abstract class VNag { |
const VNAG_VERSION = '2019-11-12'; |
public const VNAG_VERSION = '2020-04-14'; |
|
// Status 0..3 for STATUSMODEL_SERVICE (the default status model): |
# The guideline states: "Higher-level errors (such as name resolution errors, socket timeouts, etc) are outside of the control of plugins and should generally NOT be reported as UNKNOWN states." |
# We choose 4 as exitcode. The plugin developer is free to return any other status. |
const STATUS_OK = 0; |
const STATUS_WARNING = 1; |
const STATUS_CRITICAL = 2; |
const STATUS_UNKNOWN = 3; |
const STATUS_ERROR = 4; // and upwards |
public const STATUS_OK = 0; |
public const STATUS_WARNING = 1; |
public const STATUS_CRITICAL = 2; |
public const STATUS_UNKNOWN = 3; |
public const STATUS_ERROR = 4; // and upwards |
|
// Status 0..1 for STATUSMODEL_HOST: |
// The page https://blog.centreon.com/good-practices-how-to-develop-monitoring-plugin-nagios/ |
// states that host plugins may return following status codes: |
// 0=UP, 1=DOWN, Other=Maintains last known state |
const STATUS_UP = 0; |
const STATUS_DOWN = 1; |
const STATUS_MAINTAIN = 2; // and upwards |
public const STATUS_UP = 0; |
public const STATUS_DOWN = 1; |
public const STATUS_MAINTAIN = 2; // and upwards |
|
const VERBOSITY_SUMMARY = 0; |
const VERBOSITY_ADDITIONAL_INFORMATION = 1; |
const VERBOSITY_CONFIGURATION_DEBUG = 2; |
const VERBOSITY_PLUGIN_DEBUG = 3; |
const MAX_VERBOSITY = self::VERBOSITY_PLUGIN_DEBUG; |
public const VERBOSITY_SUMMARY = 0; |
public const VERBOSITY_ADDITIONAL_INFORMATION = 1; |
public const VERBOSITY_CONFIGURATION_DEBUG = 2; |
public const VERBOSITY_PLUGIN_DEBUG = 3; |
public const MAX_VERBOSITY = self::VERBOSITY_PLUGIN_DEBUG; |
|
const STATUSMODEL_SERVICE = 0; |
const STATUSMODEL_HOST = 1; |
public const STATUSMODEL_SERVICE = 0; |
public const STATUSMODEL_HOST = 1; |
|
private $initialized = false; |
|
382,16 → 381,14 |
private $helpObj = null; |
private $argHandler = null; |
|
const OUTPUT_SPECIAL = 1; // illegal usage / help page, version page |
const OUTPUT_NORMAL = 2; |
const OUTPUT_EXCEPTION = 4; |
const OUTPUT_ALWAYS = 7; |
const OUTPUT_NEVER = 0; |
public const OUTPUT_NEVER = 0; |
public const OUTPUT_SPECIAL = 1; // illegal usage / help page, version page |
public const OUTPUT_NORMAL = 2; |
public const OUTPUT_EXCEPTION = 4; |
public const OUTPUT_ALWAYS = 7; // = OUTPUT_SPECIAL+OUTPUT_NORMAL+OUTPUT_EXCEPTION |
|
// set to true if you want the output being shown in the HTML beside of the invisible tag |
// set to false if you just want to send the invisible tag |
public $http_visual_output = self::OUTPUT_ALWAYS; |
public $http_invisible_output = self::OUTPUT_ALWAYS; |
public $http_visual_output = self::OUTPUT_ALWAYS; // show a human-readable panel? ... |
public $http_invisible_output = self::OUTPUT_ALWAYS; // ... and/or show an invisible machine-readable tag? |
|
// $html_before and $html_after contain the output HTML which were sent by the user |
|
744,6 → 741,10 |
|
// $optional_args will be forwarded to the callback function cbRun() |
public function run($optional_args=array()) { |
global $inside_vnag_run; |
|
$inside_vnag_run = true; |
try { |
if (!$this->constructed) { |
throw new VNagNotConstructed(VNagLang::$notConstructed); |
} |
850,7 → 851,10 |
} |
|
Timeouter::end(); |
} finally { |
$inside_vnag_run = false; |
} |
} |
|
private function getNagiosConsoleText() { |
// see https://nagios-plugins.org/doc/guidelines.html#AEN200 |
1121,11 → 1125,12 |
throw new VNagPrivateKeyException(sprintf(VNagLang::$privkey_file_not_readable, $this->privkey)); |
} |
|
openssl_sign($payload, $signature, $pkeyid, $this->sign_algo); |
if (@openssl_sign($payload, $signature, $pkeyid, $this->sign_algo)) { |
openssl_free_key($pkeyid); |
|
$dataset['signature'] = base64_encode($signature); |
} |
} |
|
if (!is_null($this->password_out)) { |
$password = $this->password_out; |
1238,7 → 1243,10 |
protected function handleException($exception) { |
$this->checkInitialized(); // if (!$this->initialized) return; |
|
if (!VNag::is_http_mode()) { |
// On console output, remove anything we have written so far! |
while (ob_get_level() > 0) @ob_end_clean(); |
} |
$this->clearVerboseInfo(); |
$this->clearPerformanceData(); |
|
2450,13 → 2458,21 |
} |
|
function vnagErrorHandler($errorkind, $errortext, $file, $line) { |
// This function "converts" PHP runtime errors into Exceptions, which can then be handled by VNag::handleException() |
global $inside_vnag_run; |
|
if (!$inside_vnag_run && VNag::is_http_mode()) { |
// We want to avoid that the VNag-Exception will show up in a website that contains |
// an embedded VNag monitor, so if we are not inside a running VNag code, |
// we will call the normal PHP error handler. |
return false; |
} |
|
if (!(error_reporting() & $errorkind)) { |
// Code is not included in error_reporting. Don't do anything. |
return; |
return true; |
} |
|
while (ob_get_level() > 0) @ob_end_clean(); |
|
// We want 100% clean scripts, so any error, warning or notice will shutdown the script |
// This also fixes the issue that PHP will end with result code 0, showing an error. |
|
2478,10 → 2494,11 |
if (defined('E_USER_DEPRECATED') && ($errorkind == E_USER_DEPRECATED)) $errorkind = 'User Deprecated'; |
throw new VNagException(VNagLang::$php_error . " $errortext at $file:$line (kind $errorkind)"); |
|
// true = the PHP internal error handling will not be called. |
// true = the PHP internal error handling will NOT be called. |
return true; |
} |
|
$inside_vnag_run = false; |
$old_error_handler = set_error_handler("vnagErrorHandler"); |
|
// === End of document === |