From 64e098379310b90824b12c4fe853e80c4a07ff3a Mon Sep 17 00:00:00 2001 From: Simon Baumer Date: Thu, 29 Aug 2024 11:35:11 +0200 Subject: [PATCH] Query a URL --- collector/lib/CollectorService.cpp | 18 ++++++++++++++++++ collector/lib/CollectorService.h | 2 ++ pod.yaml | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 pod.yaml diff --git a/collector/lib/CollectorService.cpp b/collector/lib/CollectorService.cpp index 4b41300d9d..61970005c2 100644 --- a/collector/lib/CollectorService.cpp +++ b/collector/lib/CollectorService.cpp @@ -23,6 +23,7 @@ extern "C" { #include "Utility.h" #include "prometheus/exposer.h" #include "system-inspector/Service.h" +#include "curl/curl.h" extern unsigned char g_bpf_drop_syscalls[]; // defined in libscap @@ -65,6 +66,9 @@ void CollectorService::RunForever() { std::unique_ptr network_status_inspector; CLOG(INFO) << "Network scrape interval set to " << config_.ScrapeInterval() << " seconds"; + + CLOG(INFO) << "HALLO DMITRII"; + CollectorService::QueryKubelet(); if (config_.grpc_channel) { CLOG(INFO) << "Waiting for Sensor to become ready ..."; @@ -138,6 +142,20 @@ void CollectorService::RunForever() { system_inspector_.CleanUp(); } +void CollectorService::QueryKubelet() { + CLOG(INFO) << "Query Kubelet Example"; + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + if (res) { + CLOG(INFO) << printf("response: %d\n", res); + } + } +} + bool CollectorService::InitKernel() { return system_inspector_.InitKernel(config_); } diff --git a/collector/lib/CollectorService.h b/collector/lib/CollectorService.h index f52c644934..2c8236a87e 100644 --- a/collector/lib/CollectorService.h +++ b/collector/lib/CollectorService.h @@ -24,6 +24,8 @@ class CollectorService { const std::atomic& signum_; system_inspector::Service system_inspector_; + + void QueryKubelet(); }; bool SetupKernelDriver(CollectorService& collector, const std::string& GRPCServer, const CollectorConfig& config); diff --git a/pod.yaml b/pod.yaml new file mode 100644 index 0000000000..d7213ef3e7 --- /dev/null +++ b/pod.yaml @@ -0,0 +1,28 @@ +version: "3.9" +services: + collector: + image: quay.io/stackrox-io/collector:3.19.x-61-g18fbe6077a-dirty + container_name: collector-debug + network_mode: host + privileged: true + environment: + - GRPC_SERVER=localhost:9999 + - COLLECTOR_CONFIG={"logLevel":"info","turnOffScrape":true,"scrapeInterval":2} + - COLLECTION_METHOD=core-bpf + - COLLECTOR_HOST_ROOT=/host + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock:ro + - /proc:/host/proc:ro + - /etc:/host/etc:ro + - /usr/lib:/host/usr/lib:ro + - /sys/:/host/sys/:ro + - /dev:/host/dev:ro + depends_on: + - grpc-server-debug + grpc-server-debug: + image: quay.io/rhacs-eng/grpc-server:4.3.8 + container_name: grpc-server + network_mode: host + user: 1000:1000 + volumes: + - /tmp:/tmp:rw