- few more changes for SLM
authorAlex Kalimulin <alex@netxms.org>
Sun, 28 Aug 2011 22:03:17 +0000 (22:03 +0000)
committerAlex Kalimulin <alex@netxms.org>
Sun, 28 Aug 2011 22:03:17 +0000 (22:03 +0000)
include/nms_cscp.h
src/server/core/bizservice.cpp
src/server/core/nodelink.cpp
src/server/core/slm.cpp
src/server/core/slmcheck.cpp

index 6b1f9d5..989e7e1 100644 (file)
@@ -869,6 +869,11 @@ typedef struct
 #define VID_BRIDGE_BASE_ADDRESS     ((DWORD)388)
 #define VID_SUBMAP_ID               ((DWORD)389)
 #define VID_REPORT_DEFINITION       ((DWORD)390)
+#define VID_SLMCHECK_TYPE                      ((DWORD)391)
+#define VID_SLMCHECK_THR_ID                    ((DWORD)392)
+#define VID_SLMCHECK_SCRIPT                    ((DWORD)393)
+#define VID_SLMCHECK_REASON                    ((DWORD)394)
+#define VID_NODELINK_NODE_ID           ((DWORD)395)
 
 // Map elements list base
 #define VID_ELEMENT_LIST_BASE       ((DWORD)0x10000000)
index a08e7f7..be88b13 100644 (file)
@@ -216,8 +216,7 @@ BOOL BizService::DeleteFromDB()
 void BizService::CreateMessage(CSCPMessage *pMsg)
 {
    NetObj::CreateMessage(pMsg);
-   // pMsg->SetVariable(VID_ID, m_dwId);
-   // pMsg->SetVariable(VID_STATUS, m_svcStatus);
+   // Calling just a base method should do fine
 }
 
 
@@ -230,8 +229,7 @@ DWORD BizService::ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked)
    if (!bAlreadyLocked)
       LockData();
 
-       // if (pRequest->IsVariableExist(VID_STATUS))
-       //      m_svcStatus = pRequest->GetVariableLong(VID_STATUS);
+   // ... and here too
 
    return NetObj::ModifyFromMessage(pRequest, TRUE);
 }
index dc1226e..6dcd0c1 100644 (file)
@@ -33,6 +33,7 @@ NodeLink::NodeLink()
 :Container()
 {
        _tcscpy(m_szName, _T("Default"));
+       m_node = NULL;
 }
 
 
@@ -41,9 +42,9 @@ NodeLink::NodeLink()
 //
 
 NodeLink::NodeLink(const TCHAR *name)
-:Container()
+:Container(name, 0)
 {
-       nx_strncpy(m_szName, name, MAX_OBJECT_NAME);
+       m_node = NULL;
 }
 
 
@@ -196,8 +197,7 @@ BOOL NodeLink::DeleteFromDB()
 void NodeLink::CreateMessage(CSCPMessage *pMsg)
 {
        NetObj::CreateMessage(pMsg);
-       // pMsg->SetVariable(VID_ID, m_dwId);
-       // pMsg->SetVariable(VID_STATUS, m_svcStatus);
+       pMsg->SetVariable(VID_NODELINK_NODE_ID, m_node->Id());
 }
 
 
@@ -210,8 +210,12 @@ DWORD NodeLink::ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked)
        if (!bAlreadyLocked)
                LockData();
 
-       // if (pRequest->IsVariableExist(VID_STATUS))
-       //      m_svcStatus = pRequest->GetVariableLong(VID_STATUS);
+       if (pRequest->IsVariableExist(VID_NODELINK_NODE_ID))
+       {
+               safe_delete_and_null(m_node);
+               m_node = new Node;
+               m_node->CreateFromDB(pRequest->GetVariableLong(VID_NODELINK_NODE_ID));
+       }
 
        return NetObj::ModifyFromMessage(pRequest, TRUE);
 }
index 34b67af..4ff29d9 100644 (file)
 **
 **/
 
-#include "nxcore.h"
-
-static bool SlmLoadChecks(void)
-{
-       DB_HANDLE hdb = DBConnectionPoolAcquireConnection();
-
-       DBConnectionPoolReleaseConnection(hdb);
-
-       return true;
-}
-
-static bool SlmInit(void)
-{
-       // Load SLM checks
-
-       if (!SlmLoadChecks())
-       {
-               DbgPrintf(1, _T("Cannot load SLM checks"));
-       }
-
-       return true;
-}
-
-THREAD_RESULT THREAD_CALL ServiceLevelMonitoring(void *pArg)
-{
-       const DWORD dwInterval = 60;
-       time_t currTime;
-
-       DbgPrintf(1, _T("SLM thread started"));
-
-       if (!SlmInit())
-               goto finish;
-
-       while(!IsShutdownInProgress())
-       {
-               currTime = time(NULL);
-               if (SleepAndCheckForShutdown(dwInterval - (DWORD)(currTime % dwInterval)))
-                       break;      // Shutdown has arrived
-
-               DB_HANDLE hdb = DBConnectionPoolAcquireConnection();
-/*
-               NetObj* curObject;
-
-               for (int i = 0; i < g_pBizServiceRoot->m_dwChildCount; i++)
-               {
-                       curObject = g_pBizServiceRoot->m_pChildList[i];
-                       curObject->calculateCompoundStatus();
-               }
-*/
-               DBConnectionPoolReleaseConnection(hdb);
-       }
-
-finish:
-       DbgPrintf(1, _T("SLM thread terminated"));
-       return THREAD_OK;
-}
+// MUST THIS FILE BE DELETED??
\ No newline at end of file
index db9e892..ef676b4 100644 (file)
@@ -220,8 +220,10 @@ BOOL SlmCheck::DeleteFromDB()
 void SlmCheck::CreateMessage(CSCPMessage *pMsg)
 {
        NetObj::CreateMessage(pMsg);
-       // pMsg->SetVariable(VID_ID, m_dwId);
-       // pMsg->SetVariable(VID_STATUS, m_svcStatus);
+       pMsg->SetVariable(VID_SLMCHECK_TYPE, DWORD(m_type));
+       pMsg->SetVariable(VID_SLMCHECK_SCRIPT, m_script ? m_script : NULL);
+       pMsg->SetVariable(VID_SLMCHECK_REASON, m_reason);
+       pMsg->SetVariable(VID_SLMCHECK_THR_ID, m_threshold ? m_threshold->getId() : 0);
 }
 
 
@@ -234,8 +236,18 @@ DWORD SlmCheck::ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked)
        if (!bAlreadyLocked)
                LockData();
 
-       // if (pRequest->IsVariableExist(VID_STATUS))
-       //      m_svcStatus = pRequest->GetVariableLong(VID_STATUS);
+       if (pRequest->IsVariableExist(VID_SLMCHECK_TYPE))
+               m_type = CheckType(pRequest->GetVariableLong(VID_SLMCHECK_TYPE));
+       if (pRequest->IsVariableExist(VID_SLMCHECK_SCRIPT))
+               m_script = pRequest->GetVariableStr(VID_SLMCHECK_SCRIPT);
+       if (pRequest->IsVariableExist(VID_SLMCHECK_REASON))
+               pRequest->GetVariableStr(VID_SLMCHECK_REASON, m_reason, sizeof(m_reason));
+       if (pRequest->IsVariableExist(VID_SLMCHECK_THR_ID))
+       {
+               DWORD thresholdId = pRequest->GetVariableLong(VID_SLMCHECK_THR_ID);
+               // Load threshold
+               // ...
+       }
 
        return NetObj::ModifyFromMessage(pRequest, TRUE);
 }