11 #include "vr_genetlink.h"
16 #include <uve/stats_interval_types.h>
24 using process::ConnectionInfo;
25 using process::ConnectionType;
26 using process::ProcessState;
27 using process::ConnectionStatus;
30 using process::g_process_info_constants;
45 uint32_t default_intvl, uint32_t incremental_intvl)
46 : vn_uve_table_(NULL), vm_uve_table_(NULL), vrouter_uve_entry_(NULL),
48 interface_uve_table_(NULL),
49 default_interval_(default_intvl),
50 incremental_interval_(incremental_intvl),
51 agent_(agent), bandwidth_intvl_(intvl),
53 *(agent->event_manager()->io_service()),
64 TagList::const_iterator it = tl.begin();
65 while (it != tl.end()) {
88 if (!info->
labels.empty()) {
119 std::stringstream ss;
120 ss <<
"0x" << std::setfill(
'0') <<
121 std::setw(8) << std::hex << (uint32_t)value;
127 TagList::const_iterator it = tl.begin();
128 while (it != tl.end()) {
151 if (!info->
labels.empty()) {
191 boost::asio::io_context &io = *evm->
io_service();
195 ConnectionStateManager::
199 module_id, instance_id,
201 this, _1, _2, _3),
"ObjectVRouter");
205 uint8_t &num_dns_servers) {
228 std::string &message) {
229 if (message.empty()) {
230 message = cinfo.get_type();
232 message +=
", " + cinfo.get_type();
234 const std::string &name(cinfo.get_name());
236 message +=
":" + name;
248 (
const std::vector<ConnectionInfo> &cinfos,
250 size_t num_conns = 0;
251 uint8_t num_control_nodes = 0, num_dns_servers = 0;
252 uint8_t down_control_nodes = 0;
253 uint8_t expected_conns = ExpectedConnections(num_control_nodes,
255 std::string cup(g_process_info_constants.ConnectionStatusNames.
256 find(ConnectionStatus::UP)->second);
258 bool is_tor_connected =
false;
259 string tor_type(g_process_info_constants.ConnectionTypeNames.
260 find(ConnectionType::TOR)->second);
262 for (std::vector<ConnectionInfo>::const_iterator it = cinfos.begin();
263 it != cinfos.end(); it++) {
264 const ConnectionInfo &cinfo(*it);
265 const std::string &conn_status(cinfo.get_status());
266 if (cinfo.get_type() == tor_type) {
267 is_tor_connected =
true;
277 if (conn_status != cup) {
278 if (cinfo.get_name().compare(0, 13,
279 agent_->xmpp_control_node_prefix()) == 0) {
280 down_control_nodes++;
283 UpdateMessage(cinfo, message);
286 if ((num_control_nodes == 0) || (num_control_nodes == down_control_nodes)) {
287 pstate = ProcessState::NON_FUNCTIONAL;
288 if ((num_control_nodes == 0) && message.empty()) {
289 message =
"No control-nodes configured";
291 }
else if (!is_tor_connected && agent_->tor_agent_enabled()) {
293 pstate = ProcessState::NON_FUNCTIONAL;
294 message +=
" No ToR Config";
296 pstate = ProcessState::FUNCTIONAL;
299 message +=
" connection down";
301 if (!HasSelfConfiguration()) {
303 pstate = ProcessState::NON_FUNCTIONAL;
304 if (message.empty()) {
305 message =
"No Configuration for self";
307 message +=
", No Configuration for self";
311 if (!agent_->controller_ifmap_xmpp_server(i).empty()) {
312 if (agent_->stats()->xmpp_reconnects(i) >= 1) {
318 if (num_conns != expected_conns) {
std::vector< string > label_vector
ServicesModule * services() const
void Init(boost::asio::io_context &service, const std::string &hostname, const std::string &module, const std::string &instance_id, ProcessStateFn status_cb, std::string table)
const std::string & TagName(uint32_t id)
AgentUveBase(Agent *agent, uint64_t intvl, uint32_t default_intvl, uint32_t incremental_intvl)
const std::vector< std::string > collector_server_list() const
boost::scoped_ptr< InterfaceUveTable > interface_uve_table_
const std::string & dns_server(uint8_t idx) const
boost::asio::io_context * io_service()
static const uint32_t kUveCountPerTimer
void BuildTagIdsFromList(const TagList &tl, UveTagData *info) const
void set_connection_state(process::ConnectionState *state)
boost::scoped_ptr< ProuterUveTable > prouter_uve_table_
bool HasSelfConfiguration() const
std::string IntegerToHexString(uint32_t value) const
void BuildTagNamesFromList(const TagList &tl, UveTagData *info) const
TagTable * tag_table() const
boost::scoped_ptr< VrouterStatsCollector > vrouter_stats_collector_
boost::scoped_ptr< VmUveTableBase > vm_uve_table_
GlobalVrouter * global_vrouter() const
const std::string & instance_id() const
static const std::string integerToString(const NumberType &num)
static const uint32_t kDefaultInterval
EventManager * event_manager() const
static const uint64_t kBandwidthInterval
process::ConnectionStateManager * connection_state_manager_
void UpdateMessage(const process::ConnectionInfo &info, std::string &message)
virtual void RegisterDBClients()
static const uint32_t kIncrementalInterval
AgentParam * params() const
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
const std::string & agent_name() const
std::vector< string > custom_tag_vector
std::set< string > custom_tag_set
boost::scoped_ptr< VrouterUveEntryBase > vrouter_uve_entry_
void VrouterAgentProcessState(const std::vector< process::ConnectionInfo > &c, process::ProcessState::type &state, std::string &message)
const std::string & module_name() const
boost::scoped_ptr< VnUveTableBase > vn_uve_table_
static const uint32_t kTagTypeBitShift
static AgentUveBase * singleton_
uint8_t ExpectedConnections(uint8_t &num_c_nodes, uint8_t &num_d_servers)
std::set< string > label_set
std::vector< int > TagList