- DCI housekeeping implemented
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 28 Feb 2005 09:28:05 +0000 (09:28 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 28 Feb 2005 09:28:05 +0000 (09:28 +0000)
- Parameters System.Memory.Swap.* removed from Windows agent because they
  are meaningless under Windows

ChangeLog
src/agent/core/getparam.cpp
src/agent/core/win32.cpp
src/server/core/dcitem.cpp
src/server/core/hk.cpp
src/server/core/node.cpp
src/server/include/nms_dcoll.h
src/server/include/nms_objects.h

index 30ada4a..d76fa1b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 * 0.1.15
 *
 
+- DCI housekeeping implemented
 - Fixed server crash at forced poll time
 - Fixed critical bug in upgrade script starter under UNIX
 - Added support of HDD temperature monitoring under Windows and Linux
@@ -9,6 +10,8 @@
   PhysicalDisk.Firmware parameters under Windows
 - Added parameters System.CPU.Count, System.CPU.Usage*, System.KStat(*)
   and System.Memory.Physical.* to Solaris subagent
+- Parameters System.Memory.Swap.* removed from Windows agent because they
+  are meaningless under Windows
 
 
 *
index 45a95d7..99b00c5 100644 (file)
@@ -181,9 +181,6 @@ static NETXMS_SUBAGENT_PARAM m_stdParams[] =
    { "System.Memory.Physical.Free", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_FREE, DCI_DT_UINT64, "Free physical memory" },
    { "System.Memory.Physical.Total", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_TOTAL, DCI_DT_UINT64, "Total amount of physical memory" },
    { "System.Memory.Physical.Used", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_USED, DCI_DT_UINT64, "Used physical memory" },
-   { "System.Memory.Swap.Free", H_MemoryInfo, (char *)MEMINFO_SWAP_FREE, DCI_DT_UINT64, "Free swap space" },
-   { "System.Memory.Swap.Total", H_MemoryInfo, (char *)MEMINFO_SWAP_TOTAL, DCI_DT_UINT64, "Total amount of swap space" },
-   { "System.Memory.Swap.Used", H_MemoryInfo, (char *)MEMINFO_SWAP_USED, DCI_DT_UINT64, "Used swap space" },
    { "System.Memory.Virtual.Free", H_MemoryInfo, (char *)MEMINFO_VIRTUAL_FREE, DCI_DT_UINT64, "Free virtual memory" },
    { "System.Memory.Virtual.Total", H_MemoryInfo, (char *)MEMINFO_VIRTUAL_TOTAL, DCI_DT_UINT64, "Total amount of virtual memory" },
    { "System.Memory.Virtual.Used", H_MemoryInfo, (char *)MEMINFO_VIRTUAL_USED, DCI_DT_UINT64, "Used virtual memory" },
index 699e815..974ae19 100644 (file)
@@ -150,15 +150,6 @@ LONG H_MemoryInfo(char *cmd, char *arg, char *value)
          case MEMINFO_VIRTUAL_USED:
             ret_uint64(value, mse.ullTotalPageFile - mse.ullAvailPageFile);
             break;
-         case MEMINFO_SWAP_FREE:
-            ret_uint64(value, mse.ullAvailPageFile - mse.ullAvailPhys);
-            break;
-         case MEMINFO_SWAP_TOTAL:
-            ret_uint64(value, mse.ullTotalPageFile - mse.ullTotalPhys);
-            break;
-         case MEMINFO_SWAP_USED:
-            ret_uint64(value, mse.ullTotalPageFile - mse.ullAvailPageFile - (mse.ullTotalPhys - mse.ullAvailPhys));
-            break;
          default:
             return SYSINFO_RC_UNSUPPORTED;
       }
@@ -188,15 +179,6 @@ LONG H_MemoryInfo(char *cmd, char *arg, char *value)
          case MEMINFO_VIRTUAL_USED:
             ret_uint(value, ms.dwTotalPageFile - ms.dwAvailPageFile);
             break;
-         case MEMINFO_SWAP_FREE:
-            ret_uint(value, ms.dwAvailPageFile - ms.dwAvailPhys);
-            break;
-         case MEMINFO_SWAP_TOTAL:
-            ret_uint(value, ms.dwTotalPageFile - ms.dwTotalPhys);
-            break;
-         case MEMINFO_SWAP_USED:
-            ret_uint(value, ms.dwTotalPageFile - ms.dwAvailPageFile - (ms.dwTotalPhys - ms.dwAvailPhys));
-            break;
          default:
             return SYSINFO_RC_UNSUPPORTED;
       }
index 4cf8ab2..aa0dbf3 100644 (file)
@@ -729,3 +729,21 @@ void DCItem::GetLastValue(CSCPMessage *pMsg, DWORD dwId)
       pMsg->SetVariable(dwId++, (DWORD)0);
    }
 }
+
+
+//
+// Clean expired data
+//
+
+void DCItem::CleanData(void)
+{
+   TCHAR szQuery[256];
+   time_t now;
+
+   now = time(NULL);
+   Lock();
+   _sntprintf(szQuery, 256, _T("DELETE FROM idata_%ld WHERE (item_id=%ld) AND (idata_timestamp<%ld)"),
+              m_pNode->Id(), m_dwId, now - (DWORD)m_iRetentionTime * 86400);
+   Unlock();
+   QueueSQLRequest(szQuery);
+}
index 7c1008e..bd4f605 100644 (file)
@@ -97,7 +97,7 @@ THREAD_RESULT THREAD_CALL HouseKeeper(void *pArg)
 {
    time_t currTime;
    char szQuery[256];
-   DWORD dwEventLogRetentionTime, dwInterval;
+   DWORD i, dwEventLogRetentionTime, dwInterval;
 
    // Load configuration
    dwInterval = ConfigReadULong("HouseKeepingInterval", 3600);
@@ -123,6 +123,12 @@ THREAD_RESULT THREAD_CALL HouseKeeper(void *pArg)
 
       // Remove deleted objects which are no longer referenced
       CleanDeletedObjects();
+
+      // Remove expired DCI data
+      RWLockReadLock(g_rwlockNodeIndex, INFINITE);
+      for(i = 0; i < g_dwNodeAddrIndexSize; i++)
+         ((Node *)g_pNodeIndexByAddr[i].pObject)->CleanDCIData();
+      RWLockUnlock(g_rwlockNodeIndex);
    }
    return THREAD_OK;
 }
index ecb9cd1..fc4003a 100644 (file)
@@ -1505,3 +1505,18 @@ DWORD Node::GetLastValues(CSCPMessage *pMsg)
    Unlock();
    return RCC_SUCCESS;
 }
+
+
+//
+// Clean expired DCI data
+//
+
+void Node::CleanDCIData(void)
+{
+   DWORD i;
+
+   Lock();
+   for(i = 0; i < m_dwNumItems; i++)
+      m_ppItems[i]->CleanData();
+   Unlock();
+}
index 7c66adb..10a6a9f 100644 (file)
@@ -203,6 +203,8 @@ public:
 
    void CreateMessage(CSCPMessage *pMsg);
    void UpdateFromMessage(CSCPMessage *pMsg, DWORD *pdwNumMaps, DWORD **ppdwMapIndex, DWORD **ppdwMapId);
+
+   void CleanData(void);
 };
 
 
index a7fceed..ae9b33c 100644 (file)
@@ -432,6 +432,7 @@ public:
    void QueueItemsForPolling(Queue *pPollerQueue);
    DWORD GetItemForClient(int iOrigin, const char *pszParam, char *pszBuffer, DWORD dwBufSize);
    DWORD GetLastValues(CSCPMessage *pMsg);
+   void CleanDCIData(void);
 
    AgentConnection *CreateAgentConnection(void);