diff --git a/src/Extension/MokoWaaS.php b/src/Extension/MokoWaaS.php index 025ef81c..88cc520f 100644 --- a/src/Extension/MokoWaaS.php +++ b/src/Extension/MokoWaaS.php @@ -1641,6 +1641,7 @@ class MokoWaaS extends CMSPlugin curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if ($data !== null) { diff --git a/src/script.php b/src/script.php index ab8f926d..231800ac 100644 --- a/src/script.php +++ b/src/script.php @@ -839,10 +839,20 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface curl_setopt($ch, CURLOPT_POSTFIELDS, $dsPayload); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + $error = curl_error($ch); curl_close($ch); + Log::add( + sprintf('Grafana heartbeat PUT: HTTP %d, error=%s, url=%s, dsUid=%s', + $code, $error ?: 'none', $grafanaUrl, $dsUid), + Log::INFO, + 'mokowaas' + ); + if ($code === 404) { $ch = curl_init($grafanaUrl . '/api/datasources'); @@ -850,14 +860,25 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $dsPayload); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 15); - curl_exec($ch); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + $response2 = curl_exec($ch); + $code2 = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + $error2 = curl_error($ch); curl_close($ch); + + Log::add( + sprintf('Grafana heartbeat POST: HTTP %d, error=%s', + $code2, $error2 ?: 'none'), + Log::INFO, + 'mokowaas' + ); } Log::add( - 'Health endpoint provisioned with Grafana on ' - . ($code === 200 ? 'update' : 'install'), + sprintf('Grafana heartbeat result: %s (site=%s)', + $code === 200 ? 'updated' : 'created', $siteUrl), Log::INFO, 'mokowaas' );