all pollers converted to single thread pool
[public/netxms.git] / src / server / core / datacoll.cpp
CommitLineData
5039dede
AK
1/*
2** NetXMS - Network Management System
3b21a646 3** Copyright (C) 2003-2015 Victor Kirhenshtein
5039dede
AK
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** File: datacoll.cpp
20**
21**/
22
23#include "nxcore.h"
24
46ee6286
VK
25/**
26 * Interval between DCI polling
27 */
2fe54eb1 28#define ITEM_POLLING_INTERVAL 1
5039dede 29
46ee6286
VK
30/**
31 * Externals
32 */
f1784ab6
VK
33extern Queue g_syslogProcessingQueue;
34extern Queue g_syslogWriteQueue;
5039dede 35
6fd6de0a
VK
36/**
37 * Global data
38 */
5039dede
AK
39double g_dAvgPollerQueueSize = 0;
40double g_dAvgDBWriterQueueSize = 0;
cf084617 41double g_dAvgIDataWriterQueueSize = 0;
76fcb995 42double g_dAvgRawDataWriterQueueSize = 0;
cf084617 43double g_dAvgDBAndIDataWriterQueueSize = 0;
f1784ab6
VK
44double g_dAvgSyslogProcessingQueueSize = 0;
45double g_dAvgSyslogWriterQueueSize = 0;
967893bb 46UINT32 g_dwAvgDCIQueuingTime = 0;
d140955e
VK
47Queue g_dataCollectionQueue(4096, 256);
48Queue g_dciCacheLoaderQueue;
5039dede 49
171c2fd6
VK
50/**
51 * Collect data for DCI
52 */
967893bb 53static void *GetItemData(DataCollectionTarget *dcTarget, DCItem *pItem, TCHAR *pBuffer, UINT32 *error)
df94e0ce 54{
c42b4551 55 if (dcTarget->getObjectClass() == OBJECT_CLUSTER)
df94e0ce 56 {
85ae39bc
VK
57 if (pItem->isAggregateOnCluster())
58 {
59 *error = ((Cluster *)dcTarget)->collectAggregatedData(pItem, pBuffer);
60 }
61 else
62 {
3cd6f508 63 *error = DCE_IGNORE;
85ae39bc
VK
64 }
65 }
66 else
67 {
68 switch(pItem->getDataSource())
69 {
70 case DS_INTERNAL: // Server internal parameters (like status)
71 *error = dcTarget->getInternalItem(pItem->getName(), MAX_LINE_SIZE, pBuffer);
72 break;
73 case DS_SNMP_AGENT:
c42b4551 74 if (dcTarget->getObjectClass() == OBJECT_NODE)
85ae39bc
VK
75 *error = ((Node *)dcTarget)->getItemFromSNMP(pItem->getSnmpPort(), pItem->getName(), MAX_LINE_SIZE,
76 pBuffer, pItem->isInterpretSnmpRawValue() ? (int)pItem->getSnmpRawValueType() : SNMP_RAWTYPE_NONE);
77 else
78 *error = DCE_NOT_SUPPORTED;
79 break;
80 case DS_CHECKPOINT_AGENT:
c42b4551 81 if (dcTarget->getObjectClass() == OBJECT_NODE)
85ae39bc
VK
82 *error = ((Node *)dcTarget)->getItemFromCheckPointSNMP(pItem->getName(), MAX_LINE_SIZE, pBuffer);
83 else
84 *error = DCE_NOT_SUPPORTED;
85 break;
86 case DS_NATIVE_AGENT:
c42b4551 87 if (dcTarget->getObjectClass() == OBJECT_NODE)
85ae39bc
VK
88 *error = ((Node *)dcTarget)->getItemFromAgent(pItem->getName(), MAX_LINE_SIZE, pBuffer);
89 else
90 *error = DCE_NOT_SUPPORTED;
91 break;
92 case DS_WINPERF:
c42b4551 93 if (dcTarget->getObjectClass() == OBJECT_NODE)
85ae39bc
VK
94 {
95 TCHAR name[MAX_PARAM_NAME];
96 _sntprintf(name, MAX_PARAM_NAME, _T("PDH.CounterValue(\"%s\",%d)"), pItem->getName(), pItem->getSampleCount());
97 *error = ((Node *)dcTarget)->getItemFromAgent(name, MAX_LINE_SIZE, pBuffer);
98 }
99 else
100 {
101 *error = DCE_NOT_SUPPORTED;
102 }
103 break;
1d0d82b3 104 case DS_SMCLP:
c42b4551 105 if (dcTarget->getObjectClass() == OBJECT_NODE)
03bc96df 106 {
1d0d82b3 107 *error = ((Node *)dcTarget)->getItemFromSMCLP(pItem->getName(), MAX_LINE_SIZE, pBuffer);
03bc96df 108 }
85ae39bc
VK
109 else
110 {
111 *error = DCE_NOT_SUPPORTED;
112 }
17b1ab4a
VK
113 break;
114 case DS_SCRIPT:
115 *error = dcTarget->getScriptItem(pItem->getName(), MAX_LINE_SIZE, pBuffer);
85ae39bc
VK
116 break;
117 default:
118 *error = DCE_NOT_SUPPORTED;
119 break;
120 }
df94e0ce
VK
121 }
122 return pBuffer;
123}
124
171c2fd6
VK
125/**
126 * Collect data for table
127 */
967893bb 128static void *GetTableData(DataCollectionTarget *dcTarget, DCTable *table, UINT32 *error)
df94e0ce
VK
129{
130 Table *result = NULL;
c42b4551 131 if (dcTarget->getObjectClass() == OBJECT_CLUSTER)
a0ddfb29
VK
132 {
133 if (table->isAggregateOnCluster())
134 {
135 *error = ((Cluster *)dcTarget)->collectAggregatedData(table, &result);
136 }
137 else
138 {
3cd6f508 139 *error = DCE_IGNORE;
a0ddfb29
VK
140 }
141 }
142 else
df94e0ce 143 {
a0ddfb29
VK
144 switch(table->getDataSource())
145 {
146 case DS_NATIVE_AGENT:
c42b4551 147 if (dcTarget->getObjectClass() == OBJECT_NODE)
a0ddfb29
VK
148 {
149 *error = ((Node *)dcTarget)->getTableFromAgent(table->getName(), &result);
150 if ((*error == DCE_SUCCESS) && (result != NULL))
151 table->updateResultColumns(result);
152 }
153 else
154 {
155 *error = DCE_NOT_SUPPORTED;
156 }
157 break;
db117859 158 case DS_SNMP_AGENT:
c42b4551 159 if (dcTarget->getObjectClass() == OBJECT_NODE)
db117859
VK
160 {
161 *error = ((Node *)dcTarget)->getTableFromSNMP(table->getSnmpPort(), table->getName(), table->getColumns(), &result);
162 if ((*error == DCE_SUCCESS) && (result != NULL))
163 table->updateResultColumns(result);
164 }
165 else
166 {
167 *error = DCE_NOT_SUPPORTED;
168 }
169 break;
a0ddfb29
VK
170 default:
171 *error = DCE_NOT_SUPPORTED;
172 break;
173 }
174 }
df94e0ce
VK
175 return result;
176}
177
6fd6de0a
VK
178/**
179 * Data collector
180 */
5039dede
AK
181static THREAD_RESULT THREAD_CALL DataCollector(void *pArg)
182{
967893bb 183 UINT32 dwError;
5039dede 184
df94e0ce 185 TCHAR *pBuffer = (TCHAR *)malloc(MAX_LINE_SIZE * sizeof(TCHAR));
89135050 186 while(!IsShutdownInProgress())
5039dede 187 {
19dbc8ef 188 DCObject *pItem = (DCObject *)g_dataCollectionQueue.getOrBlock();
6fd6de0a 189 DataCollectionTarget *target = (DataCollectionTarget *)pItem->getTarget();
ced80327
VK
190
191 if (pItem->isScheduledForDeletion())
192 {
6fd6de0a 193 DbgPrintf(7, _T("DataCollector(): about to destroy DC object %d \"%s\" owner=%d"),
c42b4551
VK
194 pItem->getId(), pItem->getName(), (target != NULL) ? (int)target->getId() : -1);
195 pItem->deleteFromDatabase();
ced80327
VK
196 delete pItem;
197 continue;
198 }
199
6fd6de0a 200 DbgPrintf(8, _T("DataCollector(): processing DC object %d \"%s\" owner=%d proxy=%d"),
c42b4551 201 pItem->getId(), pItem->getName(), (target != NULL) ? (int)target->getId() : -1, pItem->getProxyNode());
fb05c05b 202 if (pItem->getProxyNode() != 0)
5039dede 203 {
6fd6de0a 204 NetObj *object = FindObjectById(pItem->getProxyNode(), OBJECT_NODE);
5039dede
AK
205 if (object != NULL)
206 {
c42b4551 207 if (object->isTrustedNode((target != NULL) ? target->getId() : 0))
5039dede 208 {
6fd6de0a 209 target = (Node *)object;
21c9acce 210 target->incRefCount();
5039dede
AK
211 }
212 else
213 {
35f836fe 214 // Change item's status to _T("not supported")
a8f60046 215 pItem->setStatus(ITEM_STATUS_NOT_SUPPORTED, true);
5039dede 216
6fd6de0a 217 if (target != NULL)
5039dede 218 {
21c9acce 219 target->decRefCount();
6fd6de0a 220 target = NULL;
5039dede
AK
221 }
222 }
223 }
224 else
225 {
6fd6de0a 226 if (target != NULL)
5039dede 227 {
21c9acce 228 target->decRefCount();
6fd6de0a 229 target = NULL;
5039dede
AK
230 }
231 }
232 }
233
df94e0ce 234 time_t currTime = time(NULL);
6fd6de0a 235 if (target != NULL)
5039dede 236 {
df94e0ce 237 void *data;
5039dede 238
df94e0ce
VK
239 switch(pItem->getType())
240 {
241 case DCO_TYPE_ITEM:
6fd6de0a 242 data = GetItemData(target, (DCItem *)pItem, pBuffer, &dwError);
df94e0ce
VK
243 break;
244 case DCO_TYPE_TABLE:
6fd6de0a 245 data = GetTableData(target, (DCTable *)pItem, &dwError);
df94e0ce
VK
246 break;
247 default:
248 data = NULL;
249 dwError = DCE_NOT_SUPPORTED;
250 break;
251 }
5039dede
AK
252
253 // Transform and store received value into database or handle error
254 switch(dwError)
255 {
256 case DCE_SUCCESS:
fb05c05b 257 if (pItem->getStatus() == ITEM_STATUS_NOT_SUPPORTED)
a8f60046 258 pItem->setStatus(ITEM_STATUS_ACTIVE, true);
0156d6b2
VK
259 if (!((DataCollectionTarget *)pItem->getTarget())->processNewDCValue(pItem, currTime, data))
260 {
261 // value processing failed, convert to data collection error
262 pItem->processNewError();
263 }
5039dede
AK
264 break;
265 case DCE_COMM_ERROR:
0156d6b2
VK
266 if (pItem->getStatus() == ITEM_STATUS_NOT_SUPPORTED)
267 pItem->setStatus(ITEM_STATUS_ACTIVE, true);
fb05c05b 268 pItem->processNewError();
5039dede
AK
269 break;
270 case DCE_NOT_SUPPORTED:
271 // Change item's status
a8f60046 272 pItem->setStatus(ITEM_STATUS_NOT_SUPPORTED, true);
5039dede
AK
273 break;
274 }
275
5039dede 276 // Decrement node's usage counter
21c9acce 277 target->decRefCount();
6fd6de0a 278 if ((pItem->getProxyNode() != 0) && (pItem->getTarget() != NULL))
5039dede 279 {
21c9acce 280 pItem->getTarget()->decRefCount();
5039dede
AK
281 }
282 }
6fd6de0a 283 else /* target == NULL */
5039dede 284 {
6fd6de0a
VK
285 Template *n = pItem->getTarget();
286 DbgPrintf(3, _T("*** DataCollector: Attempt to collect information for non-existing node (DCI=%d \"%s\" target=%d proxy=%d)"),
c42b4551 287 pItem->getId(), pItem->getName(), (n != NULL) ? (int)n->getId() : -1, pItem->getProxyNode());
5039dede 288 }
61b48d2f
VK
289
290 // Update item's last poll time and clear busy flag so item can be polled again
291 pItem->setLastPollTime(currTime);
292 pItem->setBusyFlag(FALSE);
5039dede
AK
293 }
294
295 free(pBuffer);
35f836fe 296 DbgPrintf(1, _T("Data collector thread terminated"));
5039dede
AK
297 return THREAD_OK;
298}
299
6fd6de0a
VK
300/**
301 * Callback for queueing DCIs
302 */
6aba3998
VK
303static void QueueItems(NetObj *object, void *data)
304{
6fd6de0a 305 DbgPrintf(8, _T("ItemPoller: calling DataCollectionTarget::queueItemsForPolling for object %s [%d]"),
c42b4551 306 object->getName(), object->getId());
d140955e 307 ((DataCollectionTarget *)object)->queueItemsForPolling(&g_dataCollectionQueue);
6aba3998
VK
308}
309
6fd6de0a
VK
310/**
311 * Item poller thread: check nodes' items and put into the
312 * data collector queue when data polling required
313 */
5039dede
AK
314static THREAD_RESULT THREAD_CALL ItemPoller(void *pArg)
315{
f1784ab6 316 UINT32 dwSum, dwWatchdogId, currPos = 0;
967893bb 317 UINT32 dwTimingHistory[60 / ITEM_POLLING_INTERVAL];
5039dede
AK
318 INT64 qwStart;
319
35f836fe 320 dwWatchdogId = WatchdogAddThread(_T("Item Poller"), 20);
967893bb 321 memset(dwTimingHistory, 0, sizeof(UINT32) * (60 / ITEM_POLLING_INTERVAL));
5039dede 322
89135050 323 while(!IsShutdownInProgress())
5039dede
AK
324 {
325 if (SleepAndCheckForShutdown(ITEM_POLLING_INTERVAL))
326 break; // Shutdown has arrived
327 WatchdogNotify(dwWatchdogId);
328 DbgPrintf(8, _T("ItemPoller: wakeup"));
329
5039dede 330 qwStart = GetCurrentTimeMs();
6aba3998 331 g_idxNodeById.forEach(QueueItems, NULL);
85ae39bc 332 g_idxClusterById.forEach(QueueItems, NULL);
6fd6de0a 333 g_idxMobileDeviceById.forEach(QueueItems, NULL);
5039dede
AK
334
335 // Save last poll time
f1784ab6
VK
336 dwTimingHistory[currPos] = (UINT32)(GetCurrentTimeMs() - qwStart);
337 currPos++;
338 if (currPos == (60 / ITEM_POLLING_INTERVAL))
339 currPos = 0;
5039dede
AK
340
341 // Calculate new average for last minute
6aba3998
VK
342 dwSum = 0;
343 for(int i = 0; i < (60 / ITEM_POLLING_INTERVAL); i++)
5039dede
AK
344 dwSum += dwTimingHistory[i];
345 g_dwAvgDCIQueuingTime = dwSum / (60 / ITEM_POLLING_INTERVAL);
346 }
35f836fe 347 DbgPrintf(1, _T("Item poller thread terminated"));
5039dede
AK
348 return THREAD_OK;
349}
350
6fd6de0a
VK
351/**
352 * Statistics collection thread
353 */
5039dede
AK
354static THREAD_RESULT THREAD_CALL StatCollector(void *pArg)
355{
f1784ab6
VK
356 UINT32 i, currPos = 0;
357 UINT32 pollerQS[12], dbWriterQS[12];
76fcb995 358 UINT32 iDataWriterQS[12], rawDataWriterQS[12], dbAndIDataWriterQS[12];
f1784ab6 359 UINT32 syslogProcessingQS[12], syslogWriterQS[12];
208d7427 360 double sum1, sum2, sum3, sum4, sum5, sum8, sum9;
5039dede 361
f1784ab6
VK
362 memset(pollerQS, 0, sizeof(UINT32) * 12);
363 memset(dbWriterQS, 0, sizeof(UINT32) * 12);
364 memset(iDataWriterQS, 0, sizeof(UINT32) * 12);
76fcb995 365 memset(rawDataWriterQS, 0, sizeof(UINT32) * 12);
f1784ab6 366 memset(dbAndIDataWriterQS, 0, sizeof(UINT32) * 12);
f1784ab6
VK
367 memset(syslogProcessingQS, 0, sizeof(UINT32) * 12);
368 memset(syslogWriterQS, 0, sizeof(UINT32) * 12);
5039dede
AK
369 g_dAvgPollerQueueSize = 0;
370 g_dAvgDBWriterQueueSize = 0;
cf084617 371 g_dAvgIDataWriterQueueSize = 0;
76fcb995 372 g_dAvgRawDataWriterQueueSize = 0;
cf084617 373 g_dAvgDBAndIDataWriterQueueSize = 0;
f1784ab6
VK
374 g_dAvgSyslogProcessingQueueSize = 0;
375 g_dAvgSyslogWriterQueueSize = 0;
89135050 376 while(!IsShutdownInProgress())
5039dede
AK
377 {
378 if (SleepAndCheckForShutdown(5))
379 break; // Shutdown has arrived
380
381 // Get current values
19dbc8ef
VK
382 pollerQS[currPos] = g_dataCollectionQueue.size();
383 dbWriterQS[currPos] = g_dbWriterQueue->size();
384 iDataWriterQS[currPos] = g_dciDataWriterQueue->size();
385 rawDataWriterQS[currPos] = g_dciRawDataWriterQueue->size();
386 dbAndIDataWriterQS[currPos] = g_dbWriterQueue->size() + g_dciDataWriterQueue->size() + g_dciRawDataWriterQueue->size();
19dbc8ef
VK
387 syslogProcessingQS[currPos] = g_syslogProcessingQueue.size();
388 syslogWriterQS[currPos] = g_syslogWriteQueue.size();
f1784ab6
VK
389 currPos++;
390 if (currPos == 12)
391 currPos = 0;
5039dede
AK
392
393 // Calculate new averages
208d7427 394 for(i = 0, sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0, sum5 = 0, sum8 = 0, sum9 = 0; i < 12; i++)
5039dede 395 {
f1784ab6
VK
396 sum1 += pollerQS[i];
397 sum2 += dbWriterQS[i];
398 sum3 += iDataWriterQS[i];
76fcb995
VK
399 sum4 += rawDataWriterQS[i];
400 sum5 += dbAndIDataWriterQS[i];
76fcb995
VK
401 sum8 += syslogProcessingQS[i];
402 sum9 += syslogWriterQS[i];
5039dede 403 }
f1784ab6
VK
404 g_dAvgPollerQueueSize = sum1 / 12;
405 g_dAvgDBWriterQueueSize = sum2 / 12;
406 g_dAvgIDataWriterQueueSize = sum3 / 12;
76fcb995
VK
407 g_dAvgRawDataWriterQueueSize = sum4 / 12;
408 g_dAvgDBAndIDataWriterQueueSize = sum5 / 12;
76fcb995
VK
409 g_dAvgSyslogProcessingQueueSize = sum8 / 12;
410 g_dAvgSyslogWriterQueueSize = sum9 / 12;
5039dede
AK
411 }
412 return THREAD_OK;
413}
414
d140955e
VK
415/**
416 * DCI cache loader
417 */
418THREAD_RESULT THREAD_CALL CacheLoader(void *arg)
419{
420 DbgPrintf(2, _T("DCI cache loader thread started"));
421 while(true)
422 {
19dbc8ef 423 DCItem *dci = (DCItem *)g_dciCacheLoaderQueue.getOrBlock();
d140955e
VK
424 if (dci == INVALID_POINTER_VALUE)
425 break;
426
427 DbgPrintf(6, _T("Loading cache for DCI %s [%d] on %s [%d]"),
428 dci->getName(), dci->getId(), dci->getNode()->getName(), dci->getNode()->getId());
429 dci->reloadCache();
430 dci->getNode()->decRefCount();
431 }
432 DbgPrintf(2, _T("DCI cache loader thread stopped"));
433 return THREAD_OK;
434}
435
6fd6de0a
VK
436/**
437 * Initialize data collection subsystem
438 */
4fe87cdc 439BOOL InitDataCollector()
5039dede
AK
440{
441 int i, iNumCollectors;
442
5039dede 443 // Start data collection threads
35f836fe 444 iNumCollectors = ConfigReadInt(_T("NumberOfDataCollectors"), 10);
5039dede
AK
445 for(i = 0; i < iNumCollectors; i++)
446 ThreadCreate(DataCollector, 0, NULL);
447
5039dede 448 ThreadCreate(ItemPoller, 0, NULL);
5039dede 449 ThreadCreate(StatCollector, 0, NULL);
d140955e 450 ThreadCreate(CacheLoader, 0, NULL);
5039dede
AK
451
452 return TRUE;
453}
454
d140955e
VK
455/**
456 * Update parameter list from node
457 */
6aba3998
VK
458static void UpdateParamList(NetObj *object, void *data)
459{
86c126f5 460 ObjectArray<AgentParameterDefinition> *fullList = (ObjectArray<AgentParameterDefinition> *)data;
6aba3998 461
86c126f5 462 ObjectArray<AgentParameterDefinition> *paramList;
cc8ce218
VK
463 ((Node *)object)->openParamList(&paramList);
464 if ((paramList != NULL) && (paramList->size() > 0))
6aba3998 465 {
cc8ce218 466 for(int i = 0; i < paramList->size(); i++)
889d7ff7 467 {
86c126f5
VK
468 int j;
469 for(j = 0; j < fullList->size(); j++)
889d7ff7 470 {
86c126f5 471 if (!_tcsicmp(paramList->get(i)->getName(), fullList->get(j)->getName()))
6aba3998
VK
472 break;
473 }
474
86c126f5 475 if (j == fullList->size())
6aba3998 476 {
86c126f5 477 fullList->add(new AgentParameterDefinition(paramList->get(i)));
889d7ff7 478 }
889d7ff7 479 }
6aba3998 480 }
f1ff4cc9 481 ((Node *)object)->closeParamList();
6aba3998
VK
482}
483
d140955e
VK
484/**
485 * Update table list from node
486 */
074498ac
VK
487static void UpdateTableList(NetObj *object, void *data)
488{
86c126f5 489 ObjectArray<AgentTableDefinition> *fullList = (ObjectArray<AgentTableDefinition> *)data;
074498ac 490
86c126f5 491 ObjectArray<AgentTableDefinition> *tableList;
074498ac
VK
492 ((Node *)object)->openTableList(&tableList);
493 if ((tableList != NULL) && (tableList->size() > 0))
494 {
074498ac
VK
495 for(int i = 0; i < tableList->size(); i++)
496 {
86c126f5
VK
497 int j;
498 for(j = 0; j < fullList->size(); j++)
074498ac 499 {
86c126f5 500 if (!_tcsicmp(tableList->get(i)->getName(), fullList->get(j)->getName()))
074498ac
VK
501 break;
502 }
503
86c126f5 504 if (j == fullList->size())
074498ac 505 {
86c126f5 506 fullList->add(new AgentTableDefinition(tableList->get(i)));
074498ac
VK
507 }
508 }
509 }
510 ((Node *)object)->closeTableList();
511}
512
d140955e
VK
513/**
514 * Write full (from all nodes) agent parameters list to NXCP message
515 */
b368969c 516void WriteFullParamListToMessage(NXCPMessage *pMsg, WORD flags)
6aba3998
VK
517{
518 // Gather full parameter list
074498ac
VK
519 if (flags & 0x01)
520 {
86c126f5 521 ObjectArray<AgentParameterDefinition> fullList(64, 64, true);
074498ac
VK
522 g_idxNodeById.forEach(UpdateParamList, &fullList);
523
524 // Put list into the message
b368969c 525 pMsg->setField(VID_NUM_PARAMETERS, (UINT32)fullList.size());
967893bb 526 UINT32 varId = VID_PARAM_LIST_BASE;
86c126f5 527 for(int i = 0; i < fullList.size(); i++)
074498ac 528 {
86c126f5 529 varId += fullList.get(i)->fillMessage(pMsg, varId);
074498ac 530 }
074498ac
VK
531 }
532
533 // Gather full table list
534 if (flags & 0x02)
535 {
86c126f5 536 ObjectArray<AgentTableDefinition> fullList(64, 64, true);
074498ac
VK
537 g_idxNodeById.forEach(UpdateTableList, &fullList);
538
539 // Put list into the message
b368969c 540 pMsg->setField(VID_NUM_TABLES, (UINT32)fullList.size());
967893bb 541 UINT32 varId = VID_TABLE_LIST_BASE;
86c126f5 542 for(int i = 0; i < fullList.size(); i++)
074498ac 543 {
86c126f5 544 varId += fullList.get(i)->fillMessage(pMsg, varId);
074498ac 545 }
074498ac 546 }
5039dede 547}
9fddfb91
VK
548
549/**
550 * Get type of data collection object
551 */
552int GetDCObjectType(UINT32 nodeId, UINT32 dciId)
553{
554 Node *node = (Node *)FindObjectById(nodeId, OBJECT_NODE);
555 if (node != NULL)
556 {
557 DCObject *dco = node->getDCObjectById(dciId);
558 if (dco != NULL)
559 {
560 return dco->getType();
561 }
562 }
563 return DCO_TYPE_ITEM; // default
564}