Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/local/nagios/libexec/ |
Upload File : |
<?php
// '#!/usr/local/bin/php' should be in the main script, and not /usr/bin/php, because macos protects entire /usr folder, with the exception of /usr/local
class Nagios_Plugin {
const RC_OK = 0; // The plugin was able to check the service and it appeared to be functioning properly
const RC_WARNING = 1; // The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly
const RC_CRITICAL = 2; // The plugin detected that either the service was not running or it was above some "critical" threshold
const RC_UNKNOWN = 3; // Invalid command line arguments were supplied to the plugin or low-level failures internal to the plugin that prevent it from performing the specified operation.
// 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.
private $rcode;
private $performance_data = []; // 0 or more lines; should not be more than 80x25 characters
private $status = 'OK';
private $summary;
protected $args = [];
protected $params = [];
public function ReturnCode() {
if (func_num_args()) {
$this->rcode = func_get_arg(0);
return $this;
}
return $this->rcode;
}
public function Status() { // this is the 'OK' or 'FAIL' at beginning of output, without the colon
if (func_num_args()) { // could also be 'CRITICAL' or 'WARNING'?
$this->status = func_get_arg(0);
return $this;
}
return $this->status;
}
public function Summary() { // this is the first line of output - providing a summary of what was picked up by the plugin
if (func_num_args()) {
$this->summary = func_get_arg(0);
return $this;
}
return $this->summary;
}
public function PerformanceData() {
if (func_num_args()) {
foreach(func_get_args() as $arg) {
$this->performance_data[] = $arg;
}
return $this;
}
return $this->performance_data;
}
public function __toString() {
$output = $this->Status() . ': ' . $this->Summary();
$pd = $this->PerformanceData();
foreach($pd as $item) {
$output .= ' | ' . $item;
}
return $output . "\n";
// return wordwrap($output, 80);
}
public function Error($message) {
$this->ReturnCode(static::RC_UNKNOWN)
->Status('ERROR')
->Summary($message);
}
private function _param($param, $key) {
if (isset($param[$key])) {
$placeholder = isset($param['param']) ? $param['param'] : FALSE;
$text = str_replace('-', '', $param[$key]);
if ($key == 'short') {
$cmd = '-' . substr($text, 0, 1);
if ($placeholder) $cmd .= " $placeholder"; // optional space between command and parameter
} else {
$cmd = '--' . $text;
if ($placeholder) $cmd .= "=$placeholder";
}
return $cmd;
} else {
return FALSE;
}
}
private function _process($name, $param, $key, $v) {
if (array_key_exists($key, $v)) {
$placeholder = isset($param['param']) ? $param['param'] : FALSE;
if ($placeholder) { // single parameter
$this->params[$name] = $v[$key];
} else { // boolean
$this->params[$name] = !$v[$key]; // invert it
}
}
}
protected function generateHelp() {
$cmdline = $_SERVER['argv'][0];
$lines = '';
foreach($this->args as $name => $param) {
$short = $this->_param($param, 'short');
$long = $this->_param($param, 'long');
if (isset($param['short'])) {
$cmd = $short;
} elseif (isset($param['long'])) {
$cmd = $long;
}
if (empty($param['required'])) {
$cmd = "[$cmd]";
}
$cmdline .= " $cmd";
$line = '';
if ($short) {
$line = $short;
}
if ($long) {
if ($line != '') $line .= ', ';
$line .= $long;
}
$line = ' ' . $line;
if (strlen($line) > 24) {
$lines .= "\n$line\n" . str_pad('', 25) . $param['help'];
} else {
$lines .= "\n" . str_pad($line, 25) . $param['help'];
}
}
return <<<BLOCK
usage: $cmdline
optional arguments:$lines
BLOCK;
}
private function getParam($fieldname) {
foreach($this->args as $name => $param) {
$param['fieldname'] = $name;
$short = $param['short'] ?? '';
if (substr($fieldname, 0, strlen($short)) == $short) {
$value = substr($fieldname, strlen($short));
if ($value != '') $param['value'] = $value;
return $param;
}
$long = $param['long'] ?? '';
if (substr($fieldname, 0, strlen($long)) == $long) {
if (($p = strpos($fieldname, '=')) !== FALSE) {
$param['value'] = substr($fieldname, $p + 1);
}
return $param;
}
}
return NULL;
}
private function _processArgument(&$i, &$errors, $param) {
$placeholder = $param['param'] ?? FALSE;
$name = $param['fieldname'];
$value = $param['value'] ?? FALSE;
if ($placeholder) { // single parameter
if ($value !== FALSE) {
$this->params[$name] = $value;
return;
}
$next = $_SERVER['argv'][$i + 1] ?? '';
if (substr($next, 0, 1) == '-') {
$errors[] = "value for field $name is missing";
} else {
$this->params[$name] = $next;
$i++;
}
} else { // boolean
if (!array_key_exists($name, $this->params)) {
$this->params[$name] = TRUE;
} else {
$this->params[$name] = !$this->params[$name];
}
}
}
public function Execute() {
$errors = [];
// put in current values
for($i = 1; $i < $_SERVER['argc']; $i++) {
$element = $_SERVER['argv'][$i];
if ($element[0] == '-') {
$param = $this->getParam($element);
if (!is_null($param)) {
$this->_processArgument($i, $errors, $param);
}
}
}
// if the parameter is missing, check the 'param' entry
// put in the defaults, check required fields
foreach($this->args as $name => $param) {
if (!array_key_exists($name, $this->params)) {
$placeholder = $param['param'] ?? FALSE;
if ($param['required'] ?? FALSE) {
$errors[] = "$name is a required field";
} elseif (!$placeholder) { // boolean
$this->params[$name] = FALSE;
} elseif (isset($param['default'])) {
$this->params[$name] = $param['default'];
} else {
$this->params[$name] = NULL;
}
}
}
if ($this->params['help']) {
die($this->generateHelp());
}
}
public function __Construct() {
// commandline params
$this->add_argument('help', [
'short' => '-h',
'long' => '--help',
'help' => 'display this help text',
]);
}
protected function add_argument($name, $arg) {
$this->args[$name] = $arg;
}
}