Skip to content

Commit

Permalink
DB IDO: Set is_connected=1 on identity==node.
Browse files Browse the repository at this point in the history
Refs #5636
  • Loading branch information
Michael Friedrich committed Mar 7, 2014
1 parent cc539fc commit 53c2b7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/db_ido/endpointdbobject.cpp
Expand Up @@ -63,7 +63,7 @@ Dictionary::Ptr EndpointDbObject::GetStatusFields(void) const

fields->Set("identity", endpoint->GetName());
fields->Set("node", IcingaApplication::GetInstance()->GetNodeName());
fields->Set("is_connected", endpoint->IsConnected() ? 1 : 0);
fields->Set("is_connected", EndpointIsConnected(endpoint));

return fields;
}
Expand All @@ -77,7 +77,7 @@ void EndpointDbObject::UpdateConnectedStatus(const Endpoint::Ptr& endpoint)
query1.Type = DbQueryUpdate;

Dictionary::Ptr fields1 = make_shared<Dictionary>();
fields1->Set("is_connected", endpoint->IsConnected() ? 1 : 0);
fields1->Set("is_connected", EndpointIsConnected(endpoint));
fields1->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
query1.Fields = fields1;

Expand All @@ -87,3 +87,14 @@ void EndpointDbObject::UpdateConnectedStatus(const Endpoint::Ptr& endpoint)

OnQuery(query1);
}

int EndpointDbObject::EndpointIsConnected(const Endpoint::Ptr& endpoint)
{
unsigned int is_connected = endpoint->IsConnected() ? 1 : 0;

/* if identity is equal to node, fake is_connected */
if (endpoint->GetName() == IcingaApplication::GetInstance()->GetNodeName())
is_connected = 1;

return is_connected;
}
1 change: 1 addition & 0 deletions lib/db_ido/endpointdbobject.h
Expand Up @@ -46,6 +46,7 @@ class EndpointDbObject : public DbObject

private:
static void UpdateConnectedStatus(const Endpoint::Ptr& endpoint);
static int EndpointIsConnected(const Endpoint::Ptr& endpoint);
};

}
Expand Down

0 comments on commit 53c2b7d

Please sign in to comment.