diff --git a/controller/DB.cpp b/controller/DB.cpp index dcce5ea11..9e0cef6e2 100644 --- a/controller/DB.cpp +++ b/controller/DB.cpp @@ -101,7 +101,14 @@ void DB::cleanMember(nlohmann::json &member) member.erase("authenticationClientID"); // computed } -DB::DB() {} +DB::DB() + : _network_count{"controller_network_count", "number of networks the controller is serving"} + , _member_count{"controller_member_count", "number of network members the controller is serving"} + , _network_changes{"controller_network_change_count", "number of times a network configuration is changed"} + , _member_changes{"controller_member_change_count", "number of times a network member configuration is changed"} + , _member_auths{"controller_member_auth_count", "number of network member auths"} + , _member_deauths{"controller_member_deauth_count", "number of network member deauths"} +{} DB::~DB() {} bool DB::get(const uint64_t networkId,nlohmann::json &network) diff --git a/controller/DB.hpp b/controller/DB.hpp index 2dd808f1c..2f4319c8b 100644 --- a/controller/DB.hpp +++ b/controller/DB.hpp @@ -191,12 +191,12 @@ protected: mutable std::mutex _changeListeners_l; mutable std::mutex _networks_l; - prometheus::simpleapi::gauge_metric_t _network_count { "controller_network_count", "number of networks the controller is serving" }; - prometheus::simpleapi::gauge_metric_t _member_count { "controller_member_count", "number of network members the controller is serving" }; - prometheus::simpleapi::counter_metric_t _network_changes { "controller_network_change_count", "number of times a network configuration is changed" }; - prometheus::simpleapi::counter_metric_t _member_changes { "controller_member_change_count", "number of times a network member configuration is changed" }; - prometheus::simpleapi::counter_metric_t _member_auths { "controller_member_auth_count", "number of network member auths" }; - prometheus::simpleapi::counter_metric_t _member_deauths { "controller_member_deauth_count", "number of network member deauths" }; + prometheus::simpleapi::gauge_metric_t _network_count; + prometheus::simpleapi::gauge_metric_t _member_count; + prometheus::simpleapi::counter_metric_t _network_changes; + prometheus::simpleapi::counter_metric_t _member_changes; + prometheus::simpleapi::counter_metric_t _member_auths; + prometheus::simpleapi::counter_metric_t _member_deauths; }; } // namespace ZeroTier diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index cca4980d8..29250ab78 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -112,6 +112,7 @@ using namespace ZeroTier; MemberNotificationReceiver::MemberNotificationReceiver(PostgreSQL *p, pqxx::connection &c, const std::string &channel) : pqxx::notification_receiver(c, channel) , _psql(p) + , _mem_notifications{"controller_pgsql_member_notifications_received", "number of member change notifications received via pgsql NOTIFY"} { fprintf(stderr, "initialize MemberNotificationReceiver\n"); } @@ -136,6 +137,7 @@ void MemberNotificationReceiver::operator() (const std::string &payload, int pac NetworkNotificationReceiver::NetworkNotificationReceiver(PostgreSQL *p, pqxx::connection &c, const std::string &channel) : pqxx::notification_receiver(c, channel) , _psql(p) + , _net_notifications{"controller_pgsql_network_notifications_received", "number of network change notifications received via pgsql NOTIFY"} { fprintf(stderr, "initialize NetworkNotificationReceiver\n"); } @@ -173,6 +175,8 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R , _redis(NULL) , _cluster(NULL) , _redisMemberStatus(false) + , _redis_mem_notif{"controller_redis_member_notifications_received", "number of member change notifications received via redis"} + , _redis_net_notif{"controller_redis_network_notifications_received", "number of network change notifications received via redis"} { char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); diff --git a/controller/PostgreSQL.hpp b/controller/PostgreSQL.hpp index 5b929dcfb..3ff2857dd 100644 --- a/controller/PostgreSQL.hpp +++ b/controller/PostgreSQL.hpp @@ -51,6 +51,7 @@ class PostgresConnFactory : public ConnectionFactory { public: PostgresConnFactory(std::string &connString) : m_connString(connString) + , _conn_counter{ "controller_pgsql_connections_created", "number of pgsql connections created"} { } @@ -62,7 +63,7 @@ public: } private: std::string m_connString; - prometheus::simpleapi::counter_metric_t _conn_counter { "controller_pgsql_connections_created", "number of pgsql connections created" }; + prometheus::simpleapi::counter_metric_t _conn_counter; }; class PostgreSQL; @@ -77,7 +78,7 @@ public: virtual void operator() (const std::string &payload, int backendPid); private: PostgreSQL *_psql; - prometheus::simpleapi::counter_metric_t _mem_notifications { "controller_pgsql_member_notifications_received", "number of member change notifications received via pgsql NOTIFY" }; + prometheus::simpleapi::counter_metric_t _mem_notifications; }; class NetworkNotificationReceiver : public pqxx::notification_receiver { @@ -90,7 +91,7 @@ public: virtual void operator() (const std::string &payload, int packend_pid); private: PostgreSQL *_psql; - prometheus::simpleapi::counter_metric_t _net_notifications { "controller_pgsql_network_notifications_received", "number of network change notifications received via pgsql NOTIFY" }; + prometheus::simpleapi::counter_metric_t _net_notifications; }; /** @@ -182,9 +183,8 @@ private: std::shared_ptr _cluster; bool _redisMemberStatus; - prometheus::simpleapi::counter_metric_t _redis_mem_notif { "controller_redis_member_notifications_received", "number of member change notifications received via redis" }; - prometheus::simpleapi::counter_metric_t _redis_net_notif { "controller_redis_network_notifications_received", "number of network change notifications received via redis" }; - + prometheus::simpleapi::counter_metric_t _redis_mem_notif; + prometheus::simpleapi::counter_metric_t _redis_net_notif; }; } // namespace ZeroTier