issue #109: finishing custom timeout per server (slight changes from pull request)
parent
7a061832ec
commit
254b281237
|
@ -16,6 +16,7 @@ not yet released
|
|||
* #105: Fixing check for websites with unverified SSL certificates.
|
||||
* #107: Fixing update job for Synology DSM Task Scheduler.
|
||||
* #108: URLs on Windows contained both back- and forward slashes.
|
||||
* #109: Custom time-out per server.
|
||||
* #111: Generated urls for non-default ports included the port twice.
|
||||
* #110: Support for SMSGlobal SMS gateway <https://www.smsglobal.com/>.
|
||||
* Support for Danish SMS provider Smsit <http://www.smsit.dk/>
|
||||
|
|
|
@ -50,6 +50,10 @@ The following people have contributed to the development of PHP Server Monitor:
|
|||
|
||||
* SMSGlobal SMS gateway
|
||||
|
||||
* Julien Lebouteiller <https://github.com/Halvra>
|
||||
|
||||
* Custom time-out per server
|
||||
|
||||
|
||||
Translators
|
||||
+++++++++++
|
||||
|
|
|
@ -263,11 +263,13 @@ function psm_parse_msg($status, $type, $vars) {
|
|||
* @param string $href
|
||||
* @param boolean $header return headers?
|
||||
* @param boolean $body return body?
|
||||
* @param int $timeout connection timeout in seconds
|
||||
* @param int $timeout connection timeout in seconds. defaults to PSM_CURL_TIMEOUT (10 secs).
|
||||
* @param boolean $add_agent add user agent?
|
||||
* @return string cURL result
|
||||
*/
|
||||
function psm_curl_get($href, $header = false, $body = true, $timeout = 10, $add_agent = true) {
|
||||
function psm_curl_get($href, $header = false, $body = true, $timeout = null, $add_agent = true) {
|
||||
$timeout = $timeout == null ? PSM_CURL_TIMEOUT : intval($timeout);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_HEADER, $header);
|
||||
curl_setopt($ch, CURLOPT_NOBODY, (!$body));
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
/**
|
||||
* Current PSM version
|
||||
*/
|
||||
define('PSM_VERSION', '3.1.1-dev');
|
||||
define('PSM_VERSION', '3.1.0-dev');
|
||||
|
||||
/**
|
||||
* URL to check for updates. Will not be checked if turned off on config page.
|
||||
|
@ -96,3 +96,8 @@ define('PSM_LOGIN_RESET_RUNTIME', 3600);
|
|||
* Number of seconds the cron is supposedly dead and we will run another cron anyway.
|
||||
*/
|
||||
define('PSM_CRON_TIMEOUT', 600);
|
||||
|
||||
/**
|
||||
* Default timeout in seconds for curl requests (can be overwritten per-server).
|
||||
*/
|
||||
define('PSM_CURL_TIMEOUT', 10);
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Статус',
|
||||
'label' => 'Име',
|
||||
'domain' => 'Хост',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Порт',
|
||||
'type' => 'Тип',
|
||||
'type_website' => 'Сайт',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Label',
|
||||
'domain' => 'Domæne/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Port',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Hjemmeside',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Beschriftung',
|
||||
'domain' => 'Domain/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Port',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -112,6 +112,7 @@ $sm_lang = array(
|
|||
'label' => 'Label',
|
||||
'domain' => 'Domain/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Port',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Titulo',
|
||||
'domain' => 'Domain/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Port',
|
||||
'type' => 'Tipo',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -112,6 +112,7 @@ $sm_lang = array(
|
|||
'label' => 'Nom',
|
||||
'domain' => 'Domaine/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Port',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Site Web',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Nome',
|
||||
'domain' => 'Dominio/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Porta',
|
||||
'type' => 'Tipo',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Label',
|
||||
'domain' => 'Domain/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Port',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Label',
|
||||
'domain' => 'Domein/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Aantal seconden te wachten op een reactie van de server.',
|
||||
'port' => 'Poort',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Status',
|
||||
'label' => 'Etiqueta',
|
||||
'domain' => 'Domínio/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Porta',
|
||||
'type' => 'Tipo',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => 'Статус',
|
||||
'label' => 'Лейбл',
|
||||
'domain' => 'Домен/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => 'Порт',
|
||||
'type' => 'Тип',
|
||||
'type_website' => 'Веб-сайт',
|
||||
|
|
|
@ -111,6 +111,8 @@ $sm_lang = array(
|
|||
'status' => '状态',
|
||||
'label' => '标签',
|
||||
'domain' => '域名/IP',
|
||||
'timeout' => 'Timeout',
|
||||
'timeout_description' => 'Number of seconds to wait for the server to respond.',
|
||||
'port' => '端口',
|
||||
'type' => '类型',
|
||||
'type_website' => '网站',
|
||||
|
|
|
@ -113,6 +113,7 @@ abstract class AbstractServerController extends AbstractController {
|
|||
|
||||
$server['error'] = htmlentities($server['error']);
|
||||
$server['type'] = psm_get_lang('servers', 'type_' . $server['type']);
|
||||
$server['timeout'] = ($server['timeout'] > 0) ? $server['timeout'] : PSM_CURL_TIMEOUT;
|
||||
|
||||
return $server;
|
||||
}
|
||||
|
|
|
@ -191,6 +191,7 @@ class ServerController extends AbstractServerController {
|
|||
'edit_value_ip' => $edit_server['ip'],
|
||||
'edit_value_port' => $edit_server['port'],
|
||||
'edit_value_timeout' => $edit_server['timeout'],
|
||||
'default_value_timeout' => PSM_CURL_TIMEOUT,
|
||||
'edit_value_pattern' => $edit_server['pattern'],
|
||||
'edit_value_warning_threshold' => $edit_server['warning_threshold'],
|
||||
'edit_type_selected_' . $edit_server['type'] => 'selected="selected"',
|
||||
|
@ -217,7 +218,7 @@ class ServerController extends AbstractServerController {
|
|||
$clean = array(
|
||||
'label' => trim(strip_tags(psm_POST('label', ''))),
|
||||
'ip' => trim(strip_tags(psm_POST('ip', ''))),
|
||||
'timeout' => intval(psm_POST('timeout', 0)),
|
||||
'timeout' => (isset($_POST['timeout']) && intval($_POST['timeout']) > 0) ? intval($_POST['timeout']) : null,
|
||||
'port' => intval(psm_POST('port', 0)),
|
||||
'type' => psm_POST('type', ''),
|
||||
'pattern' => psm_POST('pattern', ''),
|
||||
|
@ -365,6 +366,7 @@ class ServerController extends AbstractServerController {
|
|||
'label_status' => psm_get_lang('servers', 'status'),
|
||||
'label_domain' => psm_get_lang('servers', 'domain'),
|
||||
'label_timeout' => psm_get_lang('servers', 'timeout'),
|
||||
'label_timeout_description' => psm_get_lang('servers', 'timeout_description'),
|
||||
'label_port' => psm_get_lang('servers', 'port'),
|
||||
'label_type' => psm_get_lang('servers', 'type'),
|
||||
'label_website' => psm_get_lang('servers', 'type_website'),
|
||||
|
|
|
@ -78,7 +78,7 @@ class Installer {
|
|||
|
||||
// different DB version, check if the version requires any changes
|
||||
// @todo this is currently a manual check for each version, similar to upgrade().. not a clean way
|
||||
if(version_compare($version_db, '3.1.1', '<')) {
|
||||
if(version_compare($version_db, '3.1.0', '<')) {
|
||||
return true;
|
||||
} else {
|
||||
// change database version to current version so this check won't be required next time
|
||||
|
@ -218,7 +218,7 @@ class Installer {
|
|||
`sms` enum('yes','no') NOT NULL default 'no',
|
||||
`warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1',
|
||||
`warning_threshold_counter` mediumint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`timeout` int(1) NOT NULL DEFAULT '10',
|
||||
`timeout` smallint(1) unsigned NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`server_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
PSM_DB_PREFIX . 'servers_uptime' => "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "servers_uptime` (
|
||||
|
@ -275,10 +275,6 @@ class Installer {
|
|||
// upgrade to 3.1.0
|
||||
$this->upgrade310();
|
||||
}
|
||||
if(version_compare($version_from, '3.1.1', '<')) {
|
||||
// upgrade to 3.1.1
|
||||
$this->upgrade311();
|
||||
}
|
||||
psm_update_conf('version', $version_to);
|
||||
}
|
||||
|
||||
|
@ -402,12 +398,7 @@ class Installer {
|
|||
`value` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`user_id`, `key`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
|
||||
$this->execSQL($queries);
|
||||
}
|
||||
|
||||
protected function upgrade311() {
|
||||
$queries = array();
|
||||
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` INT( 1 ) NOT NULL DEFAULT '10';";
|
||||
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` smallint(1) unsigned NULL DEFAULT NULL;";
|
||||
$this->execSQL($queries);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,12 +92,6 @@
|
|||
<input type="text" id="ip" name="ip" value="{edit_value_ip}" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="timeout">{label_timeout}</label>
|
||||
<div class="controls">
|
||||
<input class="input-mini" type="text" id="timeout" name="timeout" value="{edit_value_timeout}" maxlength="10" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="type">{label_type}</label>
|
||||
<div class="controls">
|
||||
|
@ -152,6 +146,12 @@
|
|||
<input class="input-mini" type="text" id="warning_threshold" name="warning_threshold" value="{edit_value_warning_threshold}" maxlength="5" data-toggle="tooltip" title="{label_warning_threshold_description}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="timeout">{label_timeout}</label>
|
||||
<div class="controls">
|
||||
<input class="input-mini" type="text" id="timeout" name="timeout" value="{edit_value_timeout}" placeholder="{default_value_timeout}" maxlength="10" data-toggle="tooltip" title="{label_timeout_description}" /> s
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button class="btn btn-success" type="submit">{label_save}</button>
|
||||
<a class="btn" href="{url_go_back}" >{label_go_back}</a>
|
||||
|
|
|
@ -39,10 +39,6 @@
|
|||
<td>{label_domain}:</td>
|
||||
<td>{ip}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{label_timeout}:</td>
|
||||
<td>{timeout}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{label_port}:</td>
|
||||
<td>{port}</td>
|
||||
|
@ -71,6 +67,10 @@
|
|||
<td>{label_sms}:</td>
|
||||
<td>{sms}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{label_timeout}:</td>
|
||||
<td>{timeout} s</td>
|
||||
</tr>
|
||||
{html_actions}
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue