diff --git a/public_html/appmonitor/classes/appmonitor-client.class.php b/public_html/appmonitor/classes/appmonitor-client.class.php index ae2d3003900b206f50cf2187c23dee97bd6b90fa..d9b1d8bda9267c3de9e1e0c4c52cd2b076d255b8 100755 --- a/public_html/appmonitor/classes/appmonitor-client.class.php +++ b/public_html/appmonitor/classes/appmonitor-client.class.php @@ -48,8 +48,9 @@ if (!class_exists('appmonitorcheck')) { * 2025-03-04 0.154 axel.hahn@unibe.ch finish with exitcode instead of die() * 2025-03-17 0.155 axel.hahn@unibe.ch added: getVersion() and setVersion() * 2025-03-19 0.156 axel.hahn@unibe.ch added: validation rules for parameters in all checks + * 2025-03-24 0.157 axel.hahn@unibe.ch update validator for bool check in ini files * --------------------------------------------------------------------------------<br> - * @version 0.155 + * @version 0.157 * @author Axel Hahn * @link TODO * @license GPL @@ -63,7 +64,7 @@ class appmonitor * Name and Version number * @var string */ - protected string $_sVersion = '0.156'; + protected string $_sVersion = '0.157'; /** * config: default ttl for server before requesting the client check again diff --git a/public_html/appmonitor/classes/validateparam.class.php b/public_html/appmonitor/classes/validateparam.class.php index dfdf41d4667b8aa2698d5ba07fa0620f9a84c0af..a3e7c0060b270061f747a4850a20858f5495dfde 100644 --- a/public_html/appmonitor/classes/validateparam.class.php +++ b/public_html/appmonitor/classes/validateparam.class.php @@ -96,7 +96,10 @@ class validateparam break; case 'bool': if (!is_bool($value)) { - $sError .= "Value '$value' isn't a bool"; + // special case for bool after ini parsing + if(!$value==="" || !$value===1){ + $sError .= "Value '$value' isn't a bool"; + } } break; diff --git a/public_html/appmonitor/plugins/checks/cert.php b/public_html/appmonitor/plugins/checks/cert.php index 311e6d58c965a66fa4552ee365f9602e119bb6f7..864fe1034daa353735eb1be5d76ddc61e243e877 100755 --- a/public_html/appmonitor/plugins/checks/cert.php +++ b/public_html/appmonitor/plugins/checks/cert.php @@ -57,7 +57,7 @@ class checkCert extends appmonitorcheck 'url' => [ 'type' => 'string', 'required' => true, - 'description' => 'Url to check https://[server}[:{port}] or ssl://[server}[:{port}]', + 'description' => 'Url to check https://[server}[:{port}] or ssl://[server}[:{port}]; autodetected on webserver with php but required on cli', 'default' => null, 'regex'=>'/^(https|ssl):\/\/[^\s]+/', 'example' => '', @@ -86,6 +86,18 @@ class checkCert extends appmonitorcheck ], ]; + /** + * Override explain() + * If https is used, url is not required because it can be autodetected from $_SERVER + */ + public function explain(): array + { + if($_SERVER['HTTPS']??false && $_SERVER['SERVER_NAME']??false){ + $this->_aDoc['parameters']['url']['required']=false; + } + return $this->_aDoc; + } + /** * Get default group of this check * @return string