additional agent metrics for self-monitoring (SNMP proxy and syslog proxy stats)
[public/netxms.git] / src / agent / core / getparam.cpp
1 /*
2 ** NetXMS multiplatform core agent
3 ** Copyright (C) 2003-2016 Victor Kirhenshtein
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: getparam.cpp
20 **
21 **/
22
23 #include "nxagentd.h"
24
25 /**
26 * Parameter handlers
27 */
28 LONG H_ActionList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
29 LONG H_ActiveConnections(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
30 LONG H_AgentTraps(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
31 LONG H_AgentUptime(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
32 LONG H_CRC32(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
33 LONG H_DataCollectorQueueSize(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
34 LONG H_DirInfo(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
35 LONG H_ExternalParameter(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
36 LONG H_ExternalList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
37 LONG H_FileTime(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
38 LONG H_IsSubagentLoaded(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
39 LONG H_MD5Hash(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
40 LONG H_PlatformName(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
41 LONG H_ResolverAddrByName(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
42 LONG H_ResolverNameByAddr(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
43 LONG H_SessionAgents(const TCHAR *cmd, const TCHAR *arg, Table *value, AbstractCommSession *session);
44 LONG H_SHA1Hash(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
45 LONG H_SNMPProxyStats(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
46 LONG H_SubAgentList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
47 LONG H_SubAgentTable(const TCHAR *cmd, const TCHAR *arg, Table *value, AbstractCommSession *session);
48 LONG H_SyslogStats(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
49 LONG H_SystemTime(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
50 LONG H_ThreadPoolInfo(const TCHAR *param, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
51 LONG H_ThreadPoolList(const TCHAR *param, const TCHAR *arg, StringList *value, AbstractCommSession *session);
52
53 #ifdef _WIN32
54 LONG H_CPUCount(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
55 LONG H_DiskInfo(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
56 LONG H_FileSystems(const TCHAR *cmd, const TCHAR *arg, Table *value, AbstractCommSession *session);
57 LONG H_FileSystemType(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
58 LONG H_HostName(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
59 LONG H_MemoryInfo(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
60 LONG H_MountPoints(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
61 LONG H_PhysicalDiskInfo(const TCHAR *cmd, const TCHAR *arg, TCHAR *pValue, AbstractCommSession *session);
62 LONG H_SystemUname(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
63 #endif
64
65 /**
66 * Static data
67 */
68 static NETXMS_SUBAGENT_PARAM *m_pParamList = NULL;
69 static int m_iNumParams = 0;
70 static NETXMS_SUBAGENT_PUSHPARAM *m_pPushParamList = NULL;
71 static int m_iNumPushParams = 0;
72 static NETXMS_SUBAGENT_LIST *m_pEnumList = NULL;
73 static int m_iNumEnums = 0;
74 static NETXMS_SUBAGENT_TABLE *m_pTableList = NULL;
75 static int m_iNumTables = 0;
76 static UINT32 m_dwTimedOutRequests = 0;
77 static UINT32 m_dwAuthenticationFailures = 0;
78 static UINT32 m_dwProcessedRequests = 0;
79 static UINT32 m_dwFailedRequests = 0;
80 static UINT32 m_dwUnsupportedRequests = 0;
81
82 /**
83 * Handler for parameters which always returns string constant
84 */
85 static LONG H_StringConstant(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session)
86 {
87 ret_string(value, arg);
88 return SYSINFO_RC_SUCCESS;
89 }
90
91 /**
92 * Handler for parameters which returns UINT32 value from specific variable
93 */
94 static LONG H_UIntPtr(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session)
95 {
96 ret_uint(value, *((UINT32 *)arg));
97 return SYSINFO_RC_SUCCESS;
98 }
99
100 /**
101 * Handler for Agent.SupportedCiphers
102 */
103 static LONG H_SupportedCiphers(const TCHAR *pszCmd, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
104 {
105 UINT32 dwCiphers;
106
107 dwCiphers = NXCPGetSupportedCiphers();
108 if (dwCiphers == 0)
109 {
110 ret_string(pValue, _T("NONE"));
111 }
112 else
113 {
114 *pValue = 0;
115 if (dwCiphers & NXCP_SUPPORT_AES_256)
116 _tcscat(pValue, _T("AES-256 "));
117 if (dwCiphers & NXCP_SUPPORT_AES_128)
118 _tcscat(pValue, _T("AES-128 "));
119 if (dwCiphers & NXCP_SUPPORT_BLOWFISH_256)
120 _tcscat(pValue, _T("BF-256 "));
121 if (dwCiphers & NXCP_SUPPORT_BLOWFISH_128)
122 _tcscat(pValue, _T("BF-128 "));
123 if (dwCiphers & NXCP_SUPPORT_IDEA)
124 _tcscat(pValue, _T("IDEA "));
125 if (dwCiphers & NXCP_SUPPORT_3DES)
126 _tcscat(pValue, _T("3DES "));
127 pValue[_tcslen(pValue) - 1] = 0;
128 }
129 return SYSINFO_RC_SUCCESS;
130 }
131
132 /**
133 * Handler for parameters list
134 */
135 static LONG H_ParamList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session)
136 {
137 int i;
138
139 for(i = 0; i < m_iNumParams; i++)
140 if (m_pParamList[i].dataType != DCI_DT_DEPRECATED)
141 value->add(m_pParamList[i].name);
142 ListParametersFromExtProviders(value);
143 ListParametersFromExtSubagents(value);
144 return SYSINFO_RC_SUCCESS;
145 }
146
147 /**
148 * Handler for push parameters list
149 */
150 static LONG H_PushParamList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session)
151 {
152 int i;
153
154 for(i = 0; i < m_iNumPushParams; i++)
155 value->add(m_pPushParamList[i].name);
156 return SYSINFO_RC_SUCCESS;
157 }
158
159 /**
160 * Handler for enums list
161 */
162 static LONG H_EnumList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session)
163 {
164 int i;
165
166 for(i = 0; i < m_iNumEnums; i++)
167 value->add(m_pEnumList[i].name);
168 ListListsFromExtSubagents(value);
169 return SYSINFO_RC_SUCCESS;
170 }
171
172 /**
173 * Handler for table list
174 */
175 static LONG H_TableList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session)
176 {
177 int i;
178
179 for(i = 0; i < m_iNumTables; i++)
180 value->add(m_pTableList[i].name);
181 ListTablesFromExtSubagents(value);
182 return SYSINFO_RC_SUCCESS;
183 }
184
185 /**
186 * Handler for component statuses based on failure flags
187 */
188 static LONG H_ComponentStatus(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
189 {
190 UINT32 result = 0;
191 switch(*pArg)
192 {
193 case 'D':
194 if ((g_failFlags & FAIL_OPEN_DATABASE) != 0)
195 result++;
196 if ((g_failFlags & FAIL_UPGRADE_DATABASE) != 0)
197 result++;
198 break;
199 case 'L':
200 if ((g_failFlags & FAIL_OPEN_LOG) != 0)
201 result++;
202 break;
203 }
204
205 ret_uint(pValue, result);
206 return SYSINFO_RC_SUCCESS;
207 }
208
209 /**
210 * Handler for local database counters
211 */
212 static LONG H_LocalDatabaseCounters(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
213 {
214 LIBNXDB_PERF_COUNTERS counters;
215 DBGetPerfCounters(&counters);
216 switch(*pArg)
217 {
218 case 'F':
219 ret_int64(pValue, counters.failedQueries);
220 break;
221 case 'L':
222 ret_int64(pValue, counters.longRunningQueries);
223 break;
224 case 'T':
225 ret_int64(pValue, counters.totalQueries);
226 break;
227 default:
228 return SYSINFO_RC_UNSUPPORTED;
229 }
230 return SYSINFO_RC_SUCCESS;
231 }
232
233 /**
234 * Handler for flag query parameters
235 */
236 static LONG H_FlagValue(const TCHAR *param, const TCHAR *arg, TCHAR *value, AbstractCommSession *session)
237 {
238 UINT32 flag = CAST_FROM_POINTER(arg, UINT32);
239 ret_int(value, (g_dwFlags & flag) ? 1 : 0);
240 return SYSINFO_RC_SUCCESS;
241 }
242
243 /**
244 * Standard agent's parameters
245 */
246 static NETXMS_SUBAGENT_PARAM m_stdParams[] =
247 {
248 #ifdef _WIN32
249 { _T("Disk.Free(*)"), H_DiskInfo, (TCHAR *)DISKINFO_FREE_BYTES, DCI_DT_DEPRECATED, DCIDESC_DEPRECATED },
250 { _T("Disk.FreePerc(*)"), H_DiskInfo, (TCHAR *)DISKINFO_FREE_SPACE_PCT, DCI_DT_DEPRECATED, DCIDESC_DEPRECATED },
251 { _T("Disk.Total(*)"), H_DiskInfo, (TCHAR *)DISKINFO_TOTAL_BYTES, DCI_DT_DEPRECATED, DCIDESC_DEPRECATED },
252 { _T("Disk.Used(*)"), H_DiskInfo, (TCHAR *)DISKINFO_USED_BYTES, DCI_DT_DEPRECATED, DCIDESC_DEPRECATED },
253 { _T("Disk.UsedPerc(*)"), H_DiskInfo, (TCHAR *)DISKINFO_USED_SPACE_PCT, DCI_DT_DEPRECATED, DCIDESC_DEPRECATED },
254 { _T("FileSystem.Free(*)"), H_DiskInfo, (TCHAR *)DISKINFO_FREE_BYTES, DCI_DT_UINT64, DCIDESC_FS_FREE },
255 { _T("FileSystem.FreePerc(*)"), H_DiskInfo, (TCHAR *)DISKINFO_FREE_SPACE_PCT, DCI_DT_FLOAT, DCIDESC_FS_FREEPERC },
256 { _T("FileSystem.Total(*)"), H_DiskInfo, (TCHAR *)DISKINFO_TOTAL_BYTES, DCI_DT_UINT64, DCIDESC_FS_TOTAL },
257 { _T("FileSystem.Type(*)"), H_FileSystemType, NULL, DCI_DT_STRING, DCIDESC_FS_TYPE },
258 { _T("FileSystem.Used(*)"), H_DiskInfo, (TCHAR *)DISKINFO_USED_BYTES, DCI_DT_UINT64, DCIDESC_FS_USED },
259 { _T("FileSystem.UsedPerc(*)"), H_DiskInfo, (TCHAR *)DISKINFO_USED_SPACE_PCT, DCI_DT_FLOAT, DCIDESC_FS_USEDPERC },
260 { _T("PhysicalDisk.Firmware(*)"), H_PhysicalDiskInfo, _T("F"), DCI_DT_STRING, DCIDESC_PHYSICALDISK_FIRMWARE },
261 { _T("PhysicalDisk.Model(*)"), H_PhysicalDiskInfo, _T("M"), DCI_DT_STRING, DCIDESC_PHYSICALDISK_MODEL },
262 { _T("PhysicalDisk.SerialNumber(*)"), H_PhysicalDiskInfo, _T("N"), DCI_DT_STRING, DCIDESC_PHYSICALDISK_SERIALNUMBER },
263 { _T("PhysicalDisk.SmartAttr(*)"), H_PhysicalDiskInfo, _T("A"), DCI_DT_STRING, DCIDESC_PHYSICALDISK_SMARTATTR },
264 { _T("PhysicalDisk.SmartStatus(*)"), H_PhysicalDiskInfo, _T("S"), DCI_DT_INT, DCIDESC_PHYSICALDISK_SMARTSTATUS },
265 { _T("PhysicalDisk.Temperature(*)"), H_PhysicalDiskInfo, _T("T"), DCI_DT_INT, DCIDESC_PHYSICALDISK_TEMPERATURE },
266 { _T("System.CPU.Count"), H_CPUCount, NULL, DCI_DT_UINT, DCIDESC_SYSTEM_CPU_COUNT },
267 { _T("System.Hostname"), H_HostName, NULL, DCI_DT_STRING, DCIDESC_SYSTEM_HOSTNAME },
268 { _T("System.Memory.Physical.Available"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_FREE, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_AVAILABLE },
269 { _T("System.Memory.Physical.AvailablePerc"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_FREE_PCT, DCI_DT_UINT, DCIDESC_SYSTEM_MEMORY_PHYSICAL_AVAILABLE_PCT },
270 { _T("System.Memory.Physical.Free"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_FREE, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE },
271 { _T("System.Memory.Physical.FreePerc"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_FREE_PCT, DCI_DT_UINT, DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE_PCT },
272 { _T("System.Memory.Physical.Total"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_TOTAL, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_TOTAL },
273 { _T("System.Memory.Physical.Used"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_USED, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED },
274 { _T("System.Memory.Physical.UsedPerc"), H_MemoryInfo, (TCHAR *)MEMINFO_PHYSICAL_USED_PCT, DCI_DT_UINT, DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED_PCT },
275 { _T("System.Memory.Virtual.Free"), H_MemoryInfo, (TCHAR *)MEMINFO_VIRTUAL_FREE, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE },
276 { _T("System.Memory.Virtual.FreePerc"), H_MemoryInfo, (TCHAR *)MEMINFO_VIRTUAL_FREE_PCT, DCI_DT_UINT, DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE_PCT },
277 { _T("System.Memory.Virtual.Total"), H_MemoryInfo, (TCHAR *)MEMINFO_VIRTUAL_TOTAL, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_VIRTUAL_TOTAL },
278 { _T("System.Memory.Virtual.Used"), H_MemoryInfo, (TCHAR *)MEMINFO_VIRTUAL_USED, DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED },
279 { _T("System.Memory.Virtual.UsedPerc"), H_MemoryInfo, (TCHAR *)MEMINFO_VIRTUAL_USED_PCT, DCI_DT_UINT, DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED_PCT },
280 { _T("System.Uname"), H_SystemUname, NULL, DCI_DT_STRING, DCIDESC_SYSTEM_UNAME },
281 #endif
282
283 { _T("Agent.AcceptedConnections"), H_UIntPtr, (TCHAR *)&g_dwAcceptedConnections, DCI_DT_UINT, DCIDESC_AGENT_ACCEPTEDCONNECTIONS },
284 { _T("Agent.AcceptErrors"), H_UIntPtr, (TCHAR *)&g_dwAcceptErrors, DCI_DT_UINT, DCIDESC_AGENT_ACCEPTERRORS },
285 { _T("Agent.ActiveConnections"), H_ActiveConnections, NULL, DCI_DT_UINT, DCIDESC_AGENT_ACTIVECONNECTIONS },
286 { _T("Agent.AuthenticationFailures"), H_UIntPtr, (TCHAR *)&m_dwAuthenticationFailures, DCI_DT_UINT, DCIDESC_AGENT_AUTHENTICATIONFAILURES },
287 { _T("Agent.ConfigurationServer"), H_StringConstant, g_szConfigServer, DCI_DT_STRING, DCIDESC_AGENT_CONFIG_SERVER },
288 { _T("Agent.DataCollectorQueueSize"), H_DataCollectorQueueSize, NULL, DCI_DT_UINT, DCIDESC_AGENT_DATACOLLQUEUESIZE },
289 { _T("Agent.FailedRequests"), H_UIntPtr, (TCHAR *)&m_dwFailedRequests, DCI_DT_UINT, DCIDESC_AGENT_FAILEDREQUESTS },
290 { _T("Agent.GeneratedTraps"), H_AgentTraps, _T("G"), DCI_DT_UINT64, DCIDESC_AGENT_GENERATED_TRAPS },
291 { _T("Agent.IsSubagentLoaded(*)"), H_IsSubagentLoaded, NULL, DCI_DT_INT, DCIDESC_AGENT_IS_SUBAGENT_LOADED },
292 { _T("Agent.LastTrapTime"), H_AgentTraps, _T("T"), DCI_DT_UINT64, DCIDESC_AGENT_LAST_TRAP_TIME },
293 { _T("Agent.LocalDatabase.FailedQueries"), H_LocalDatabaseCounters, _T("F"), DCI_DT_UINT64, DCIDESC_AGENT_LOCALDB_FAILED_QUERIES },
294 { _T("Agent.LocalDatabase.LongRunningQueries"), H_LocalDatabaseCounters, _T("L"), DCI_DT_UINT64, DCIDESC_AGENT_LOCALDB_SLOW_QUERIES },
295 { _T("Agent.LocalDatabase.Status"), H_ComponentStatus, _T("D"), DCI_DT_UINT, DCIDESC_AGENT_LOCALDB_STATUS },
296 { _T("Agent.LocalDatabase.TotalQueries"), H_LocalDatabaseCounters, _T("T"), DCI_DT_UINT64, DCIDESC_AGENT_LOCALDB_TOTAL_QUERIES },
297 { _T("Agent.LogFile.Status"), H_ComponentStatus, _T("L"), DCI_DT_UINT, DCIDESC_AGENT_LOG_STATUS },
298 { _T("Agent.ProcessedRequests"), H_UIntPtr, (TCHAR *)&m_dwProcessedRequests, DCI_DT_UINT, DCIDESC_AGENT_PROCESSEDREQUESTS },
299 { _T("Agent.Registrar"), H_StringConstant, g_szRegistrar, DCI_DT_STRING, DCIDESC_AGENT_REGISTRAR },
300 { _T("Agent.RejectedConnections"), H_UIntPtr, (TCHAR *)&g_dwRejectedConnections, DCI_DT_UINT, DCIDESC_AGENT_REJECTEDCONNECTIONS },
301 { _T("Agent.SentTraps"), H_AgentTraps, _T("S"), DCI_DT_UINT64, DCIDESC_AGENT_SENT_TRAPS },
302 { _T("Agent.SNMP.IsProxyEnabled"), H_FlagValue, CAST_TO_POINTER(AF_ENABLE_SNMP_PROXY, TCHAR *), DCI_DT_UINT, DCIDESC_AGENT_SNMP_ISPROXYENABLED },
303 { _T("Agent.SNMP.IsTrapProxyEnabled"), H_FlagValue, CAST_TO_POINTER(AF_ENABLE_SNMP_TRAP_PROXY, TCHAR *), DCI_DT_UINT, DCIDESC_AGENT_SNMP_ISPROXYENABLED },
304 { _T("Agent.SNMP.Requests"), H_SNMPProxyStats, _T("R"), DCI_DT_UINT64, DCIDESC_AGENT_SNMP_REQUESTS },
305 { _T("Agent.SNMP.Responses"), H_SNMPProxyStats, _T("r"), DCI_DT_UINT64, DCIDESC_AGENT_SNMP_RESPONSES },
306 { _T("Agent.SNMP.ServerRequests"), H_SNMPProxyStats, _T("S"), DCI_DT_UINT64, DCIDESC_AGENT_SNMP_SERVERREQUESTS },
307 { _T("Agent.SourcePackageSupport"), H_StringConstant, _T("0"), DCI_DT_INT, DCIDESC_AGENT_SOURCEPACKAGESUPPORT },
308 { _T("Agent.SupportedCiphers"), H_SupportedCiphers, NULL, DCI_DT_STRING, DCIDESC_AGENT_SUPPORTEDCIPHERS },
309 { _T("Agent.SyslogProxy.IsEnabled"), H_FlagValue, CAST_TO_POINTER(AF_ENABLE_SYSLOG_PROXY, TCHAR *), DCI_DT_UINT, DCIDESC_AGENT_SYSLOGPROXY_ISENABLED },
310 { _T("Agent.SyslogProxy.ReceivedMessages"), H_SyslogStats, _T("R"), DCI_DT_UINT64, DCIDESC_AGENT_SYSLOGPROXY_RECEIVEDMSGS },
311 { _T("Agent.SyslogProxy.QueueSize"), H_SyslogStats, _T("Q"), DCI_DT_UINT, DCIDESC_AGENT_SYSLOGPROXY_QUEUESIZE },
312 { _T("Agent.ThreadPool.ActiveRequests(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_REQUESTS, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_ACTIVEREQUESTS },
313 { _T("Agent.ThreadPool.CurrSize(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_CURR_SIZE, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_CURRSIZE },
314 { _T("Agent.ThreadPool.Load(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_LOAD, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_LOAD },
315 { _T("Agent.ThreadPool.LoadAverage(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_LOADAVG_1, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_LOADAVG },
316 { _T("Agent.ThreadPool.LoadAverage5(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_LOADAVG_5, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_LOADAVG_5 },
317 { _T("Agent.ThreadPool.LoadAverage15(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_LOADAVG_15, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_LOADAVG_15 },
318 { _T("Agent.ThreadPool.MaxSize(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_MAX_SIZE, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_MAXSIZE },
319 { _T("Agent.ThreadPool.MinSize(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_MIN_SIZE, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_MINSIZE },
320 { _T("Agent.ThreadPool.Usage(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_USAGE, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_USAGE },
321 { _T("Agent.TimedOutRequests"), H_UIntPtr, (TCHAR *)&m_dwTimedOutRequests, DCI_DT_UINT, DCIDESC_AGENT_TIMEDOUTREQUESTS },
322 { _T("Agent.UnsupportedRequests"), H_UIntPtr, (TCHAR *)&m_dwUnsupportedRequests, DCI_DT_UINT, DCIDESC_AGENT_UNSUPPORTEDREQUESTS },
323 { _T("Agent.Uptime"), H_AgentUptime, NULL, DCI_DT_UINT, DCIDESC_AGENT_UPTIME },
324 { _T("Agent.Version"), H_StringConstant, AGENT_VERSION_STRING, DCI_DT_STRING, DCIDESC_AGENT_VERSION },
325 { _T("File.Count(*)"), H_DirInfo, (TCHAR *)DIRINFO_FILE_COUNT, DCI_DT_UINT, DCIDESC_FILE_COUNT },
326 { _T("File.FolderCount(*)"), H_DirInfo, (TCHAR *)DIRINFO_FOLDER_COUNT, DCI_DT_UINT, DCIDESC_FILE_FOLDERCOUNT },
327 { _T("File.Hash.CRC32(*)"), H_CRC32, NULL, DCI_DT_UINT, DCIDESC_FILE_HASH_CRC32 },
328 { _T("File.Hash.MD5(*)"), H_MD5Hash, NULL, DCI_DT_STRING, DCIDESC_FILE_HASH_MD5 },
329 { _T("File.Hash.SHA1(*)"), H_SHA1Hash, NULL, DCI_DT_STRING, DCIDESC_FILE_HASH_SHA1 },
330 { _T("File.Size(*)"), H_DirInfo, (TCHAR *)DIRINFO_FILE_SIZE, DCI_DT_UINT64, DCIDESC_FILE_SIZE },
331 { _T("File.Time.Access(*)"), H_FileTime, (TCHAR *)FILETIME_ATIME, DCI_DT_UINT64, DCIDESC_FILE_TIME_ACCESS },
332 { _T("File.Time.Change(*)"), H_FileTime, (TCHAR *)FILETIME_CTIME, DCI_DT_UINT64, DCIDESC_FILE_TIME_CHANGE },
333 { _T("File.Time.Modify(*)"), H_FileTime, (TCHAR *)FILETIME_MTIME, DCI_DT_UINT64, DCIDESC_FILE_TIME_MODIFY },
334 { _T("Net.Resolver.AddressByName(*)"), H_ResolverAddrByName, NULL, DCI_DT_STRING, DCIDESC_NET_RESOLVER_ADDRBYNAME },
335 { _T("Net.Resolver.NameByAddress(*)"), H_ResolverNameByAddr, NULL, DCI_DT_STRING, DCIDESC_NET_RESOLVER_NAMEBYADDR },
336 { _T("System.CurrentTime"), H_SystemTime, NULL, DCI_DT_INT64, DCIDESC_SYSTEM_CURRENTTIME },
337 { _T("System.PlatformName"), H_PlatformName, NULL, DCI_DT_STRING, DCIDESC_SYSTEM_PLATFORMNAME }
338 };
339
340 /**
341 * Standard agent's lists
342 */
343 static NETXMS_SUBAGENT_LIST m_stdLists[] =
344 {
345 #ifdef _WIN32
346 { _T("FileSystem.MountPoints"), H_MountPoints, NULL },
347 #endif
348 { _T("Agent.ActionList"), H_ActionList, NULL },
349 { _T("Agent.SubAgentList"), H_SubAgentList, NULL },
350 { _T("Agent.SupportedLists"), H_EnumList, NULL },
351 { _T("Agent.SupportedParameters"), H_ParamList, NULL },
352 { _T("Agent.SupportedPushParameters"), H_PushParamList, NULL },
353 { _T("Agent.SupportedTables"), H_TableList, NULL },
354 { _T("Agent.ThreadPools"), H_ThreadPoolList, NULL }
355 };
356
357 /**
358 * Standard agent's tables
359 */
360 static NETXMS_SUBAGENT_TABLE m_stdTables[] =
361 {
362 { _T("Agent.SessionAgents"), H_SessionAgents, NULL, _T("SESSION_ID"), DCTDESC_AGENT_SUBAGENTS },
363 { _T("Agent.SubAgents"), H_SubAgentTable, NULL, _T("NAME"), DCTDESC_AGENT_SUBAGENTS },
364 #ifdef _WIN32
365 { _T("FileSystem.Volumes"), H_FileSystems, NULL, _T("VOLUME"), DCTDESC_FILESYSTEM_VOLUMES }
366 #endif
367 };
368
369 /**
370 * Initialize dynamic parameters list from default static list
371 */
372 BOOL InitParameterList()
373 {
374 if ((m_pParamList != NULL) || (m_pEnumList != NULL) || (m_pTableList != NULL))
375 return FALSE;
376
377 m_iNumParams = sizeof(m_stdParams) / sizeof(NETXMS_SUBAGENT_PARAM);
378 if (m_iNumParams > 0)
379 {
380 m_pParamList = (NETXMS_SUBAGENT_PARAM *)malloc(sizeof(NETXMS_SUBAGENT_PARAM) * m_iNumParams);
381 if (m_pParamList == NULL)
382 return FALSE;
383 memcpy(m_pParamList, m_stdParams, sizeof(NETXMS_SUBAGENT_PARAM) * m_iNumParams);
384 }
385
386 m_iNumEnums = sizeof(m_stdLists) / sizeof(NETXMS_SUBAGENT_LIST);
387 if (m_iNumEnums > 0)
388 {
389 m_pEnumList = (NETXMS_SUBAGENT_LIST *)malloc(sizeof(NETXMS_SUBAGENT_LIST) * m_iNumEnums);
390 if (m_pEnumList == NULL)
391 return FALSE;
392 memcpy(m_pEnumList, m_stdLists, sizeof(NETXMS_SUBAGENT_LIST) * m_iNumEnums);
393 }
394
395 m_iNumTables = sizeof(m_stdTables) / sizeof(NETXMS_SUBAGENT_TABLE);
396 if (m_iNumTables > 0)
397 {
398 m_pTableList = (NETXMS_SUBAGENT_TABLE *)malloc(sizeof(NETXMS_SUBAGENT_TABLE) * m_iNumTables);
399 if (m_pTableList == NULL)
400 return FALSE;
401 memcpy(m_pTableList, m_stdTables, sizeof(NETXMS_SUBAGENT_TABLE) * m_iNumTables);
402 }
403
404 return TRUE;
405 }
406
407 /**
408 * Add push parameter to list
409 * by LWX
410 */
411 void AddPushParameter(const TCHAR *name, int dataType, const TCHAR *description)
412 {
413 int i;
414
415 // Search for existing parameter
416 for(i = 0; i < m_iNumPushParams; i++)
417 if (!_tcsicmp(m_pPushParamList[i].name, name))
418 break;
419 if (i < m_iNumPushParams)
420 {
421 // Replace existing attributes
422 m_pPushParamList[i].dataType = dataType;
423 nx_strncpy(m_pPushParamList[i].description, description, MAX_DB_STRING);
424 }
425 else
426 {
427 // Add new parameter
428 m_pPushParamList = (NETXMS_SUBAGENT_PUSHPARAM *)realloc(m_pPushParamList, sizeof(NETXMS_SUBAGENT_PUSHPARAM) * (m_iNumPushParams + 1));
429 nx_strncpy(m_pPushParamList[m_iNumPushParams].name, name, MAX_PARAM_NAME - 1);
430 m_pPushParamList[m_iNumPushParams].dataType = dataType;
431 nx_strncpy(m_pPushParamList[m_iNumPushParams].description, description, MAX_DB_STRING);
432 m_iNumPushParams++;
433 }
434 }
435
436 /**
437 * Add parameter to list
438 */
439 void AddParameter(const TCHAR *pszName, LONG (* fpHandler)(const TCHAR *, const TCHAR *, TCHAR *, AbstractCommSession *), const TCHAR *pArg,
440 int iDataType, const TCHAR *pszDescription)
441 {
442 int i;
443
444 // Search for existing parameter
445 for(i = 0; i < m_iNumParams; i++)
446 if (!_tcsicmp(m_pParamList[i].name, pszName))
447 break;
448 if (i < m_iNumParams)
449 {
450 // Replace existing handler and attributes
451 m_pParamList[i].handler = fpHandler;
452 m_pParamList[i].dataType = iDataType;
453 nx_strncpy(m_pParamList[i].description, pszDescription, MAX_DB_STRING);
454
455 // If we are replacing System.PlatformName, add pointer to
456 // platform suffix as argument, otherwise, use supplied pArg
457 if (!_tcscmp(pszName, _T("System.PlatformName")))
458 {
459 m_pParamList[i].arg = g_szPlatformSuffix; // to be TCHAR
460 }
461 else
462 {
463 m_pParamList[i].arg = pArg;
464 }
465 }
466 else
467 {
468 // Add new parameter
469 m_pParamList = (NETXMS_SUBAGENT_PARAM *)realloc(m_pParamList, sizeof(NETXMS_SUBAGENT_PARAM) * (m_iNumParams + 1));
470 nx_strncpy(m_pParamList[m_iNumParams].name, pszName, MAX_PARAM_NAME - 1);
471 m_pParamList[m_iNumParams].handler = fpHandler;
472 m_pParamList[m_iNumParams].arg = pArg;
473 m_pParamList[m_iNumParams].dataType = iDataType;
474 nx_strncpy(m_pParamList[m_iNumParams].description, pszDescription, MAX_DB_STRING);
475 m_iNumParams++;
476 }
477 }
478
479 /**
480 * Add list
481 */
482 void AddList(const TCHAR *name, LONG (* handler)(const TCHAR *, const TCHAR *, StringList *, AbstractCommSession *), const TCHAR *arg)
483 {
484 int i;
485
486 // Search for existing enum
487 for(i = 0; i < m_iNumEnums; i++)
488 if (!_tcsicmp(m_pEnumList[i].name, name))
489 break;
490 if (i < m_iNumEnums)
491 {
492 // Replace existing handler and arg
493 m_pEnumList[i].handler = handler;
494 m_pEnumList[i].arg = arg;
495 }
496 else
497 {
498 // Add new enum
499 m_pEnumList = (NETXMS_SUBAGENT_LIST *)realloc(m_pEnumList, sizeof(NETXMS_SUBAGENT_LIST) * (m_iNumEnums + 1));
500 nx_strncpy(m_pEnumList[m_iNumEnums].name, name, MAX_PARAM_NAME - 1);
501 m_pEnumList[m_iNumEnums].handler = handler;
502 m_pEnumList[m_iNumEnums].arg = arg;
503 m_iNumEnums++;
504 }
505 }
506
507 /**
508 * Add table
509 */
510 void AddTable(const TCHAR *name, LONG (* handler)(const TCHAR *, const TCHAR *, Table *, AbstractCommSession *), const TCHAR *arg,
511 const TCHAR *instanceColumns, const TCHAR *description, int numColumns, NETXMS_SUBAGENT_TABLE_COLUMN *columns)
512 {
513 int i;
514
515 // Search for existing table
516 for(i = 0; i < m_iNumTables; i++)
517 if (!_tcsicmp(m_pTableList[i].name, name))
518 break;
519 if (i < m_iNumTables)
520 {
521 // Replace existing handler and arg
522 m_pTableList[i].handler = handler;
523 m_pTableList[i].arg = arg;
524 nx_strncpy(m_pTableList[m_iNumTables].instanceColumns, instanceColumns, MAX_COLUMN_NAME * MAX_INSTANCE_COLUMNS);
525 nx_strncpy(m_pTableList[m_iNumTables].description, description, MAX_DB_STRING);
526 m_pTableList[i].numColumns = numColumns;
527 m_pTableList[i].columns = columns;
528 }
529 else
530 {
531 // Add new table
532 m_pTableList = (NETXMS_SUBAGENT_TABLE *)realloc(m_pTableList, sizeof(NETXMS_SUBAGENT_TABLE) * (m_iNumTables + 1));
533 nx_strncpy(m_pTableList[m_iNumTables].name, name, MAX_PARAM_NAME);
534 m_pTableList[m_iNumTables].handler = handler;
535 m_pTableList[m_iNumTables].arg = arg;
536 nx_strncpy(m_pTableList[m_iNumTables].instanceColumns, instanceColumns, MAX_COLUMN_NAME * MAX_INSTANCE_COLUMNS);
537 nx_strncpy(m_pTableList[m_iNumTables].description, description, MAX_DB_STRING);
538 m_pTableList[m_iNumTables].numColumns = numColumns;
539 m_pTableList[m_iNumTables].columns = columns;
540 m_iNumTables++;
541 }
542 }
543
544 /**
545 * Add external parameter
546 */
547 BOOL AddExternalParameter(TCHAR *pszCfgLine, BOOL bShellExec, BOOL bIsList) //to be TCHAR
548 {
549 TCHAR *pszCmdLine, *pszArg;
550
551 pszCmdLine = _tcschr(pszCfgLine, _T(':'));
552 if (pszCmdLine == NULL)
553 return FALSE;
554
555 *pszCmdLine = 0;
556 pszCmdLine++;
557 StrStrip(pszCfgLine);
558 StrStrip(pszCmdLine);
559 if ((*pszCfgLine == 0) || (*pszCmdLine == 0))
560 return FALSE;
561
562 pszArg = (TCHAR *)malloc((_tcslen(pszCmdLine) + 2) * sizeof(TCHAR));
563 pszArg[0] = bShellExec ? _T('S') : _T('E');
564 _tcscpy(&pszArg[1], pszCmdLine);
565 if (bIsList)
566 {
567 AddList(pszCfgLine, H_ExternalList, pszArg);
568 }
569 else
570 {
571 AddParameter(pszCfgLine, H_ExternalParameter, pszArg, DCI_DT_STRING, _T(""));
572 }
573 return TRUE;
574 }
575
576 /**
577 * Get parameter's value
578 */
579 UINT32 GetParameterValue(UINT32 sessionId, const TCHAR *param, TCHAR *value, AbstractCommSession *session)
580 {
581 int i, rc;
582 UINT32 dwErrorCode;
583
584 DebugPrintf(sessionId, 5, _T("Requesting parameter \"%s\""), param);
585 for(i = 0; i < m_iNumParams; i++)
586 {
587 if (MatchString(m_pParamList[i].name, param, FALSE))
588 {
589 rc = m_pParamList[i].handler(param, m_pParamList[i].arg, value, session);
590 switch(rc)
591 {
592 case SYSINFO_RC_SUCCESS:
593 dwErrorCode = ERR_SUCCESS;
594 m_dwProcessedRequests++;
595 break;
596 case SYSINFO_RC_ERROR:
597 dwErrorCode = ERR_INTERNAL_ERROR;
598 m_dwFailedRequests++;
599 break;
600 case SYSINFO_RC_NO_SUCH_INSTANCE:
601 dwErrorCode = ERR_NO_SUCH_INSTANCE;
602 m_dwFailedRequests++;
603 break;
604 case SYSINFO_RC_UNSUPPORTED:
605 dwErrorCode = ERR_UNKNOWN_PARAMETER;
606 m_dwUnsupportedRequests++;
607 break;
608 default:
609 nxlog_write(MSG_UNEXPECTED_IRC, EVENTLOG_ERROR_TYPE, "ds", rc, param);
610 dwErrorCode = ERR_INTERNAL_ERROR;
611 m_dwFailedRequests++;
612 break;
613 }
614 break;
615 }
616 }
617
618 if (i == m_iNumParams)
619 {
620 rc = GetParameterValueFromExtProvider(param, value);
621 if (rc == SYSINFO_RC_SUCCESS)
622 {
623 dwErrorCode = ERR_SUCCESS;
624 m_dwProcessedRequests++;
625 }
626 else
627 {
628 dwErrorCode = ERR_UNKNOWN_PARAMETER;
629 }
630 }
631
632 if ((dwErrorCode == ERR_UNKNOWN_PARAMETER) && (i == m_iNumParams))
633 {
634 dwErrorCode = GetParameterValueFromAppAgent(param, value);
635 if (dwErrorCode == ERR_SUCCESS)
636 {
637 m_dwProcessedRequests++;
638 }
639 else if (dwErrorCode != ERR_UNKNOWN_PARAMETER)
640 {
641 m_dwFailedRequests++;
642 }
643 }
644
645 if ((dwErrorCode == ERR_UNKNOWN_PARAMETER) && (i == m_iNumParams))
646 {
647 dwErrorCode = GetParameterValueFromExtSubagent(param, value);
648 if (dwErrorCode == ERR_SUCCESS)
649 {
650 m_dwProcessedRequests++;
651 }
652 else if (dwErrorCode == ERR_UNKNOWN_PARAMETER)
653 {
654 m_dwUnsupportedRequests++;
655 }
656 else
657 {
658 m_dwFailedRequests++;
659 }
660 }
661
662 DebugPrintf(sessionId, 7, _T("GetParameterValue(): result is %d (%s)"), (int)dwErrorCode,
663 dwErrorCode == ERR_SUCCESS ? _T("SUCCESS") : (dwErrorCode == ERR_UNKNOWN_PARAMETER ? _T("UNKNOWN_PARAMETER") : _T("INTERNAL_ERROR")));
664 return dwErrorCode;
665 }
666
667 /**
668 * Get list's value
669 */
670 UINT32 GetListValue(UINT32 sessionId, const TCHAR *param, StringList *value, AbstractCommSession *session)
671 {
672 int i, rc;
673 UINT32 dwErrorCode;
674
675 DebugPrintf(sessionId, 5, _T("Requesting list \"%s\""), param);
676 for(i = 0; i < m_iNumEnums; i++)
677 {
678 if (MatchString(m_pEnumList[i].name, param, FALSE))
679 {
680 rc = m_pEnumList[i].handler(param, m_pEnumList[i].arg, value, session);
681 switch(rc)
682 {
683 case SYSINFO_RC_SUCCESS:
684 dwErrorCode = ERR_SUCCESS;
685 m_dwProcessedRequests++;
686 break;
687 case SYSINFO_RC_ERROR:
688 dwErrorCode = ERR_INTERNAL_ERROR;
689 m_dwFailedRequests++;
690 break;
691 case SYSINFO_RC_NO_SUCH_INSTANCE:
692 dwErrorCode = ERR_NO_SUCH_INSTANCE;
693 m_dwFailedRequests++;
694 break;
695 case SYSINFO_RC_UNSUPPORTED:
696 dwErrorCode = ERR_UNKNOWN_PARAMETER;
697 m_dwUnsupportedRequests++;
698 break;
699 default:
700 nxlog_write(MSG_UNEXPECTED_IRC, EVENTLOG_ERROR_TYPE, "ds", rc, param);
701 dwErrorCode = ERR_INTERNAL_ERROR;
702 m_dwFailedRequests++;
703 break;
704 }
705 break;
706 }
707 }
708
709 if (i == m_iNumEnums)
710 {
711 dwErrorCode = GetListValueFromExtSubagent(param, value);
712 if (dwErrorCode == ERR_SUCCESS)
713 {
714 m_dwProcessedRequests++;
715 }
716 else if (dwErrorCode == ERR_UNKNOWN_PARAMETER)
717 {
718 m_dwUnsupportedRequests++;
719 }
720 else
721 {
722 m_dwFailedRequests++;
723 }
724 }
725
726 DebugPrintf(sessionId, 7, _T("GetListValue(): result is %d (%s)"), (int)dwErrorCode,
727 dwErrorCode == ERR_SUCCESS ? _T("SUCCESS") : (dwErrorCode == ERR_UNKNOWN_PARAMETER ? _T("UNKNOWN_PARAMETER") : _T("INTERNAL_ERROR")));
728 return dwErrorCode;
729 }
730
731 /**
732 * Get table's value
733 */
734 UINT32 GetTableValue(UINT32 sessionId, const TCHAR *param, Table *value, AbstractCommSession *session)
735 {
736 int i, rc;
737 UINT32 dwErrorCode;
738
739 DebugPrintf(sessionId, 5, _T("Requesting table \"%s\""), param);
740 for(i = 0; i < m_iNumTables; i++)
741 {
742 if (MatchString(m_pTableList[i].name, param, FALSE))
743 {
744 // pre-fill table columns if specified in table definition
745 if (m_pTableList[i].numColumns > 0)
746 {
747 for(int c = 0; c < m_pTableList[i].numColumns; c++)
748 {
749 NETXMS_SUBAGENT_TABLE_COLUMN *col = &m_pTableList[i].columns[c];
750 value->addColumn(col->name, col->dataType, col->displayName, col->isInstance);
751 }
752 }
753
754 rc = m_pTableList[i].handler(param, m_pTableList[i].arg, value, session);
755 switch(rc)
756 {
757 case SYSINFO_RC_SUCCESS:
758 dwErrorCode = ERR_SUCCESS;
759 m_dwProcessedRequests++;
760 break;
761 case SYSINFO_RC_ERROR:
762 dwErrorCode = ERR_INTERNAL_ERROR;
763 m_dwFailedRequests++;
764 break;
765 case SYSINFO_RC_NO_SUCH_INSTANCE:
766 dwErrorCode = ERR_NO_SUCH_INSTANCE;
767 m_dwFailedRequests++;
768 break;
769 case SYSINFO_RC_UNSUPPORTED:
770 dwErrorCode = ERR_UNKNOWN_PARAMETER;
771 m_dwUnsupportedRequests++;
772 break;
773 default:
774 nxlog_write(MSG_UNEXPECTED_IRC, EVENTLOG_ERROR_TYPE, "ds", rc, param);
775 dwErrorCode = ERR_INTERNAL_ERROR;
776 m_dwFailedRequests++;
777 break;
778 }
779 break;
780 }
781 }
782
783 if (i == m_iNumTables)
784 {
785 dwErrorCode = GetTableValueFromExtSubagent(param, value);
786 if (dwErrorCode == ERR_SUCCESS)
787 {
788 m_dwProcessedRequests++;
789 }
790 else if (dwErrorCode == ERR_UNKNOWN_PARAMETER)
791 {
792 m_dwUnsupportedRequests++;
793 }
794 else
795 {
796 m_dwFailedRequests++;
797 }
798 }
799
800 DebugPrintf(sessionId, 7, _T("GetTableValue(): result is %d (%s)"), (int)dwErrorCode,
801 dwErrorCode == ERR_SUCCESS ? _T("SUCCESS") : (dwErrorCode == ERR_UNKNOWN_PARAMETER ? _T("UNKNOWN_PARAMETER") : _T("INTERNAL_ERROR")));
802 return dwErrorCode;
803 }
804
805 /**
806 * Put complete list of supported parameters into NXCP message
807 */
808 void GetParameterList(NXCPMessage *pMsg)
809 {
810 int i;
811 UINT32 dwId, count;
812
813 // Parameters
814 for(i = 0, count = 0, dwId = VID_PARAM_LIST_BASE; i < m_iNumParams; i++)
815 {
816 if (m_pParamList[i].dataType != DCI_DT_DEPRECATED)
817 {
818 pMsg->setField(dwId++, m_pParamList[i].name);
819 pMsg->setField(dwId++, m_pParamList[i].description);
820 pMsg->setField(dwId++, (WORD)m_pParamList[i].dataType);
821 count++;
822 }
823 }
824 ListParametersFromExtProviders(pMsg, &dwId, &count);
825 ListParametersFromExtSubagents(pMsg, &dwId, &count);
826 pMsg->setField(VID_NUM_PARAMETERS, count);
827
828 // Push parameters
829 pMsg->setField(VID_NUM_PUSH_PARAMETERS, (UINT32)m_iNumPushParams);
830 for(i = 0, dwId = VID_PUSHPARAM_LIST_BASE; i < m_iNumPushParams; i++)
831 {
832 pMsg->setField(dwId++, m_pPushParamList[i].name);
833 pMsg->setField(dwId++, m_pPushParamList[i].description);
834 pMsg->setField(dwId++, (WORD)m_pPushParamList[i].dataType);
835 }
836
837 // Lists
838 pMsg->setField(VID_NUM_ENUMS, (UINT32)m_iNumEnums);
839 for(i = 0, dwId = VID_ENUM_LIST_BASE; i < m_iNumEnums; i++)
840 {
841 pMsg->setField(dwId++, m_pEnumList[i].name);
842 }
843 ListListsFromExtSubagents(pMsg, &dwId, &count);
844
845 // Tables
846 pMsg->setField(VID_NUM_TABLES, (UINT32)m_iNumTables);
847 for(i = 0, dwId = VID_TABLE_LIST_BASE; i < m_iNumTables; i++)
848 {
849 pMsg->setField(dwId++, m_pTableList[i].name);
850 pMsg->setField(dwId++, m_pTableList[i].instanceColumns);
851 pMsg->setField(dwId++, m_pTableList[i].description);
852 }
853 ListTablesFromExtSubagents(pMsg, &dwId, &count);
854 }
855
856 /**
857 * Put list of supported tables into NXCP message
858 */
859 void GetTableList(NXCPMessage *pMsg)
860 {
861 int i;
862 UINT32 dwId, count;
863
864 pMsg->setField(VID_NUM_TABLES, (UINT32)m_iNumTables);
865 for(i = 0, dwId = VID_TABLE_LIST_BASE; i < m_iNumTables; i++)
866 {
867 pMsg->setField(dwId++, m_pTableList[i].name);
868 pMsg->setField(dwId++, m_pTableList[i].instanceColumns);
869 pMsg->setField(dwId++, m_pTableList[i].description);
870 }
871 ListTablesFromExtSubagents(pMsg, &dwId, &count);
872 }
873
874 /**
875 * Put list of supported lists (enums) into NXCP message
876 */
877 void GetEnumList(NXCPMessage *pMsg)
878 {
879 int i;
880 UINT32 dwId, count;
881
882 pMsg->setField(VID_NUM_ENUMS, (UINT32)m_iNumEnums);
883 for(i = 0, dwId = VID_ENUM_LIST_BASE; i < m_iNumEnums; i++)
884 {
885 pMsg->setField(dwId++, m_pEnumList[i].name);
886 }
887 ListListsFromExtSubagents(pMsg, &dwId, &count);
888 }