Skip to content

Commit

Permalink
set a home directory for stats output
Browse files Browse the repository at this point in the history
  • Loading branch information
glimberg committed May 7, 2024
1 parent 342657e commit 161ed18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tcp-proxy/Makefile
@@ -1,9 +1,10 @@
CXX=$(shell which clang++ g++ c++ 2>/dev/null | head -n 1)

INCLUDES?=-isystem ../ext/prometheus-cpp-lite-1.0/core/include -isystem ../ext/prometheus-cpp-lite-1.0/simpleapi/include
INCLUDES?=-isystem ../ext/prometheus-cpp-lite-1.0/core/include -isystem ../ext/prometheus-cpp-lite-1.0/simpleapi/include -isystem ../ext/

OBJS=Metrics.o \
../node/Metrics.o
../node/Metrics.o \
../osdep/OSUtils.o

CXXFLAGS=-O3 -fno-rtti $(INCLUDES) -std=c++17 -pthread -frtti

Expand Down
14 changes: 14 additions & 0 deletions tcp-proxy/tcp-proxy.cpp
Expand Up @@ -42,12 +42,15 @@
#include <vector>

#include "../osdep/Phy.hpp"
#include "../osdep/OSUtils.hpp"

#include "Metrics.hpp"

#define ZT_TCP_PROXY_CONNECTION_TIMEOUT_SECONDS 300
#define ZT_TCP_PROXY_TCP_PORT 443

#define HOMEDIR "/var/lib/zt-tcp-proxy"

using namespace ZeroTier;

/*
Expand Down Expand Up @@ -300,6 +303,17 @@ int main(int argc,char **argv)
signal(SIGHUP,SIG_IGN);
srand(time((time_t *)0));

if (!OSUtils::fileExists(HOMEDIR)) {
if (!OSUtils::mkdir(HOMEDIR)) {
fprintf(stderr,"%s: fatal error: unable to create %s\n",argv[0],HOMEDIR);
return 1;
}
}

prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5));
prometheus::simpleapi::saver.set_out_file(HOMEDIR "/metrics.json");

TcpProxyService svc;
Phy<TcpProxyService *> phy(&svc,false,true);
svc.phy = &phy;
Expand Down

0 comments on commit 161ed18

Please sign in to comment.