Subversion Repositories vnag

Compare Revisions

No changes between revisions

Regard whitespace Rev 1 → Rev 2

/trunk/plugins/nocc_version/NoccVersionCheck.class.php
0,0 → 1,83
<?php /* <ViaThinkSoftSignature>Pk9vVzhiMUsINHj3unermWodlsIIRX8gfqCE9mxoch3WXBd3FqQdASPFk8CNjqMB1bPBUTqhkSkn1gKP8qG7e1kcr8pciOd4RYZmd5HuuqNFdJFK4l8cDYSl71LgqQBKQMMLt9bygoUPVyAgN6b8B87qM6XmTsJHDK74u1OtQOaffQNIBMXvbWH8tDFrcDpKvTvQlgkNYqil/gvZ/KMSjghhh0+OTFmBFeaChK34O0vMv7PbWw2Kt/rT1jxs6sfWzGal1cLAP/wAb1/fwKP8+OsmOuRwcNjEk09/k6mc93SxGAxYvRatgNoE3QhMyJMra9iF22/ZZ2/xkubn4T83rDI+AJXzvsvqpTFezxmTeHG8Y02ufSPOl4lFT9Ds6FtRymHaLtSMrXet3r/RRO0vM8V86kpQ8iEQSPEpXNletRZ9XoE6m2fsZ+laMin+WiHibBrSgr173K/fGuk0Vw1k0oZ10DrottkQ84WBizZXNgMqmQCuXoLKbVJj+75LCGp3z6YwU2XiEXRZbcjyp2FU8LG6NLBZJq3BjnoiFppoFRG2QCqCBAbUCCKNXhCqPyxUmXTRmcusxWEwpTZPMgucGixaRgo56ta7Mp8R6SG3c1k6kvOyueIfWoiyw2DGgMTnX/WvVgbH2TEeYn1RNv5YbEdMAYrcKfFDU9gSzKwr5+KJMSuXR6MhCPRPd0x+U8wg8Spf6Ys426ZMSd1a5MuFCoVt9CgvJcdzMLnQ0bLDBtACMfldEjqM8Qg/BdfS4Fsq9glaaaN5B9/RU50qh2fY12V5kxZK+q/3Nr+Lb9Ks+x7RwivwgBNfO+D1CyDY9JsyvOlc5NMOax2tyAkd4VL5eFPqGh4YwYuY1vxd+oBN1ED72Ozva85BzSi+gJcPF8APZNgGaGTRa/Qxkf0nIEQw4XPOrxysQtVjxzfAqsyzLBqad1ZBm/ed0tzbqPVju17YCa6cKWHGiVZlPHgkcKP8CDSJN1CEG1gp7D5luov777Y3PS1jLOiCD2ZV+ZSy1fWBA8aH8M2taKyRJl2mFYqIAk657nKQa/QaIMmPDaTzGMKJGlXSyLySmkTxpkKNcl4OMDIc8NkYxhk/EJW95rXP+J8X/PNBD05wplBx0d3W0ujUSyT2zeFbTGb4M7ph0SgMEFgwP0ivfSjTh2+ChFvdU0BFz9WbBLr0lU20FYnunsQEdlmU1aMgC23+rG3KYnXwsK7xl+ZK7wcavgNYIjrpdSy5V0errT23OWv/XSjyBEIp8KN2yYpz59/p8Z90E7P67DqIO4XWKfkotiLkRxhblpbJpXynVP/rjreWXN0pNtpA6EeO6pPInpekv3/UAKyrRpI151znpA9qYqSXxV15sA==</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 NoccVersionCheck extends VNag {
protected $argSystemDir = null;
 
public function __construct() {
parent::__construct();
 
$this->registerExpectedStandardArguments('Vht');
 
$this->getHelpManager()->setPluginName('check_nocc_version');
$this->getHelpManager()->setVersion('1.0');
$this->getHelpManager()->setShortDescription('This plugin checks if a local NOCC 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, 'noccPath', 'The local directory where your NOCC installation is located.'));
}
 
protected function get_nocc_version($path) {
$path = realpath($path) === false ? $path : realpath($path);
 
$cont = @file_get_contents("$path/common.php");
 
if (!preg_match('@\$conf\->nocc_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('http://nocc.sourceforge.net/download/?lang=en');
if (!$cont) {
throw new Exception("Cannot access website with latest version");
}
 
if (!preg_match('@Download the current NOCC version <strong>(.+)</strong>@ismU', $cont, $m)) {
if (!preg_match('@/nocc\-(.+)\.tar\.gz"@ismU', $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 NOCC 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_nocc_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/nocc_version/check_nocc_version
0,0 → 1,20
#!/usr/bin/php
<?php /* <ViaThinkSoftSignature>K2/AEb5ko2ocYdyzMoVvaPV25g9LT8UY7lftmZzqH6DzSV918kgfNORcrZAYlmlFPd0hvMSXB5KcJvOLWVquVDtyZxtKwzZf+RyvtYMuwqqMbjTsoW2sECXzNkW9K+KPLnOITL/zNKSl2LJeaupA34o+xJGO2jwjBfGRMJz9qCq2+XBMW9ApzpCvRUMLIy6+WpaeQSJsHVMbcWduakEcGJQNAwLcvKDlcthcp5xslfMD/z3eB86rY5IFDDqvImvzlXOO9HD292o673ZbqSIIMZxINkGGRT7cO4sXWnBV1NSOb7Zx2EUVUn3IJR5RAB1r+7leZ2oNunAIh6Fivk8K2a35fNwkVPE4AVkVM+1JAiGnlWiWZ8T4mKw6l5k7GxsjO5oFOWpo0FS0Um9RzemIsQAGD8Ve2dNxLa/t/9rO0ADczUEFAZnffDG1ZH+VH4f9ls0yjp0YPUHfFYSGcC/WW4SyawqluoYbmQNEowzCIc25IKZTFYbqIWWj68RWZ9egfGP+EJ96XqhSrGUhK0fjNgujxO2uipnObGbpBclS4R8YFI/k+QkqcR8HeNG90dmNNrehFBTHz0W+CbY+RpUQf+fMp4PyiPPIPEE9rBnvzTYFSEyrcsq3ue9t2Lu2WiIe7Vuo3SHUyuiNiiRmNBJb4csJ2aHspL/5I0AXUl1aCnpFKIV1iXQUCcTfq6AGZXjG6RK/FEMSA0PdCMGaxHPpsZAZODURKGfMwCWbXnuZhhoKHshMx8PkZ0KkRKTGIy11U8kQze72qrWwhJN8hrx79ckBQ/UhL9OBjRI83jx1ESIlnIs6AwIER6oiSgkh7n0SiObUyK8ubZvSCv/cMQnWoAieQViRWARbcKPrPXuu1KHan8QDgoHubDehBf4KtQIAHU+dMVlglXZdAGamYZx+25RJ6Qoenh5G+X6xXN5l6neAPnETVfHI1n3/ZSuUfemu+KkTyS/9+4AuhrKIigcef0tIbn6DfqD//+encjTxi00eMGMzHHfcDfEKwwQF5ot0WXiRi5EkY6E5IARP7XmO6jxEwkBnM/trg97+oKxRO7dJBNJKZt/9sQt7AiWFWrUOsijXBH5Twvk0bJlA3yeaY13+08RtnvR15uNnAMj83QrnvmpXiAirkQ3Po642/PW2ofO8fyi8I+GhJb/ZAx6TcctW6rXgR47nfu2vLLOiRiioH7WGO3kyQYgeqCWf/G3KuivXQ1tjuuG4zTZ9UbbcqFJFD72VYjK37DKfURQdDM92wZPn85YErD4uXkZrPTNU6Ah5TmicM6LK8NcWGh2WdKSG5Uze3GHwOKv9vfhCN45TgS0tCgxBn93JES63XR6o1JhNewN3Q3WTchdsQNcIHQ==</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__ . '/NoccVersionCheck.class.php';
 
$job = new NoccVersionCheck();
$job->run();
unset($job);
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/plugins/nocc_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_nocc_version" {
command = [ "/daten/vnag/plugins/nocc_version/check_nocc_version" ]
 
arguments = {
"-d" = {
value = "$vnag_nocc_version_dir$"
description = "Location where the NOCC installation is located"
required = true
}
}
}
 
// Example usage:
//
// apply Service "example_website1_nocc_version" {
// import "generic-service"
// check_command = "vnag_nocc_version"
// vars = {
// vnag_nocc_version_dir = "/var/www/website1/nocc/"
// }
// assign where host.name == NodeName
// }
//
// apply Service "example_website2_nocc_version" {
// import "generic-service"
// check_command = "vnag_nocc_version"
// vars = {
// vnag_nocc_version_dir = "/var/www/website2/nocc/"
// }
// assign where host.name == NodeName
// }
//
// apply Service "example_website3_nocc_version" {
// import "generic-service"
// check_command = "vnag_nocc_version"
// vars = {
// vnag_nocc_version_dir = "/var/www/website3/nocc/"
// }
// assign where host.name == NodeName
// }