From 6655f990b02390d89016db4cc9a30648160b3b9c Mon Sep 17 00:00:00 2001 From: Pepijn Over Date: Sat, 12 Apr 2014 11:55:41 +0200 Subject: [PATCH] issue #59: Warning threshold ignored for notification trigger --- CHANGELOG.rst | 109 ++++++++++--------- src/psm/Util/Updater/Autorun.class.php | 2 +- src/psm/Util/Updater/StatusUpdater.class.php | 8 +- 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 27260688..5809e6b6 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,87 +4,88 @@ Changelog not yet released ---------------- - * #57: Added Chinese translation. - * Sphinx is now used for documentation . - * #58: Server order on users page now matches the order on servers page. +* #57: Added Chinese translation. +* #58: Server order on users page now matches the order on servers page. +* #59: Warning threshold ignored for notification trigger. +* Sphinx is now used for documentation . v3.0.0 (released April 6, 2014) ------------------------------- - * New module structure (not backwards compatible). - * Added user login system with 2 user levels (administrator and regular user). - * Added warning threshold option (set number of failed checks before server goes offline). - * Added SMTP support. - * Adding Bulgarian language file. - * Added history tracking of server uptime. - * Added history graphs of server uptime and latency. - * Added user profile page. - * Status page is now default homepage. - * Updated translations. - * Date and time formats are taken from language file and localized per language. - * When checking a website, the updater will now follow 302 Location headers. - * String/pattern search on websites did not work for websites with compression turned on. - * The monitor now uses a custom user agent so it can be identified in access logs (Mozilla/5.0 (compatible; phpservermon/version; +http://www.phpservermonitor.org)). - * Improved mobile compatibility. - * Template directory restructured to correspond with module structure. - * Switched from mysql_* to PDO. - * Updated PHPMailer package to v5.2.6. - * Fixed several XSS vulnerabilities. - * Project website updated to +* New module structure (not backwards compatible). +* Added user login system with 2 user levels (administrator and regular user). +* Added warning threshold option (set number of failed checks before server goes offline). +* Added SMTP support. +* Adding Bulgarian language file. +* Added history tracking of server uptime. +* Added history graphs of server uptime and latency. +* Added user profile page. +* Status page is now default homepage. +* Updated translations. +* Date and time formats are taken from language file and localized per language. +* When checking a website, the updater will now follow 302 Location headers. +* String/pattern search on websites did not work for websites with compression turned on. +* The monitor now uses a custom user agent so it can be identified in access logs (Mozilla/5.0 (compatible; phpservermon/version; +http://www.phpservermonitor.org)). +* Improved mobile compatibility. +* Template directory restructured to correspond with module structure. +* Switched from mysql_* to PDO. +* Updated PHPMailer package to v5.2.6. +* Fixed several XSS vulnerabilities. +* Project website updated to v2.1.0 (released February 8, 2014) ---------------------------------- - * PHP 5.3+ required - * Merged PHP Server Monitor Plus project by Luiz Alberto S. Ribeiro (). - * New layout - * New install module. - * Regex search on website has been added. - * Support for mosms provider. - * Support for Textmarketer provider. - * Language files are now automatically detected, instead of a hardcoded list. - * Adding Korean language file. - * Adding Portuguese / Brazilian language file. - * Large status page. - * New config file (see install instructions in README). - * Cronjob will be prevented from running multiple times at the same time (with a 10 mins timeout). +* PHP 5.3+ required +* Merged PHP Server Monitor Plus project by Luiz Alberto S. Ribeiro (). +* New layout +* New install module. +* Regex search on website has been added. +* Support for mosms provider. +* Support for Textmarketer provider. +* Language files are now automatically detected, instead of a hardcoded list. +* Adding Korean language file. +* Adding Portuguese / Brazilian language file. +* Large status page. +* New config file (see install instructions in README). +* Cronjob will be prevented from running multiple times at the same time (with a 10 mins timeout). v2.0.1 (released October 29, 2011) ---------------------------------- - * Adding German language file. - * Adding French language file. - * classes/sm/smUpdaterStatus.class.php: the curl option CURLOPT_CUSTOMREQUEST has been changed to CURLOPT_NOBODY. - * Servers page: auto refresh can be configured at the config page. - * Servers page: if the server is a website, the "Domain/Ip" field will be a link to the website. - * New text message gateway: Clickatell.com. - * If cURL is not installed, the install.php script will throw an error. - * HTTP status codes 5xx will also be treated as error. +* Adding German language file. +* Adding French language file. +* classes/sm/smUpdaterStatus.class.php: the curl option CURLOPT_CUSTOMREQUEST has been changed to CURLOPT_NOBODY. +* Servers page: auto refresh can be configured at the config page. +* Servers page: if the server is a website, the "Domain/Ip" field will be a link to the website. +* New text message gateway: Clickatell.com. +* If cURL is not installed, the install.php script will throw an error. +* HTTP status codes 5xx will also be treated as error. v2.0.0 (released October 19, 2009) ---------------------------------- - * Server type ("service" or "website"). - * Different types of notification. - * New text message gateways. - * Code rewrite. - * New layout. - * Check for updates function. +* Server type ("service" or "website"). +* Different types of notification. +* New text message gateways. +* Code rewrite. +* New layout. +* Check for updates function. v1.0.1 (released September 18, 2008) ------------------------------------ - * log.php - * tpl/log.tpl.html - * Select order by clause used datetime field after DATE_FORMAT had been performed, resulting in a wrong list of log entries shown. +* log.php +* tpl/log.tpl.html +* Select order by clause used datetime field after DATE_FORMAT had been performed, resulting in a wrong list of log entries shown. v1.0.0 (released July 16, 2008) ------------------------------- - * Initial release +* Initial release diff --git a/src/psm/Util/Updater/Autorun.class.php b/src/psm/Util/Updater/Autorun.class.php index 9dfb0902..681456e1 100644 --- a/src/psm/Util/Updater/Autorun.class.php +++ b/src/psm/Util/Updater/Autorun.class.php @@ -89,7 +89,7 @@ class Autorun { // notify the nerds if applicable $notifier->notify($server['server_id'], $status_old, $status_new); - // clean-up time!! archive all records older than 1 month + // clean-up time!! archive all records older than 1 week $archiver->archive($server['server_id'], $cleanup_date); } } diff --git a/src/psm/Util/Updater/StatusUpdater.class.php b/src/psm/Util/Updater/StatusUpdater.class.php index 3963b06e..dacd784a 100644 --- a/src/psm/Util/Updater/StatusUpdater.class.php +++ b/src/psm/Util/Updater/StatusUpdater.class.php @@ -67,6 +67,8 @@ class StatusUpdater { * The function its all about. This one checks whether the given ip and port are up and running! * If the server check fails it will try one more time, depending on the $max_runs. * + * Please note: if the server is down but has not met the warning threshold, this will return true + * to avoid any "we are down" events. * @param int $server_id * @param int $max_runs how many times should the script recheck the server if unavailable. default is 2 * @return boolean TRUE if server is up, FALSE otherwise @@ -102,6 +104,10 @@ class StatusUpdater { 'rtime' => $this->rtime, ); + // log the uptime before checking the warning threshold, + // so that the warnings can still be reviewed in the server history. + psm_log_uptime($this->server_id, (int) $this->status_new, $this->rtime); + if($this->status_new == true) { // if the server is on, add the last_online value and reset the error threshold counter $save['status'] = 'on'; @@ -115,13 +121,13 @@ class StatusUpdater { // the server is offline but the error threshold has not been met yet. // so we are going to leave the status "on" for now while we are in a sort of warning state.. $save['status'] = 'on'; + $this->status_new = true; } else { $save['status'] = 'off'; } } $this->db->save(PSM_DB_PREFIX . 'servers', $save, array('server_id' => $this->server_id)); - psm_log_uptime($this->server_id, (int) $this->status_new, $this->rtime); return $this->status_new;