issue #59: Warning threshold ignored for notification trigger

This commit is contained in:
Pepijn Over 2014-04-12 11:55:41 +02:00
parent 1da008b3b4
commit 6655f990b0
3 changed files with 63 additions and 56 deletions

View File

@ -4,87 +4,88 @@ Changelog
not yet released
----------------
* #57: Added Chinese translation.
* Sphinx is now used for documentation <http://sphinx.pocoo.org/>.
* #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 <http://sphinx.pocoo.org/>.
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 <http://www.phpservermonitor.org>
* 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 <http://www.phpservermonitor.org>
v2.1.0 (released February 8, 2014)
----------------------------------
* PHP 5.3+ required
* Merged PHP Server Monitor Plus project by Luiz Alberto S. Ribeiro (<https://github.com/madeinnordeste/PHP-Server-Monitor-Plus>).
* 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 (<https://github.com/madeinnordeste/PHP-Server-Monitor-Plus>).
* 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

View File

@ -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);
}
}

View File

@ -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;