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