Open dnsmichi opened 6 years ago
Logging would also help with HTTP-Requests fired against the Icinga 2 API. For now, I've added own hacks to extract the specific requests and to analyse and fix icinga/icinga2#6635.
@@ -171,6 +171,9 @@ class RestApiClient
curl_setopt_array($curl, $opts);
// TODO: request headers, validate status code
+ var_dump(curl_getinfo($curl));
+ var_dump($body);
+ //die();
Benchmark::measure('Rest Api, sending ' . $url);
$res = curl_exec($curl);
if ($res === false) {
@@ -184,6 +187,8 @@ class RestApiClient
);
}
+ var_dump("Success");
+
Benchmark::measure('Rest Api, got response');
if ($stream) {
array(26) {
["url"]=>
string(70) "https://icinga2.vagrant.demo.icinga.com:5665/v1/console/execute-script"
["content_type"]=>
string(16) "application/json"
["http_code"]=>
int(200)
["header_size"]=>
int(115)
["request_size"]=>
int(306)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0.00096)
["namelookup_time"]=>
float(1.9E-5)
["connect_time"]=>
float(1.9E-5)
["pretransfer_time"]=>
float(9.9E-5)
["size_upload"]=>
float(97)
["size_download"]=>
float(370)
["speed_download"]=>
float(385416)
["speed_upload"]=>
float(101041)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(97)
["starttransfer_time"]=>
float(0.000943)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(9) "127.0.0.1"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(5665)
["local_ip"]=>
string(9) "127.0.0.1"
["local_port"]=>
int(42956)
}
string(214) "{"command":"var constants = [];\nfor (k => v in globals) {\n if (typeof(v) in [String, Number, Boolean]) {\n res = { name = k, value = v }\n constants.add({name = k, value = v})\n }\n};\nconstants\n"}"
Expected Behavior
The specific steps are logged if requested by the caller, either with
--verbose
or--debug
.Current Behavior
Nothing is logged which makes it hard to analyse upon failure. Tracing the requests in the icinga2.log or via tcpdump isn't enough.
I was testing and analysing icinga/icinga2#6248
Possible Solution
Add logger calls for specific steps.
Your Environment
icinga2 --version
): HEAD, v2.8.4-815-gac6afadb5