Central startup update (#1973)

* allow specifying authtoken in central startup

* set allowManagedFrom

* move redis_mem_notification to the correct place

* add node checkins metric

* wire up min/max connection pool size metrics
This commit is contained in:
Grant Limberg 2023-04-25 12:44:18 -07:00 committed by GitHub
parent 8e6e4ede6d
commit e4cb74896b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 1 deletions

View File

@ -61,6 +61,8 @@ public:
, m_minPoolSize(min_pool_size) , m_minPoolSize(min_pool_size)
, m_factory(factory) , m_factory(factory)
{ {
Metrics::max_pool_size += max_pool_size;
Metrics::min_pool_size += min_pool_size;
while(m_pool.size() < m_minPoolSize){ while(m_pool.size() < m_minPoolSize){
m_pool.push_back(m_factory->create()); m_pool.push_back(m_factory->create());
Metrics::pool_avail++; Metrics::pool_avail++;

View File

@ -1145,6 +1145,7 @@ void PostgreSQL::_membersWatcher_Redis() {
_redis->xdel(key, id); _redis->xdel(key, id);
} }
lastID = id; lastID = id;
Metrics::redis_mem_notification++;
} }
} }
} }
@ -1687,6 +1688,7 @@ void PostgreSQL::onlineNotification_Postgres()
<< " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated"; << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated";
pipe.insert(memberUpdate.str()); pipe.insert(memberUpdate.str());
Metrics::pgsql_node_checkin++;
} }
while(!pipe.empty()) { while(!pipe.empty()) {
pipe.retrieve(); pipe.retrieve();
@ -1794,7 +1796,7 @@ uint64_t PostgreSQL::_doRedisUpdate(sw::redis::Transaction &tx, std::string &con
.sadd("network-nodes-all:{"+controllerId+"}:"+networkId, memberId) .sadd("network-nodes-all:{"+controllerId+"}:"+networkId, memberId)
.hmset("member:{"+controllerId+"}:"+networkId+":"+memberId, record.begin(), record.end()); .hmset("member:{"+controllerId+"}:"+networkId+":"+memberId, record.begin(), record.end());
++count; ++count;
Metrics::redis_mem_notification++; Metrics::redis_node_checkin++;
} }
// expire records from all-nodes and network-nodes member list // expire records from all-nodes and network-nodes member list

View File

@ -58,6 +58,9 @@ mkdir -p /var/lib/zerotier-one
pushd /var/lib/zerotier-one pushd /var/lib/zerotier-one
ln -s $ZT_IDENTITY_PATH/identity.public identity.public ln -s $ZT_IDENTITY_PATH/identity.public identity.public
ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret
if [ -f "$ZT_IDENTITY_PATH/authtoken.secret" ]; then
ln -s $ZT_IDENTITY_PATH/authtoken.secret authtoken.secret
fi
popd popd
DEFAULT_PORT=9993 DEFAULT_PORT=9993
@ -74,6 +77,7 @@ echo "{
\"nat64\" \"nat64\"
], ],
\"ssoRedirectURL\": \"${ZT_SSO_REDIRECT_URL}\", \"ssoRedirectURL\": \"${ZT_SSO_REDIRECT_URL}\",
\"allowManagementFrom\": [\"127.0.0.1\", \"::1\", \"10.0.0.0/8\"],
${REDIS} ${REDIS}
} }
} }

View File

@ -52,10 +52,14 @@ namespace ZeroTier {
{ "controller_pgsql_member_notifications_received", "number of member change notifications received via pgsql NOTIFY" }; { "controller_pgsql_member_notifications_received", "number of member change notifications received via pgsql NOTIFY" };
prometheus::simpleapi::counter_metric_t pgsql_net_notification prometheus::simpleapi::counter_metric_t pgsql_net_notification
{ "controller_pgsql_network_notifications_received", "number of network change notifications received via pgsql NOTIFY" }; { "controller_pgsql_network_notifications_received", "number of network change notifications received via pgsql NOTIFY" };
prometheus::simpleapi::counter_metric_t pgsql_node_checkin
{ "controller_pgsql_node_checkin_count", "number of node check-ins (pgsql)" };
prometheus::simpleapi::counter_metric_t redis_mem_notification prometheus::simpleapi::counter_metric_t redis_mem_notification
{ "controller_redis_member_notifications_received", "number of member change notifications received via redis" }; { "controller_redis_member_notifications_received", "number of member change notifications received via redis" };
prometheus::simpleapi::counter_metric_t redis_net_notification prometheus::simpleapi::counter_metric_t redis_net_notification
{ "controller_redis_network_notifications_received", "number of network change notifications received via redis" }; { "controller_redis_network_notifications_received", "number of network change notifications received via redis" };
prometheus::simpleapi::counter_metric_t redis_node_checkin
{ "controller_redis_node_checkin_count", "number of node check-ins (redis)" };
// Central DB Pool Metrics // Central DB Pool Metrics
prometheus::simpleapi::counter_metric_t conn_counter prometheus::simpleapi::counter_metric_t conn_counter

View File

@ -40,8 +40,10 @@ namespace ZeroTier {
// Central Controller Metrics // Central Controller Metrics
extern prometheus::simpleapi::counter_metric_t pgsql_mem_notification; extern prometheus::simpleapi::counter_metric_t pgsql_mem_notification;
extern prometheus::simpleapi::counter_metric_t pgsql_net_notification; extern prometheus::simpleapi::counter_metric_t pgsql_net_notification;
extern prometheus::simpleapi::counter_metric_t pgsql_node_checkin;
extern prometheus::simpleapi::counter_metric_t redis_mem_notification; extern prometheus::simpleapi::counter_metric_t redis_mem_notification;
extern prometheus::simpleapi::counter_metric_t redis_net_notification; extern prometheus::simpleapi::counter_metric_t redis_net_notification;
extern prometheus::simpleapi::counter_metric_t redis_node_checkin;
// Central DB Pool Metrics // Central DB Pool Metrics
extern prometheus::simpleapi::counter_metric_t conn_counter; extern prometheus::simpleapi::counter_metric_t conn_counter;