void Syncer(void *arg);
void NodePoller(void *arg);
void StatusPoller(void *arg);
+void ConfigurationPoller(void *arg);
void EventProcessor(void *arg);
DB_HANDLE g_hCoreDB = 0;
DWORD g_dwDiscoveryPollingInterval;
DWORD g_dwStatusPollingInterval;
+DWORD g_dwConfigurationPollingInterval;
//
static void LoadGlobalConfig()
{
- g_dwDiscoveryPollingInterval = ConfigReadInt("DiscoveryPollingInterval", 3600);
+ g_dwDiscoveryPollingInterval = ConfigReadInt("DiscoveryPollingInterval", 900);
g_dwStatusPollingInterval = ConfigReadInt("StatusPollingInterval", 60);
+ g_dwConfigurationPollingInterval = ConfigReadInt("ConfigurationPollingInterval", 3600);
}
extern DWORD g_dwDiscoveryPollingInterval;
extern DWORD g_dwStatusPollingInterval;
+extern DWORD g_dwConfigurationPollingInterval;
//
char m_szObjectId[MAX_OID_LEN * 4];
time_t m_tLastDiscoveryPoll;
time_t m_tLastStatusPoll;
+ time_t m_tLastConfigurationPoll;
+ int m_iSnmpAgentFails;
+ int m_iNativeAgentFails;
public:
Node();
void SetDiscoveryPollTimeStamp(void) { m_tLastDiscoveryPoll = time(NULL); }
BOOL ReadyForStatusPoll(void) { return (DWORD)time(NULL) - (DWORD)m_tLastStatusPoll > g_dwStatusPollingInterval ? TRUE : FALSE; }
void StatusPoll(void);
+ BOOL ReadyForConfigurationPoll(void) { return (DWORD)time(NULL) - (DWORD)m_tLastConfigurationPoll > g_dwConfigurationPollingInterval ? TRUE : FALSE; }
+ void ConfigurationPoll(void);
virtual void CalculateCompoundStatus(void);
};
m_szObjectId[0] = 0;
m_tLastDiscoveryPoll = 0;
m_tLastStatusPoll = 0;
+ m_tLastConfigurationPoll = 0;
+ m_iSnmpAgentFails = 0;
+ m_iNativeAgentFails = 0;
}
m_szObjectId[0] = 0;
m_tLastDiscoveryPoll = 0;
m_tLastStatusPoll = 0;
+ m_tLastConfigurationPoll = 0;
+ m_iSnmpAgentFails = 0;
+ m_iNativeAgentFails = 0;
}
CalculateCompoundStatus();
m_tLastStatusPoll = time(NULL);
}
+
+
+//
+// Perform configuration poll on node
+//
+
+void Node::ConfigurationPoll(void)
+{
+ DWORD dwOldFlags = m_dwFlags;
+ AgentConnection *pAgentConn;
+ INTERFACE_LIST *pIfList;
+
+ // Check node's capabilities
+ if (SnmpGet(m_dwIpAddr, m_szCommunityString, ".1.3.6.1.2.1.1.2.0", NULL, 0, m_szObjectId, MAX_OID_LEN * 4))
+ {
+ m_dwFlags |= NF_IS_SNMP;
+ m_iSnmpAgentFails = 0;
+ }
+ else
+ {
+ if (m_iSnmpAgentFails == 0)
+ PostEvent(EVENT_SNMP_FAIL, m_dwId, NULL);
+ m_iSnmpAgentFails++;
+ }
+
+ pAgentConn = new AgentConnection(m_dwIpAddr, m_wAgentPort, m_wAuthMethod, m_szSharedSecret);
+ if (pAgentConn->Connect())
+ {
+ m_dwFlags |= NF_IS_NATIVE_AGENT;
+ m_iNativeAgentFails = 0;
+ }
+ else
+ {
+ if (m_iNativeAgentFails == 0)
+ PostEvent(EVENT_AGENT_FAIL, m_dwId, NULL);
+ m_iNativeAgentFails++;
+ }
+
+ // Generate event if node flags has been changed
+ if (dwOldFlags != m_dwFlags)
+ PostEvent(EVENT_NODE_FLAGS_CHANGED, m_dwId, "xx", dwOldFlags, m_dwFlags);
+
+ // Retrieve interface list
+ pIfList = GetInterfaceList();
+ if (pIfList != NULL)
+ {
+ DWORD i;
+
+ // Find non-existing interfaces
+ for(i = 0; i < m_dwChildCount; i++)
+ if (m_pChildList[i]->Type() == OBJECT_INTERFACE)
+ {
+ Interface *pInterface = (Interface *)m_pChildList[i];
+ int j;
+
+ for(j = 0; j < pIfList->iNumEntries; j++)
+ if ((pIfList->pInterfaces[j].dwIndex == pInterface->IfIndex()) &&
+ (pIfList->pInterfaces[j].dwIpAddr == pInterface->IpAddr()) &&
+ (pIfList->pInterfaces[j].dwIpNetMask == pInterface->IpNetMask()))
+ break;
+ if (j == pIfList->iNumEntries)
+ {
+ // No such interface in current configuration, delete it
+ PostEvent(EVENT_INTERFACE_DELETED, m_dwId, "dsaa", pInterface->IfIndex(),
+ pInterface->Name(), pInterface->IpAddr(), pInterface->IpNetMask());
+ pInterface->Delete();
+ i = 0; // Restart loop
+ }
+ }
+
+ }
+}
}
}
}
+
+
+//
+// Configuration poll thread
+//
+
+void ConfigurationPoller(void *arg)
+{
+ Node *pNode;
+
+ while(!ShutdownInProgress())
+ {
+ if (SleepAndCheckForShutdown(30))
+ break; // Shutdown has arrived
+
+ // Walk through nodes and do configuration poll
+ for(DWORD i = 0; i < g_dwNodeAddrIndexSize; i++)
+ {
+ pNode = (Node *)g_pNodeIndexByAddr[i].pObject;
+ if (pNode->ReadyForConfigurationPoll())
+ pNode->ConfigurationPoll();
+ }
+ }
+}