mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-31 00:23:58 +00:00
testing out a labled gauge on Networks
This commit is contained in:
parent
bd8f048bef
commit
499ed6d95e
@ -538,19 +538,29 @@ static _doZtFilterResult _doZtFilter(
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
std::string nwid_printf(int64_t id) {
|
||||||
|
char out[32] = {};
|
||||||
|
sprintf(out, "%.16llx", id);
|
||||||
|
return std::string(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
prometheus::simpleapi::gauge_family_t multicastGroupsFamily{"network_multicast_groups", "number of joined multicast groups"};
|
||||||
|
|
||||||
const ZeroTier::MulticastGroup Network::BROADCAST(ZeroTier::MAC(0xffffffffffffULL),0);
|
const ZeroTier::MulticastGroup Network::BROADCAST(ZeroTier::MAC(0xffffffffffffULL),0);
|
||||||
|
|
||||||
Network::Network(const RuntimeEnvironment *renv,void *tPtr,uint64_t nwid,void *uptr,const NetworkConfig *nconf) :
|
Network::Network(const RuntimeEnvironment *renv,void *tPtr,uint64_t nwid,void *uptr,const NetworkConfig *nconf)
|
||||||
RR(renv),
|
: RR(renv)
|
||||||
_uPtr(uptr),
|
, _uPtr(uptr)
|
||||||
_id(nwid),
|
, _id(nwid)
|
||||||
_lastAnnouncedMulticastGroupsUpstream(0),
|
, _lastAnnouncedMulticastGroupsUpstream(0)
|
||||||
_mac(renv->identity.address(),nwid),
|
, _mac(renv->identity.address(),nwid)
|
||||||
_portInitialized(false),
|
, _portInitialized(false)
|
||||||
_lastConfigUpdate(0),
|
, _lastConfigUpdate(0)
|
||||||
_destroyed(false),
|
, _destroyed(false)
|
||||||
_netconfFailure(NETCONF_FAILURE_NONE),
|
, _netconfFailure(NETCONF_FAILURE_NONE)
|
||||||
_portError(0)
|
, _portError(0)
|
||||||
|
, _multicast_groups_gauge{multicastGroupsFamily.Add({{"networkId", nwid_printf(_id).c_str()}})}
|
||||||
{
|
{
|
||||||
for(int i=0;i<ZT_NETWORK_MAX_INCOMING_UPDATES;++i)
|
for(int i=0;i<ZT_NETWORK_MAX_INCOMING_UPDATES;++i)
|
||||||
_incomingConfigChunks[i].ts = 0;
|
_incomingConfigChunks[i].ts = 0;
|
||||||
@ -852,6 +862,7 @@ void Network::multicastSubscribe(void *tPtr,const MulticastGroup &mg)
|
|||||||
if (!std::binary_search(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg)) {
|
if (!std::binary_search(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg)) {
|
||||||
_myMulticastGroups.insert(std::upper_bound(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg),mg);
|
_myMulticastGroups.insert(std::upper_bound(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg),mg);
|
||||||
_sendUpdatesToMembers(tPtr,&mg);
|
_sendUpdatesToMembers(tPtr,&mg);
|
||||||
|
_multicast_groups_gauge++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,8 +870,10 @@ void Network::multicastUnsubscribe(const MulticastGroup &mg)
|
|||||||
{
|
{
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
std::vector<MulticastGroup>::iterator i(std::lower_bound(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg));
|
std::vector<MulticastGroup>::iterator i(std::lower_bound(_myMulticastGroups.begin(),_myMulticastGroups.end(),mg));
|
||||||
if ( (i != _myMulticastGroups.end()) && (*i == mg) )
|
if ( (i != _myMulticastGroups.end()) && (*i == mg) ) {
|
||||||
_myMulticastGroups.erase(i);
|
_myMulticastGroups.erase(i);
|
||||||
|
_multicast_groups_gauge--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Network::handleConfigChunk(void *tPtr,const uint64_t packetId,const Address &source,const Buffer<ZT_PROTO_MAX_PACKET_LENGTH> &chunk,unsigned int ptr)
|
uint64_t Network::handleConfigChunk(void *tPtr,const uint64_t packetId,const Address &source,const Buffer<ZT_PROTO_MAX_PACKET_LENGTH> &chunk,unsigned int ptr)
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "NetworkConfig.hpp"
|
#include "NetworkConfig.hpp"
|
||||||
#include "CertificateOfMembership.hpp"
|
#include "CertificateOfMembership.hpp"
|
||||||
|
|
||||||
|
#include <prometheus/simpleapi.h>
|
||||||
|
|
||||||
#define ZT_NETWORK_MAX_INCOMING_UPDATES 3
|
#define ZT_NETWORK_MAX_INCOMING_UPDATES 3
|
||||||
#define ZT_NETWORK_MAX_UPDATE_CHUNKS ((ZT_NETWORKCONFIG_DICT_CAPACITY / 1024) + 1)
|
#define ZT_NETWORK_MAX_UPDATE_CHUNKS ((ZT_NETWORKCONFIG_DICT_CAPACITY / 1024) + 1)
|
||||||
|
|
||||||
@ -46,6 +48,9 @@ namespace ZeroTier {
|
|||||||
class RuntimeEnvironment;
|
class RuntimeEnvironment;
|
||||||
class Peer;
|
class Peer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A virtual LAN
|
* A virtual LAN
|
||||||
*/
|
*/
|
||||||
@ -474,6 +479,8 @@ private:
|
|||||||
Mutex _lock;
|
Mutex _lock;
|
||||||
|
|
||||||
AtomicCounter __refCount;
|
AtomicCounter __refCount;
|
||||||
|
|
||||||
|
prometheus::simpleapi::gauge_metric_t _multicast_groups_gauge;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
Loading…
x
Reference in New Issue
Block a user