Subversion Repositories vnag

Compare Revisions

No changes between revisions

Regard whitespace Rev 1 → Rev 2

/trunk/plugins/wordpress_version/WordPressVersionCheck.class.php
0,0 → 1,81
<?php /* <ViaThinkSoftSignature>OJBtqRvIU6hU8LTzanZKhpd9dpHHiBOX4pwyUGXYgEltRcNKKASFsv71lmshrkuxmgCp2q4aa9jB03T0RPOPXtAulRlFpLvsmD7eXHRqt82AC8H2PMw8uoCMk/bqgfAMqf1y0sP9qs5s9faijFgdKlQkJH3nLGDQ3YsN1dYLMwtUQsKtnVobLizdd5tIlyW1OcY5h32Yd2z24CjcgBUbknqBD+I6dBx7TBQWXqX4CwC7N2jDXyn7TBN2CHWtYlY1BldUndt6PXEaaoYOtqcQw/cSc7NvOenQFGQt++Kwur1f31+6HiGbLFGLfrA0sXJWUdYWLHGkNHKmzmPoDZFWweQIadB5QQGtnLWUpPtIsShIg4/G0+Lt6V/janYr0D/IGVnRyXUikh59qNkx942oGF/ozuu39OYyAhyUTbpCT8/PeDwjS2qPbvsZEq2tUDGHHBxq1XW8DmsmLkRCertcVGsG+WLBmxCJLRjI/5UE0zB9XCXwIPOI8+ImtvBgGhEPu63xbORECr6R0L8FWZ8cjCvnrNEFZOSliTQWwUzpcgJTAFSJPlHEF/X4PbqbhsJLU6Z75Q/jIfKWzxzREzkyPKQGDAitKnGwiNZo04tJSxBryd8Vqm0sASmTkSm1TU60C7MOzWCekIekea+lOpoxPwdXuphxwahGTxXkp+FCQ7/K1e/jYOkCgq/Xz7uZRVXK7/bL0QlrwMQtJbbiJHon4pE7aar6yP3mAE6zqXdPzxCRr28ochhY2dFU6RKXK9mMgkAdvalsyksLR4ivEOcGrRW3ZasY8RhLu1UiZKGpVrlanK7E8AqL6moXB5xxTmNeBGBPzWmYJaAFjHp+iFNVy11jGTQD9HW4bQ0vqhj71TyCpmXJnsiF0J3Zurj+iB22U192yBVluuOemOCTfygSySdZXsQCb2dARjnalkyb9ee5j0VrgeI7FYeVne9PkarpWRgvVhEQzLbwcCgRHKpQy0w4V41wx5HdmrcncYntEdbIx0iITKeIFy65VaQYQyk4RNL6PG6jY32gyNqIA7OzwnTYrguBlKhf4Fp9ij8g9xPtXp16Jz1AEzxkbxMzIZeSwQXIv14rbZszTuFJ3LsjH77agS2Gc6nqframOvPF4YszPJUG+EpSLiiuM/5SAXcTB8pDPoaRSVXSg9ouoLjH5BcppDUQqBIaXuJzDvqpfXQzAEBeyZg0jQw/3ylLAIlp4oNmuU+UlmIO4GYlGWVo6eAqH/v/g3cffTVce/OvpjUR0+3bTgmlf8/QC9s/rqtYEJ9jB953TfnSkP1RXP2y0ZlfuumRB2u2mDuJEZrWbZwXdobkfwwLrxPGeucLqPeY+it+yD6tNguvu2c0/BMuPA==</ViaThinkSoftSignature> */ ?>
<?php
 
/*
* VNag - Nagios Framework for PHP
* Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
* Licensed under the terms of the Apache 2.0 license
*
* Revision 2018-07-15
*/
 
declare(ticks=1);
 
class WordPressVersionCheck extends VNag {
protected $argSystemDir = null;
 
public function __construct() {
parent::__construct();
 
$this->registerExpectedStandardArguments('Vht');
 
$this->getHelpManager()->setPluginName('check_wordpress_version');
$this->getHelpManager()->setVersion('1.0');
$this->getHelpManager()->setShortDescription('This plugin checks if a local WordPress Webmail system has the latest version installed.');
$this->getHelpManager()->setCopyright('Copyright (C) 2011-$CURYEAR$ Daniel Marschall, ViaThinkSoft.');
$this->getHelpManager()->setSyntax('$SCRIPTNAME$ [-d <directory>]');
$this->getHelpManager()->setFootNotes('If you encounter bugs, please contact ViaThinkSoft at www.viathinksoft.com');
 
// Individual (non-standard) arguments:
$this->addExpectedArgument($this->argSystemDir = new VNagArgument('d', 'directory', VNagArgument::VALUE_REQUIRED, 'wordpressPath', 'The local directory where WordPress installation is located.'));
}
 
protected function get_wordpress_version($path) {
$path = realpath($path) === false ? $path : realpath($path);
 
$cont = @file_get_contents("$path/wp-includes/version.php");
 
if (!preg_match('@\$wp_version = \'(.+)\';@ismU', $cont, $m)) {
throw new Exception("Cannot find version information at $path");
}
 
return $m[1];
}
 
protected function get_latest_version() {
$cont = @file_get_contents('https://wordpress.org/download/');
if (!$cont) {
throw new Exception("Cannot access website with latest version");
}
 
if (!preg_match('@Download WordPress ([0-9\.]+)@ism', $cont, $m)) {
throw new Exception("Cannot find version information on the website");
}
 
return trim($m[1]);
}
 
protected function cbRun($optional_args=array()) {
$system_dir = $this->argSystemDir->getValue();
if (empty($system_dir)) {
throw new Exception("Please specify the directory of the WordPress installation.");
}
$system_dir = realpath($system_dir) === false ? $system_dir : realpath($system_dir);
 
if (!is_dir($system_dir)) {
throw new Exception('Directory "'.$system_dir.'" not found.', false);
}
 
$version = $this->get_wordpress_version($system_dir);
 
$latest_version = $this->get_latest_version();
 
if ($version == $latest_version) {
$this->setStatus(VNag::STATUS_OK);
$this->setHeadline("Version $version at $system_dir", true);
} else {
$this->setStatus(VNag::STATUS_WARNING);
$this->setHeadline("Version $version is outdated (Latest version is $latest_version) at $system_dir", true);
}
}
}
/trunk/plugins/wordpress_version/check_wordpress_version
0,0 → 1,20
#!/usr/bin/php
<?php /* <ViaThinkSoftSignature>Mzlo3XO1AyetqTdWdp4c5CngIzcUyos2y4JIyI4Y5Xt3osdutrFth/1x8muUNkHZ37a7RrR5uM4oTKnzgj+seixYPeRE5CBxN4Ciqe7jHDFMxjRehWL2ly7Oq5WVhrC1QljKGBU9/cHtBaIEtcqkLilBX4MNN4PLuuvHNuI+6qByg66gSGq+Zwt5fAW+4b9HOHxQEPOCQXWx3SR7SwSdnoM73znHWsEqGZHie4UnGajoCUmzuj0ONg2Q8k3g+n+o838Boc2TnWafkjgaHgCf/m0J2wH4z2V4YgtFRZ10DF6UZN3k6Khgc5HOL1IV2le0mcTD70b1JYghEXXgZYn1qhoap9cBDbSgtwjh7zxEiEzy5zP31r0+Ue8H+puuJXhmoBHopOloeD1CWHGWJfoGZ+lKOKTIQJOpVDBLuHIsKb30rBSRgQolcbSpqmlyWgCVK2LTlciYXYb76vDd1yoNaw6slcuJswQQCwRSmn59xgBTy9MMOLRXxv37TMgfzvNAeTZ3HSrAgGkzRyMIM9VrsSM0E6tB9pBS0kB2CEttzX5eqflffYmetM18WtR33YWqVkUF9SxeFHP1Rd5d5siA36KkYoMBkzLm+kb2GvSM4N4gaA1rV8ZYY1cL9OERfT09aqfoXAEtCh88a4HzbyDCCN9zAhl+6PxDDHR1mzUoUyk/Eps6CF78Hp5AfEX17WIxC18CdN2UzvpTMCc+fALRddKxGg1he8U6zf5umkCWFDAAt8oeGcwm4Se0F+veudgfq8wOcT/c3EAFVCV3BuVCZJLBSAiYCJXHY8nbAgWhmfU0M+tu+HKqgzrSIXxFxvpStlTZ4D5eI5oolGdwJiDbP39lLLrRFX5fVJvmzMzi6Tu/1OXW6p2Cx8Cy7/GX6qW2wusEUUjQWPl+F7N4P/X6z8g+/Sql3UgmEZBu1qZzUwXYczhXMPUloSiSK+SzDFf2o5wjXJ/gNks/Wy5AlPvdxa4Qzf5cCITL8jbWzZurVXW+UExZMYoMNDlk8jogjqxr90eoKINJYaM3WDowoS84FZzxWAKrHGUYhKTUAJETC0zwaYI1j94XEktxU/1NBaEdVVbf3zr3DU6xbWHqVnrO1Cs7TOAHTiX1Z9rfo3yIFUnmOAAglfDGJCjghdudp6CMebKRFbQLEfg5J03c+pSan/yqgz1Nc8zBOe1hlAnXZsrzL3b0q/+YGfhHQmh6kP9wZ77IKjfZ4RhvBckUplcB3Cm39j2lgBLVtyUKWopnVVohpakMgw9FuEv0pOGFaDPTibIbgkh5QRBLasrnn5+Hbucke/IfJq8/svSKA2JMfYVjMMudOabsRWYgZmLTx3od3dKyrb8YrBimXUoyl43Meg==</ViaThinkSoftSignature> */ ?>
<?php
 
/*
* VNag - Nagios Framework for PHP
* Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
* Licensed under the terms of the Apache 2.0 license
*
* Revision 2018-07-15
*/
 
declare(ticks=1);
 
require_once __DIR__ . '/../../framework/vnag_framework.inc.php';
require_once __DIR__ . '/WordPressVersionCheck.class.php';
 
$job = new WordPressVersionCheck();
$job->run();
unset($job);
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/plugins/wordpress_version/icinga2.conf
0,0 → 1,48
// Put this file in /etc/icinga2/conf.d/...
 
// VNag - Nagios Framework for PHP
// Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
// Licensed under the terms of the Apache 2.0 license
//
// Revision 2018-07-15
 
object CheckCommand "vnag_wordpress_version" {
command = [ "/daten/vnag/plugins/wordpress_version/check_wordpress_version" ]
 
arguments = {
"-d" = {
value = "$vnag_wordpress_version_dir$"
description = "Location where the WordPress installation is located"
required = true
}
}
}
 
// Example usage:
//
// apply Service "example_website1_wordpress_version" {
// import "generic-service"
// check_command = "vnag_wordpress_version"
// vars = {
// vnag_wordpress_version_dir = "/var/www/website1/wordpress/"
// }
// assign where host.name == NodeName
// }
//
// apply Service "example_website2_wordpress_version" {
// import "generic-service"
// check_command = "vnag_wordpress_version"
// vars = {
// vnag_wordpress_version_dir = "/var/www/website2/wordpress/"
// }
// assign where host.name == NodeName
// }
//
// apply Service "example_website3_wordpress_version" {
// import "generic-service"
// check_command = "vnag_wordpress_version"
// vars = {
// vnag_wordpress_version_dir = "/var/www/website3/wordpress/"
// }
// assign where host.name == NodeName
// }