diff --git a/Dockerfile b/Dockerfile index e94f234..e78162e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM debian:buster as builder MAINTAINER cppla https://cpp.la -RUN apt-get update -y && apt-get -y install gcc g++ make +RUN apt-get update -y && apt-get -y install gcc g++ make libcurl4-openssl-dev COPY . . diff --git a/server/Makefile b/server/Makefile index 3ca07ff..1c777f0 100644 --- a/server/Makefile +++ b/server/Makefile @@ -26,7 +26,7 @@ $(ODIR)/%.o: $(SDIR)/%.cpp $(CXX) -c $(INC) $(CXXFLAGS) $< -o $@ $(OUT): $(OBJS) - $(CXX) $(LIBS) $^ -o $(OUT) + $(CXX) $(LIBS) $^ -o $(OUT) -lcurl .PHONY: clean diff --git a/server/src/main.cpp b/server/src/main.cpp index 02dcd75..87f9afe 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -8,6 +8,7 @@ #include "server.h" #include "main.h" #include "exprtk.hpp" +#include "curl/curl.h" #if defined(CONF_FAMILY_UNIX) #include <signal.h> @@ -321,6 +322,22 @@ void CMain::WatchdogMessage(int ClientNetID, double load_1, double load_5, doubl printf("node info: %s\n\n", Client(ClientID)->m_aLocation); printf("watchdog name: %s\n", Watchdog(ID)->m_aName); printf("watchdog rule: %s\n", Watchdog(ID)->m_aRule); + CURL *curl; + CURLcode res; + + curl_global_init(CURL_GLOBAL_ALL); + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://cpp.la"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl"); + res = curl_easy_perform(curl); + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + curl_easy_cleanup(curl); + } + curl_global_cleanup(); } } ID++;