set a home directory for stats output

This commit is contained in:
Grant Limberg 2024-05-06 19:21:30 -07:00
parent 342657e629
commit 161ed18e48
No known key found for this signature in database
GPG Key ID: 8F2F97D3BE8D7735
2 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -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;
/*
@ -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;