4f454301fa9a7995de1dfc09d9538049830bf89c
[public/netxms.git] / include / nms_agent.h
1 /*
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003-2010 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: nms_agent.h
20 **
21 **/
22
23 #ifndef _nms_agent_h_
24 #define _nms_agent_h_
25
26 #include <nms_common.h>
27 #include <nms_util.h>
28 #include <nxconfig.h>
29
30
31 //
32 // Initialization function declaration macro
33 //
34
35 #if defined(_STATIC_AGENT) || defined(_NETWARE)
36 #define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL NxSubAgentRegister_##name(NETXMS_SUBAGENT_INFO **ppInfo, Config *config)
37 #else
38 #ifdef _WIN32
39 #define DECLSPEC_EXPORT __declspec(dllexport) __cdecl
40 #else
41 #define DECLSPEC_EXPORT
42 #endif
43 #define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL DECLSPEC_EXPORT NxSubAgentRegister(NETXMS_SUBAGENT_INFO **ppInfo, Config *config)
44 #endif
45
46
47 //
48 // Some constants
49 //
50
51 #define AGENT_LISTEN_PORT 4700
52 #define AGENT_PROTOCOL_VERSION 2
53 #define MAX_RESULT_LENGTH 256
54 #define MAX_CMD_LEN 256
55 #define COMMAND_TIMEOUT 60
56 #define MAX_SUBAGENT_NAME 64
57
58
59 //
60 // Agent policy types
61 //
62
63 #define AGENT_POLICY_CONFIG 1
64
65
66 //
67 // Error codes
68 //
69
70 #define ERR_SUCCESS ((DWORD)0)
71 #define ERR_UNKNOWN_COMMAND ((DWORD)400)
72 #define ERR_AUTH_REQUIRED ((DWORD)401)
73 #define ERR_ACCESS_DENIED ((DWORD)403)
74 #define ERR_UNKNOWN_PARAMETER ((DWORD)404)
75 #define ERR_REQUEST_TIMEOUT ((DWORD)408)
76 #define ERR_AUTH_FAILED ((DWORD)440)
77 #define ERR_ALREADY_AUTHENTICATED ((DWORD)441)
78 #define ERR_AUTH_NOT_REQUIRED ((DWORD)442)
79 #define ERR_INTERNAL_ERROR ((DWORD)500)
80 #define ERR_NOT_IMPLEMENTED ((DWORD)501)
81 #define ERR_OUT_OF_RESOURCES ((DWORD)503)
82 #define ERR_NOT_CONNECTED ((DWORD)900)
83 #define ERR_CONNECTION_BROKEN ((DWORD)901)
84 #define ERR_BAD_RESPONSE ((DWORD)902)
85 #define ERR_IO_FAILURE ((DWORD)903)
86 #define ERR_RESOURCE_BUSY ((DWORD)904)
87 #define ERR_EXEC_FAILED ((DWORD)905)
88 #define ERR_ENCRYPTION_REQUIRED ((DWORD)906)
89 #define ERR_NO_CIPHERS ((DWORD)907)
90 #define ERR_INVALID_PUBLIC_KEY ((DWORD)908)
91 #define ERR_INVALID_SESSION_KEY ((DWORD)909)
92 #define ERR_CONNECT_FAILED ((DWORD)910)
93 #define ERR_MALFORMED_COMMAND ((DWORD)911)
94 #define ERR_SOCKET_ERROR ((DWORD)912)
95 #define ERR_BAD_ARGUMENTS ((DWORD)913)
96 #define ERR_SUBAGENT_LOAD_FAILED ((DWORD)914)
97 #define ERR_FILE_OPEN_ERROR ((DWORD)915)
98 #define ERR_FILE_STAT_FAILED ((DWORD)916)
99 #define ERR_MEM_ALLOC_FAILED ((DWORD)917)
100 #define ERR_FILE_DELETE_FAILED ((DWORD)918)
101
102
103 //
104 // Parameter handler return codes
105 //
106
107 #define SYSINFO_RC_SUCCESS 0
108 #define SYSINFO_RC_UNSUPPORTED 1
109 #define SYSINFO_RC_ERROR 2
110
111
112 //
113 // Descriptions for common parameters
114 //
115
116 #define DCIDESC_FS_AVAIL "Available space on file system {instance}"
117 #define DCIDESC_FS_AVAILPERC "Percentage of available space on file system {instance}"
118 #define DCIDESC_FS_FREE "Free space on file system {instance}"
119 #define DCIDESC_FS_FREEPERC "Percentage of free space on file system {instance}"
120 #define DCIDESC_FS_TOTAL "Total space on file system {instance}"
121 #define DCIDESC_FS_USED "Used space on file system {instance}"
122 #define DCIDESC_FS_USEDPERC "Percentage of used space on file system {instance}"
123 #define DCIDESC_NET_INTERFACE_ADMINSTATUS "Administrative status of interface {instance}"
124 #define DCIDESC_NET_INTERFACE_BYTESIN "Number of input bytes on interface {instance}"
125 #define DCIDESC_NET_INTERFACE_BYTESOUT "Number of output bytes on interface {instance}"
126 #define DCIDESC_NET_INTERFACE_DESCRIPTION "Description of interface {instance}"
127 #define DCIDESC_NET_INTERFACE_INERRORS "Number of input errors on interface {instance}"
128 #define DCIDESC_NET_INTERFACE_LINK "Link status for interface {instance}"
129 #define DCIDESC_NET_INTERFACE_MTU "MTU for interface {instance}"
130 #define DCIDESC_NET_INTERFACE_OPERSTATUS "Operational status of interface {instance}"
131 #define DCIDESC_NET_INTERFACE_OUTERRORS "Number of output errors on interface {instance}"
132 #define DCIDESC_NET_INTERFACE_PACKETSIN "Number of input packets on interface {instance}"
133 #define DCIDESC_NET_INTERFACE_PACKETSOUT "Number of output packets on interface {instance}"
134 #define DCIDESC_NET_INTERFACE_SPEED "Speed of interface {instance}"
135 #define DCIDESC_NET_IP_FORWARDING "IP forwarding status"
136 #define DCIDESC_NET_IP6_FORWARDING "IPv6 forwarding status"
137 #define DCIDESC_PHYSICALDISK_FIRMWARE "Firmware version of hard disk {instance}"
138 #define DCIDESC_PHYSICALDISK_MODEL "Model of hard disk {instance}"
139 #define DCIDESC_PHYSICALDISK_SERIALNUMBER "Serial number of hard disk {instance}"
140 #define DCIDESC_PHYSICALDISK_SMARTATTR ""
141 #define DCIDESC_PHYSICALDISK_SMARTSTATUS "Status of hard disk {instance} reported by SMART"
142 #define DCIDESC_PHYSICALDISK_TEMPERATURE "Temperature of hard disk {instance}"
143 #define DCIDESC_SYSTEM_CPU_COUNT "Number of CPU in the system"
144 #define DCIDESC_SYSTEM_HOSTNAME "Host name"
145 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE "Free physical memory"
146 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE_PCT "Percentage of free physical memory"
147 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_TOTAL "Total amount of physical memory"
148 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED "Used physical memory"
149 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED_PCT "Percentage of used physical memory"
150 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_AVAILABLE "Available physical memory"
151 #define DCIDESC_SYSTEM_MEMORY_PHYSICAL_AVAILABLE_PCT "Percentage of available physical memory"
152 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE "Free virtual memory"
153 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE_PCT "Percentage of free virtual memory"
154 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_TOTAL "Total amount of virtual memory"
155 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED "Used virtual memory"
156 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED_PCT "Percentage of used virtual memory"
157 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_AVAILABLE "Available virtual memory"
158 #define DCIDESC_SYSTEM_MEMORY_VIRTUAL_AVAILABLE_PCT "Percentage of available virtual memory"
159 #define DCIDESC_SYSTEM_MEMORY_SWAP_FREE "Free swap space"
160 #define DCIDESC_SYSTEM_MEMORY_SWAP_FREE_PCT "Percentage of free swap space"
161 #define DCIDESC_SYSTEM_MEMORY_SWAP_TOTAL "Total amount of swap space"
162 #define DCIDESC_SYSTEM_MEMORY_SWAP_USED "Used swap space"
163 #define DCIDESC_SYSTEM_MEMORY_SWAP_USED_PCT "Percentage of used swap space"
164 #define DCIDESC_SYSTEM_UNAME "System uname"
165 #define DCIDESC_AGENT_ACCEPTEDCONNECTIONS "Number of connections accepted by agent"
166 #define DCIDESC_AGENT_ACCEPTERRORS "Number of accept() call errors"
167 #define DCIDESC_AGENT_ACTIVECONNECTIONS "Number of active connections to agent"
168 #define DCIDESC_AGENT_AUTHENTICATIONFAILURES "Number of authentication failures"
169 #define DCIDESC_AGENT_CONFIG_SERVER "Configuration server address set on agent startup"
170 #define DCIDESC_AGENT_FAILEDREQUESTS "Number of failed requests to agent"
171 #define DCIDESC_AGENT_PROCESSEDREQUESTS "Number of requests processed by agent"
172 #define DCIDESC_AGENT_REGISTRAR "Registrar server address set on agent startup"
173 #define DCIDESC_AGENT_REJECTEDCONNECTIONS "Number of connections rejected by agent"
174 #define DCIDESC_AGENT_SOURCEPACKAGESUPPORT ""
175 #define DCIDESC_AGENT_SUPPORTEDCIPHERS "List of ciphers supported by agent"
176 #define DCIDESC_AGENT_TIMEDOUTREQUESTS "Number of timed out requests to agent"
177 #define DCIDESC_AGENT_UNSUPPORTEDREQUESTS "Number of requests for unsupported parameters"
178 #define DCIDESC_AGENT_UPTIME "Agent's uptime"
179 #define DCIDESC_AGENT_VERSION "Agent's version"
180 #define DCIDESC_FILE_COUNT "Number of files {instance}"
181 #define DCIDESC_FILE_HASH_CRC32 "CRC32 checksum of {instance}"
182 #define DCIDESC_FILE_HASH_MD5 "MD5 hash of {instance}"
183 #define DCIDESC_FILE_HASH_SHA1 "SHA1 hash of {instance}"
184 #define DCIDESC_FILE_SIZE "Size of file {instance}"
185 #define DCIDESC_FILE_TIME_ACCESS "Time of last access to file {instance}"
186 #define DCIDESC_FILE_TIME_CHANGE "Time of last status change of file {instance}"
187 #define DCIDESC_FILE_TIME_MODIFY "Time of last modification of file {instance}"
188 #define DCIDESC_SYSTEM_PLATFORMNAME "Platform name"
189 #define DCIDESC_PROCESS_COUNT "Number of {instance} processes"
190 #define DCIDESC_PROCESS_COUNTEX "Number of {instance} processes (extended)"
191 #define DCIDESC_PROCESS_CPUTIME "Total execution time for process {instance}"
192 #define DCIDESC_PROCESS_GDIOBJ "GDI objects used by process {instance}"
193 #define DCIDESC_PROCESS_IO_OTHERB ""
194 #define DCIDESC_PROCESS_IO_OTHEROP ""
195 #define DCIDESC_PROCESS_IO_READB ""
196 #define DCIDESC_PROCESS_IO_READOP ""
197 #define DCIDESC_PROCESS_IO_WRITEB ""
198 #define DCIDESC_PROCESS_IO_WRITEOP ""
199 #define DCIDESC_PROCESS_KERNELTIME "Total execution time in kernel mode for process {instance}"
200 #define DCIDESC_PROCESS_PAGEFAULTS "Page faults for process {instance}"
201 #define DCIDESC_PROCESS_SYSCALLS "Number of system calls made by process {instance}"
202 #define DCIDESC_PROCESS_THREADS "Number of threads in process {instance}"
203 #define DCIDESC_PROCESS_USEROBJ "USER objects used by process {instance}"
204 #define DCIDESC_PROCESS_USERTIME "Total execution time in user mode for process {instance}"
205 #define DCIDESC_PROCESS_VMSIZE "Virtual memory used by process {instance}"
206 #define DCIDESC_PROCESS_WKSET "Physical memory used by process {instance}"
207 #define DCIDESC_SYSTEM_APPADDRESSSPACE "Address space available to applications (MB)"
208 #define DCIDESC_SYSTEM_CONNECTEDUSERS "Number of logged in users"
209 #define DCIDESC_SYSTEM_PROCESSCOUNT "Total number of processes"
210 #define DCIDESC_SYSTEM_SERVICESTATE "State of {instance} service"
211 #define DCIDESC_SYSTEM_PROCESSCOUNT "Total number of processes"
212 #define DCIDESC_SYSTEM_THREADCOUNT "Total number of threads"
213 #define DCIDESC_PDH_COUNTERVALUE "Value of PDH counter {instance}"
214 #define DCIDESC_PDH_VERSION "Version of PDH.DLL"
215 #define DCIDESC_SYSTEM_UPTIME "System uptime"
216 #define DCIDESC_SYSTEM_CPU_LOADAVG "Average CPU load for last minute"
217 #define DCIDESC_SYSTEM_CPU_LOADAVG5 "Average CPU load for last 5 minutes"
218 #define DCIDESC_SYSTEM_CPU_LOADAVG15 "Average CPU load for last 15 minutes"
219
220
221 #define DCIDESC_SYSTEM_CPU_USAGE_EX "Average CPU {instance} utilization for last minute"
222 #define DCIDESC_SYSTEM_CPU_USAGE5_EX "Average CPU {instance} utilization for last 5 minutes"
223 #define DCIDESC_SYSTEM_CPU_USAGE15_EX "Average CPU {instance} utilization for last 15 minutes"
224 #define DCIDESC_SYSTEM_CPU_USAGE "Average CPU utilization for last minute"
225 #define DCIDESC_SYSTEM_CPU_USAGE5 "Average CPU utilization for last 5 minutes"
226 #define DCIDESC_SYSTEM_CPU_USAGE15 "Average CPU utilization for last 15 minutes"
227
228 #define DCIDESC_SYSTEM_CPU_USAGE_USER_EX "Average CPU {instance} utilization (user) for last minute"
229 #define DCIDESC_SYSTEM_CPU_USAGE5_USER_EX "Average CPU {instance} utilization (user) for last 5 minutes"
230 #define DCIDESC_SYSTEM_CPU_USAGE15_USER_EX "Average CPU {instance} utilization (user) for last 15 minutes"
231 #define DCIDESC_SYSTEM_CPU_USAGE_USER "Average CPU utilization (user) for last minute"
232 #define DCIDESC_SYSTEM_CPU_USAGE5_USER "Average CPU utilization (user) for last 5 minutes"
233 #define DCIDESC_SYSTEM_CPU_USAGE15_USER "Average CPU utilization (user) for last 15 minutes"
234
235 #define DCIDESC_SYSTEM_CPU_USAGE_NICE_EX "Average CPU {instance} utilization (nice) for last minute"
236 #define DCIDESC_SYSTEM_CPU_USAGE5_NICE_EX "Average CPU {instance} utilization (nice) for last 5 minutes"
237 #define DCIDESC_SYSTEM_CPU_USAGE15_NICE_EX "Average CPU {instance} utilization (nice) for last 15 minutes"
238 #define DCIDESC_SYSTEM_CPU_USAGE_NICE "Average CPU utilization (nice) for last minute"
239 #define DCIDESC_SYSTEM_CPU_USAGE5_NICE "Average CPU utilization (nice) for last 5 minutes"
240 #define DCIDESC_SYSTEM_CPU_USAGE15_NICE "Average CPU utilization (nice) for last 15 minutes"
241
242 #define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM_EX "Average CPU {instance} utilization (system) for last minute"
243 #define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM_EX "Average CPU {instance} utilization (system) for last 5 minutes"
244 #define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM_EX "Average CPU {instance} utilization (system) for last 15 minutes"
245 #define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM "Average CPU utilization (system) for last minute"
246 #define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM "Average CPU utilization (system) for last 5 minutes"
247 #define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM "Average CPU utilization (system) for last 15 minutes"
248
249 #define DCIDESC_SYSTEM_CPU_USAGE_IDLE_EX "Average CPU {instance} utilization (idle) for last minute"
250 #define DCIDESC_SYSTEM_CPU_USAGE5_IDLE_EX "Average CPU {instance} utilization (idle) for last 5 minutes"
251 #define DCIDESC_SYSTEM_CPU_USAGE15_IDLE_EX "Average CPU {instance} utilization (idle) for last 15 minutes"
252 #define DCIDESC_SYSTEM_CPU_USAGE_IDLE "Average CPU utilization (idle) for last minute"
253 #define DCIDESC_SYSTEM_CPU_USAGE5_IDLE "Average CPU utilization (idle) for last 5 minutes"
254 #define DCIDESC_SYSTEM_CPU_USAGE15_IDLE "Average CPU utilization (idle) for last 15 minutes"
255
256 #define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last minute"
257 #define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last 5 minutes"
258 #define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last 15 minutes"
259 #define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT "Average CPU utilization (iowait) for last minute"
260 #define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT "Average CPU utilization (iowait) for last 5 minutes"
261 #define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT "Average CPU utilization (iowait) for last 15 minutes"
262
263 #define DCIDESC_SYSTEM_CPU_USAGE_IRQ_EX "Average CPU {instance} utilization (irq) for last minute"
264 #define DCIDESC_SYSTEM_CPU_USAGE5_IRQ_EX "Average CPU {instance} utilization (irq) for last 5 minutes"
265 #define DCIDESC_SYSTEM_CPU_USAGE15_IRQ_EX "Average CPU {instance} utilization (irq) for last 15 minutes"
266 #define DCIDESC_SYSTEM_CPU_USAGE_IRQ "Average CPU utilization (irq) for last minute"
267 #define DCIDESC_SYSTEM_CPU_USAGE5_IRQ "Average CPU utilization (irq) for last 5 minutes"
268 #define DCIDESC_SYSTEM_CPU_USAGE15_IRQ "Average CPU utilization (irq) for last 15 minutes"
269
270 #define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last minute"
271 #define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last 5 minutes"
272 #define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last 15 minutes"
273 #define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ "Average CPU utilization (softirq) for last minute"
274 #define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ "Average CPU utilization (softirq) for last 5 minutes"
275 #define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ "Average CPU utilization (softirq) for last 15 minutes"
276
277 #define DCIDESC_SYSTEM_CPU_USAGE_STEAL_EX "Average CPU {instance} utilization (steal) for last minute"
278 #define DCIDESC_SYSTEM_CPU_USAGE5_STEAL_EX "Average CPU {instance} utilization (steal) for last 5 minutes"
279 #define DCIDESC_SYSTEM_CPU_USAGE15_STEAL_EX "Average CPU {instance} utilization (steal) for last 15 minutes"
280 #define DCIDESC_SYSTEM_CPU_USAGE_STEAL "Average CPU utilization (steal) for last minute"
281 #define DCIDESC_SYSTEM_CPU_USAGE5_STEAL "Average CPU utilization (steal) for last 5 minutes"
282 #define DCIDESC_SYSTEM_CPU_USAGE15_STEAL "Average CPU utilization (steal) for last 15 minutes"
283
284 #define DCIDESC_SYSTEM_CPU_USAGE_GUEST_EX "Average CPU {instance} utilization (guest) for last minute"
285 #define DCIDESC_SYSTEM_CPU_USAGE5_GUEST_EX "Average CPU {instance} utilization (guest) for last 5 minutes"
286 #define DCIDESC_SYSTEM_CPU_USAGE15_GUEST_EX "Average CPU {instance} utilization (guest) for last 15 minutes"
287 #define DCIDESC_SYSTEM_CPU_USAGE_GUEST "Average CPU utilization (guest) for last minute"
288 #define DCIDESC_SYSTEM_CPU_USAGE5_GUEST "Average CPU utilization (guest) for last 5 minutes"
289 #define DCIDESC_SYSTEM_CPU_USAGE15_GUEST "Average CPU utilization (guest) for last 15 minutes"
290
291 #define DCIDESC_SYSTEM_IO_DISKQUEUE "Average disk queue length for last minute"
292 #define DCIDESC_SYSTEM_IO_DISKQUEUE_EX "Average disk queue length of device {instance} for last minute"
293 #define DCIDESC_SYSTEM_IO_DISKTIME "Percent of CPU time spent on I/O for last minute"
294 #define DCIDESC_SYSTEM_IO_DISKTIME_EX "Percent of CPU time spent on I/O on device {instance} for last minute"
295 #define DCIDESC_SYSTEM_IO_WAITTIME "Average I/O request wait time"
296 #define DCIDESC_SYSTEM_IO_WAITTIME_EX "Average I/O request wait time for device {instance}"
297 #define DCIDESC_SYSTEM_IO_READS "Average number of read operations for last minute"
298 #define DCIDESC_SYSTEM_IO_READS_EX "Average number of read operations on device {instance} for last minute"
299 #define DCIDESC_SYSTEM_IO_WRITES "Average number of write operations for last minute"
300 #define DCIDESC_SYSTEM_IO_WRITES_EX "Average number of write operations on device {instance} for last minute"
301 #define DCIDESC_SYSTEM_IO_XFERS "Average number of I/O transfers for last minute"
302 #define DCIDESC_SYSTEM_IO_XFERS_EX "Average number of I/O transfers on device {instance} for last minute"
303 #define DCIDESC_SYSTEM_IO_BYTEREADS "Average number of bytes read for last minute"
304 #define DCIDESC_SYSTEM_IO_BYTEREADS_EX "Average number of bytes read on device {instance} for last minute"
305 #define DCIDESC_SYSTEM_IO_BYTEWRITES "Average number of bytes written for last minute"
306 #define DCIDESC_SYSTEM_IO_BYTEWRITES_EX "Average number of bytes written on device {instance} for last minute"
307 #define DCIDESC_SYSTEM_IO_OPENFILES "Number of open files"
308
309
310 #define DCIDESC_DEPRECATED "<deprecated>"
311
312
313 //
314 // Subagent's parameter information
315 //
316
317 typedef struct
318 {
319 TCHAR szName[MAX_PARAM_NAME];
320 LONG (* fpHandler)(const TCHAR *, const TCHAR *, TCHAR *);
321 const TCHAR *pArg;
322 int iDataType; // Use DT_DEPRECATED to indicate deprecated parameter
323 TCHAR szDescription[MAX_DB_STRING];
324 } NETXMS_SUBAGENT_PARAM;
325
326
327 //
328 // Subagent's push parameter information
329 //
330
331 typedef struct
332 {
333 TCHAR name[MAX_PARAM_NAME];
334 int dataType;
335 TCHAR description[MAX_DB_STRING];
336 } NETXMS_SUBAGENT_PUSHPARAM;
337
338
339 //
340 // Subagent's enum information
341 //
342
343 typedef struct
344 {
345 TCHAR szName[MAX_PARAM_NAME];
346 LONG (* fpHandler)(const TCHAR *, const TCHAR *, StringList *);
347 const TCHAR *pArg;
348 } NETXMS_SUBAGENT_ENUM;
349
350
351 //
352 // Subagent's action information
353 //
354
355 typedef struct
356 {
357 TCHAR szName[MAX_PARAM_NAME];
358 LONG (* fpHandler)(const TCHAR *, StringList *, const TCHAR *);
359 const TCHAR *pArg;
360 TCHAR szDescription[MAX_DB_STRING];
361 } NETXMS_SUBAGENT_ACTION;
362
363
364 //
365 // Subagent initialization structure
366 //
367
368 #define NETXMS_SUBAGENT_INFO_MAGIC ((DWORD)0x20091206)
369
370 class CSCPMessage;
371
372 typedef struct
373 {
374 DWORD dwMagic; // Magic number to check if subagent uses correct version of this structure
375 TCHAR szName[MAX_SUBAGENT_NAME];
376 TCHAR szVersion[32];
377 BOOL (* pInit)(Config *); // Called to initialize subagent. Can be NULL.
378 void (* pShutdown)(void); // Called at subagent unload. Can be NULL.
379 BOOL (* pCommandHandler)(DWORD dwCommand, CSCPMessage *pRequest,
380 CSCPMessage *pResponse, void *session);
381 DWORD dwNumParameters;
382 NETXMS_SUBAGENT_PARAM *pParamList;
383 DWORD dwNumEnums;
384 NETXMS_SUBAGENT_ENUM *pEnumList;
385 DWORD dwNumActions;
386 NETXMS_SUBAGENT_ACTION *pActionList;
387 DWORD dwNumPushParameters;
388 NETXMS_SUBAGENT_PUSHPARAM *pPushParamList;
389 } NETXMS_SUBAGENT_INFO;
390
391
392 //
393 // Inline functions for returning parameters
394 //
395
396 inline void ret_string(TCHAR *rbuf, const TCHAR *value)
397 {
398 nx_strncpy(rbuf, value, MAX_RESULT_LENGTH);
399 }
400
401 inline void ret_int(TCHAR *rbuf, LONG value)
402 {
403 #if defined(_WIN32) && (_MSC_VER >= 1300)
404 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%ld"), (long)value);
405 #else
406 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%ld"), (long)value);
407 #endif
408 }
409
410 inline void ret_uint(TCHAR *rbuf, DWORD value)
411 {
412 #if defined(_WIN32) && (_MSC_VER >= 1300)
413 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%lu"), (unsigned long)value);
414 #else
415 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%lu"), (unsigned long)value);
416 #endif
417 }
418
419 inline void ret_double(TCHAR *rbuf, double value)
420 {
421 #if defined(_WIN32) && (_MSC_VER >= 1300)
422 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%f"), value);
423 #else
424 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%f"), value);
425 #endif
426 }
427
428 inline void ret_int64(TCHAR *rbuf, INT64 value)
429 {
430 #if defined(_WIN32) && (_MSC_VER >= 1300)
431 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%I64d"), value);
432 #else /* _WIN32 */
433 _sntprintf(rbuf, MAX_RESULT_LENGTH, INT64_FMT, value);
434 #endif /* _WIN32 */
435 }
436
437 inline void ret_uint64(TCHAR *rbuf, QWORD value)
438 {
439 #if defined(_WIN32) && (_MSC_VER >= 1300)
440 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%I64u"), value);
441 #else /* _WIN32 */
442 _sntprintf(rbuf, MAX_RESULT_LENGTH, UINT64_FMT, value);
443 #endif /* _WIN32 */
444 }
445
446
447 //
448 // API for subagents
449 //
450
451 BOOL LIBNETXMS_EXPORTABLE AgentGetParameterArg(const TCHAR *param, int index, TCHAR *arg, int maxSize);
452 void LIBNETXMS_EXPORTABLE AgentWriteLog(int logLevel, const TCHAR *format, ...);
453 void LIBNETXMS_EXPORTABLE AgentWriteLog2(int logLevel, const TCHAR *format, va_list args);
454 void LIBNETXMS_EXPORTABLE AgentWriteDebugLog(int level, const TCHAR *format, ...);
455 void LIBNETXMS_EXPORTABLE AgentWriteDebugLog2(int level, const TCHAR *format, va_list args);
456 void LIBNETXMS_EXPORTABLE AgentSendTrap(DWORD dwEvent, const char *pszFormat, ...);
457 void LIBNETXMS_EXPORTABLE AgentSendTrap2(DWORD dwEvent, int nCount, TCHAR **ppszArgList);
458 BOOL LIBNETXMS_EXPORTABLE AgentSendFileToServer(void *session, DWORD requestId, const TCHAR *file, long offset);
459 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterData(const TCHAR *parameter, const TCHAR *value);
460 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataInt32(const TCHAR *parameter, LONG value);
461 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataUInt32(const TCHAR *parameter, DWORD value);
462 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataInt64(const TCHAR *parameter, INT64 value);
463 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataUInt64(const TCHAR *parameter, QWORD value);
464 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataDouble(const TCHAR *parameter, double value);
465
466 #endif /* _nms_agent_h_ */