- Version changed to 0.1.11
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 18 Jan 2005 21:07:14 +0000 (21:07 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 18 Jan 2005 21:07:14 +0000 (21:07 +0000)
- Added event correlation module (which does nothing for the moment)

.gitattributes
include/netxms-version.h
src/server/core/correlate.cpp [copied from include/netxms-version.h with 70% similarity]
src/server/core/events.cpp
src/server/core/evproc.cpp
src/server/core/nxcore.dsp
src/server/include/nms_events.h

index 66d89d5..0691f8c 100644 (file)
@@ -497,6 +497,7 @@ src/server/core/alarm.cpp -text
 src/server/core/client.cpp -text
 src/server/core/config.cpp -text
 src/server/core/container.cpp -text
+src/server/core/correlate.cpp -text
 src/server/core/datacoll.cpp -text
 src/server/core/dbwrite.cpp -text
 src/server/core/dcitem.cpp -text
index 3e1a9eb..58d0fdb 100644 (file)
@@ -30,8 +30,8 @@
 
 #define NETXMS_VERSION_MAJOR      0
 #define NETXMS_VERSION_MINOR      1
-#define NETXMS_VERSION_BUILD      10
-#define NETXMS_VERSION_STRING     _T("0.1.10")
+#define NETXMS_VERSION_BUILD      11
+#define NETXMS_VERSION_STRING     _T("0.1.11")
 
 
 #endif
similarity index 70%
copy from include/netxms-version.h
copy to src/server/core/correlate.cpp
index 3e1a9eb..871fe9c 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003, 2004 Victor Kirhenshtein
+** Copyright (C) 2003, 2004, 2005 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: netxms-version.h
+** $module: correlate.cpp
 **
 **/
 
-#ifndef _netxms_version_h_
-#define _netxms_version_h_
+#include "nxcore.h"
 
 
 //
-// Version constants 
+// Correlate event
 //
 
-#define NETXMS_VERSION_MAJOR      0
-#define NETXMS_VERSION_MINOR      1
-#define NETXMS_VERSION_BUILD      10
-#define NETXMS_VERSION_STRING     _T("0.1.10")
-
-
-#endif
+void CorrelateEvent(Event *pEvent)
+{
+}
index 2598417..2656cd0 100644 (file)
@@ -50,6 +50,7 @@ static RWLOCK m_rwlockTemplateAccess;
 Event::Event()
 {
    m_qwId = 0;
+   m_qwRootId = 0;
    m_dwCode = 0;
    m_dwSeverity = 0;
    m_dwSource = 0;
@@ -69,6 +70,7 @@ Event::Event(EVENT_TEMPLATE *pTemplate, DWORD dwSourceId, char *szFormat, va_lis
 {
    m_tTimeStamp = time(NULL);
    m_qwId = CreateUniqueEventId();
+   m_qwRootId = 0;
    m_dwCode = pTemplate->dwCode;
    m_dwSeverity = pTemplate->dwSeverity;
    m_dwFlags = pTemplate->dwFlags;
index 1c56aee..d326d28 100644 (file)
@@ -48,6 +48,9 @@ THREAD_RESULT THREAD_CALL EventProcessor(void *arg)
       if (pEvent == INVALID_POINTER_VALUE)
          break;   // Shutdown indicator
 
+      // Attempt to correlate event to some of previous events
+      CorrelateEvent(pEvent);
+
       // Write event to log if required
       if (pEvent->Flags() & EF_LOG)
       {
@@ -55,14 +58,15 @@ THREAD_RESULT THREAD_CALL EventProcessor(void *arg)
 
          pszMsg = EncodeSQLString(pEvent->Message());
          sprintf(szQuery, "INSERT INTO event_log (event_id,event_code,event_timestamp,"
-                          "event_source,event_severity,event_message) "
+                          "event_source,event_severity,event_message,root_event_id) "
 #ifdef _WIN32
-                          "VALUES (%I64d,%d,%d,%d,%d,'%s')", 
+                          "VALUES (%I64d,%d,%d,%d,%d,'%s',%I64d)", 
 #else
-                          "VALUES (%lld,%d,%d,%d,%d,'%s')", 
+                          "VALUES (%lld,%d,%d,%d,%d,'%s',%lld)", 
 #endif
                  pEvent->Id(), pEvent->Code(), pEvent->TimeStamp(),
-                 pEvent->SourceId(), pEvent->Severity(), pszMsg);
+                 pEvent->SourceId(), pEvent->Severity(), pszMsg,
+                 pEvent->GetRootId());
          free(pszMsg);
          DBQuery(g_hCoreDB, szQuery);
       }
@@ -76,12 +80,15 @@ THREAD_RESULT THREAD_CALL EventProcessor(void *arg)
          NetObj *pObject = FindObjectById(pEvent->SourceId());
          if (pObject == NULL)
             pObject = g_pEntireNet;
-         printf("EVENT %d (F:0x%04X S:%d) FROM %s: %s\n", pEvent->Code(), 
-                pEvent->Flags(), pEvent->Severity(), pObject->Name(), pEvent->Message());
+         printf("EVENT %d (F:0x%04X S:%d%s) FROM %s: %s\n", pEvent->Code(), 
+                pEvent->Flags(), pEvent->Severity(),
+                (pEvent->GetRootId() == 0) ? "" : " CORRELATED",
+                pObject->Name(), pEvent->Message());
       }
 
       // Pass event through event processing policy
-      g_pEventPolicy->ProcessEvent(pEvent);
+      if (pEvent->GetRootId() == 0)
+         g_pEventPolicy->ProcessEvent(pEvent);
 
       // Destroy event
       delete pEvent;
index 071d560..c1028c9 100644 (file)
@@ -130,6 +130,10 @@ SOURCE=.\container.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\correlate.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\datacoll.cpp
 # End Source File
 # Begin Source File
index 30153ef..bf2ae56 100644 (file)
@@ -55,6 +55,7 @@ class Event
 {
 private:
    QWORD m_qwId;
+   QWORD m_qwRootId;    // Root event id
    DWORD m_dwCode;
    DWORD m_dwSeverity;
    DWORD m_dwFlags;
@@ -78,6 +79,9 @@ public:
    DWORD SourceId(void) { return m_dwSource; }
    const char *Message(void) { return m_pszMessageText; }
    time_t TimeStamp(void) { return m_tTimeStamp; }
+   
+   QWORD GetRootId(void) { return m_qwRootId; }
+   void SetRootId(QWORD qwId) { m_qwRootId = qwId; }
 
    void PrepareMessage(NXC_EVENT *pEventData);
 
@@ -165,6 +169,7 @@ BOOL InitEventSubsystem(void);
 void ShutdownEventSubsystem(void);
 BOOL PostEvent(DWORD dwEventCode, DWORD dwSourceId, char *szFormat, ...);
 void ReloadEvents(void);
+void CorrelateEvent(Event *pEvent);
 
 
 //