comment out metrics for now

This commit is contained in:
Grant Limberg 2024-05-09 12:52:57 -07:00
parent 219133a2c8
commit 06c634ab57
No known key found for this signature in database
GPG Key ID: 8F2F97D3BE8D7735
3 changed files with 43 additions and 43 deletions

View File

@ -3,25 +3,25 @@
namespace ZeroTier { namespace ZeroTier {
namespace Metrics { namespace Metrics {
prometheus::simpleapi::gauge_metric_t tcp_connections // prometheus::simpleapi::gauge_metric_t tcp_connections
{"tcp_connections", "TCP connections"}; // {"tcp_connections", "TCP connections"};
prometheus::simpleapi::counter_metric_t udp_open_failed // prometheus::simpleapi::counter_metric_t udp_open_failed
{"udp_open_failed", "UDP open failed"}; // {"udp_open_failed", "UDP open failed"};
prometheus::simpleapi::counter_metric_t tcp_opened // prometheus::simpleapi::counter_metric_t tcp_opened
{"tcp_opened", "TCP opened"}; // {"tcp_opened", "TCP opened"};
prometheus::simpleapi::counter_metric_t tcp_closed // prometheus::simpleapi::counter_metric_t tcp_closed
{"tcp_closed", "TCP closed"}; // {"tcp_closed", "TCP closed"};
prometheus::simpleapi::counter_metric_t tcp_bytes_in // prometheus::simpleapi::counter_metric_t tcp_bytes_in
{"tcp_byes_in", "TCP bytes in"}; // {"tcp_byes_in", "TCP bytes in"};
prometheus::simpleapi::counter_metric_t tcp_bytes_out // prometheus::simpleapi::counter_metric_t tcp_bytes_out
{"tcp_byes_out", "TCP bytes out"}; // {"tcp_byes_out", "TCP bytes out"};
prometheus::simpleapi::counter_metric_t udp_bytes_in // prometheus::simpleapi::counter_metric_t udp_bytes_in
{"udp_bytes_in", "UDP bytes in"}; // {"udp_bytes_in", "UDP bytes in"};
prometheus::simpleapi::counter_metric_t udp_bytes_out // prometheus::simpleapi::counter_metric_t udp_bytes_out
{"udp_bytes_out", "UDP bytes out"}; // {"udp_bytes_out", "UDP bytes out"};
} }
} }

View File

@ -5,18 +5,18 @@
namespace ZeroTier { namespace ZeroTier {
namespace Metrics { namespace Metrics {
extern prometheus::simpleapi::gauge_metric_t tcp_connections; // extern prometheus::simpleapi::gauge_metric_t tcp_connections;
extern prometheus::simpleapi::counter_metric_t udp_open_failed; // extern prometheus::simpleapi::counter_metric_t udp_open_failed;
extern prometheus::simpleapi::counter_metric_t tcp_opened; // extern prometheus::simpleapi::counter_metric_t tcp_opened;
extern prometheus::simpleapi::counter_metric_t tcp_closed; // extern prometheus::simpleapi::counter_metric_t tcp_closed;
extern prometheus::simpleapi::counter_metric_t tcp_bytes_in; // extern prometheus::simpleapi::counter_metric_t tcp_bytes_in;
extern prometheus::simpleapi::counter_metric_t tcp_bytes_out; // extern prometheus::simpleapi::counter_metric_t tcp_bytes_out;
extern prometheus::simpleapi::counter_metric_t udp_bytes_in; // extern prometheus::simpleapi::counter_metric_t udp_bytes_in;
extern prometheus::simpleapi::counter_metric_t udp_bytes_out; // extern prometheus::simpleapi::counter_metric_t udp_bytes_out;
} }
} }

View File

@ -130,7 +130,7 @@ struct TcpProxyService
if (!*uptr) if (!*uptr)
return; return;
if ((from->sa_family == AF_INET)&&(len >= 16)&&(len < 2048)) { if ((from->sa_family == AF_INET)&&(len >= 16)&&(len < 2048)) {
Metrics::udp_bytes_in += len; // Metrics::udp_bytes_in += len;
Client &c = *((Client *)*uptr); Client &c = *((Client *)*uptr);
c.lastActivity = time((time_t *)0); c.lastActivity = time((time_t *)0);
@ -176,7 +176,7 @@ struct TcpProxyService
Client &c = clients[sockN]; Client &c = clients[sockN];
PhySocket *udp = getUnusedUdp((void *)&c); PhySocket *udp = getUnusedUdp((void *)&c);
if (!udp) { if (!udp) {
Metrics::udp_open_failed++; // Metrics::udp_open_failed++;
phy->close(sockN); phy->close(sockN);
clients.erase(sockN); clients.erase(sockN);
printf("** TCP rejected, no more UDP ports to assign\n"); printf("** TCP rejected, no more UDP ports to assign\n");
@ -190,8 +190,8 @@ struct TcpProxyService
c.newVersion = false; c.newVersion = false;
*uptrN = (void *)&c; *uptrN = (void *)&c;
printf("<< TCP from %s -> %.16llx\n",inet_ntoa(reinterpret_cast<const struct sockaddr_in *>(from)->sin_addr),(unsigned long long)&c); printf("<< TCP from %s -> %.16llx\n",inet_ntoa(reinterpret_cast<const struct sockaddr_in *>(from)->sin_addr),(unsigned long long)&c);
Metrics::tcp_opened++; // Metrics::tcp_opened++;
Metrics::tcp_connections++; // Metrics::tcp_connections++;
} }
void phyOnTcpClose(PhySocket *sock,void **uptr) void phyOnTcpClose(PhySocket *sock,void **uptr)
@ -202,7 +202,7 @@ struct TcpProxyService
phy->close(c.udp); phy->close(c.udp);
clients.erase(sock); clients.erase(sock);
printf("** TCP %.16llx closed\n",(unsigned long long)*uptr); printf("** TCP %.16llx closed\n",(unsigned long long)*uptr);
Metrics::tcp_closed++; // Metrics::tcp_closed++;
} }
void phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len) void phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len)
@ -210,7 +210,7 @@ struct TcpProxyService
Client &c = *((Client *)*uptr); Client &c = *((Client *)*uptr);
c.lastActivity = time((time_t *)0); c.lastActivity = time((time_t *)0);
Metrics::tcp_bytes_in += len; // Metrics::tcp_bytes_in += len;
for(unsigned long i=0;i<len;++i) { for(unsigned long i=0;i<len;++i) {
if (c.tcpReadPtr >= sizeof(c.tcpReadBuf)) { if (c.tcpReadPtr >= sizeof(c.tcpReadBuf)) {
@ -257,7 +257,7 @@ struct TcpProxyService
if ((ntohs(dest.sin_port) > 1024)&&(payloadLen >= 16)) { if ((ntohs(dest.sin_port) > 1024)&&(payloadLen >= 16)) {
phy->udpSend(c.udp,(const struct sockaddr *)&dest,payload,payloadLen); phy->udpSend(c.udp,(const struct sockaddr *)&dest,payload,payloadLen);
printf(">> TCP %.16llx to %s:%d\n",(unsigned long long)*uptr,inet_ntoa(dest.sin_addr),(int)ntohs(dest.sin_port)); printf(">> TCP %.16llx to %s:%d\n",(unsigned long long)*uptr,inet_ntoa(dest.sin_addr),(int)ntohs(dest.sin_port));
Metrics::udp_bytes_out += payloadLen; // Metrics::udp_bytes_out += payloadLen;
} }
} }
@ -273,7 +273,7 @@ struct TcpProxyService
if (c.tcpWritePtr) { if (c.tcpWritePtr) {
long n = phy->streamSend(sock,c.tcpWriteBuf,c.tcpWritePtr); long n = phy->streamSend(sock,c.tcpWriteBuf,c.tcpWritePtr);
if (n > 0) { if (n > 0) {
Metrics::tcp_bytes_out += n; // Metrics::tcp_bytes_out += n;
memmove(c.tcpWriteBuf,c.tcpWriteBuf + n,c.tcpWritePtr -= (unsigned long)n); memmove(c.tcpWriteBuf,c.tcpWriteBuf + n,c.tcpWritePtr -= (unsigned long)n);
if (!c.tcpWritePtr) if (!c.tcpWritePtr)
phy->setNotifyWritable(sock,false); phy->setNotifyWritable(sock,false);
@ -293,8 +293,8 @@ struct TcpProxyService
} }
for(std::vector<PhySocket *>::iterator s(toClose.begin());s!=toClose.end();++s) { for(std::vector<PhySocket *>::iterator s(toClose.begin());s!=toClose.end();++s) {
phy->close(*s); phy->close(*s);
Metrics::tcp_closed++; // Metrics::tcp_closed++;
Metrics::tcp_connections--; // Metrics::tcp_connections--;
} }
} }
}; };
@ -305,16 +305,16 @@ int main(int argc,char **argv)
signal(SIGHUP,SIG_IGN); signal(SIGHUP,SIG_IGN);
srand(time((time_t *)0)); srand(time((time_t *)0));
if (!OSUtils::fileExists(HOMEDIR)) { // if (!OSUtils::fileExists(HOMEDIR)) {
if (!OSUtils::mkdir(HOMEDIR)) { // if (!OSUtils::mkdir(HOMEDIR)) {
fprintf(stderr,"%s: fatal error: unable to create %s\n",argv[0],HOMEDIR); // fprintf(stderr,"%s: fatal error: unable to create %s\n",argv[0],HOMEDIR);
return 1; // return 1;
} // }
} // }
prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr); // prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5)); // prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5));
prometheus::simpleapi::saver.set_out_file(HOMEDIR "/metrics.json"); // prometheus::simpleapi::saver.set_out_file(HOMEDIR "/metrics.json");
TcpProxyService svc; TcpProxyService svc;
Phy<TcpProxyService *> phy(&svc,false,true); Phy<TcpProxyService *> phy(&svc,false,true);