fixed incorrect event severity level handling on Windows Server 2008 and Windows 7
[public/netxms.git] / include / nms_agent.h
CommitLineData
cbcaf8c8 1/*
7ac71e60 2** NetXMS - Network Management System
e2d68ddd 3** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
cbcaf8c8
VK
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**
456d5d1c 19** File: nms_agent.h
cbcaf8c8
VK
20**
21**/
22
23#ifndef _nms_agent_h_
24#define _nms_agent_h_
25
adc00755 26#include <nms_common.h>
64584976 27#include <nms_util.h>
e6c91aac 28#include <nxconfig.h>
6827d635
VK
29
30
b5138dfb
VK
31//
32// Initialization function declaration macro
33//
34
a0a945fb 35#if defined(_STATIC_AGENT) || defined(_NETWARE)
e6c91aac 36#define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL NxSubAgentRegister_##name(NETXMS_SUBAGENT_INFO **ppInfo, Config *config)
a0a945fb 37#else
b5138dfb 38#ifdef _WIN32
a0a945fb 39#define DECLSPEC_EXPORT __declspec(dllexport) __cdecl
b5138dfb
VK
40#else
41#define DECLSPEC_EXPORT
42#endif
e6c91aac 43#define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL DECLSPEC_EXPORT NxSubAgentRegister(NETXMS_SUBAGENT_INFO **ppInfo, Config *config)
b5138dfb
VK
44#endif
45
46
cbcaf8c8
VK
47//
48// Some constants
49//
50
51#define AGENT_LISTEN_PORT 4700
deaa4491 52#define AGENT_PROTOCOL_VERSION 2
cbcaf8c8 53#define MAX_RESULT_LENGTH 256
e22f1644
VK
54#define MAX_CMD_LEN 256
55#define COMMAND_TIMEOUT 60
47e0446b 56#define MAX_SUBAGENT_NAME 64
cbcaf8c8
VK
57
58
6ca3b41c
VK
59//
60// Agent policy types
61//
62
63#define AGENT_POLICY_CONFIG 1
64
65
cbcaf8c8
VK
66//
67// Error codes
68//
69
deaa4491
VK
70#define ERR_SUCCESS ((DWORD)0)
71#define ERR_UNKNOWN_COMMAND ((DWORD)400)
72#define ERR_AUTH_REQUIRED ((DWORD)401)
d096bcdd 73#define ERR_ACCESS_DENIED ((DWORD)403)
deaa4491
VK
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)
1a17feb0 84#define ERR_BAD_RESPONSE ((DWORD)902)
d096bcdd
VK
85#define ERR_IO_FAILURE ((DWORD)903)
86#define ERR_RESOURCE_BUSY ((DWORD)904)
e925a5fc 87#define ERR_EXEC_FAILED ((DWORD)905)
e44ac467
VK
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)
1ba3c17a 92#define ERR_CONNECT_FAILED ((DWORD)910)
78e570e6 93#define ERR_MALFORMED_COMMAND ((DWORD)911)
f1448d17 94#define ERR_SOCKET_ERROR ((DWORD)912)
dbca7ed1 95#define ERR_BAD_ARGUMENTS ((DWORD)913)
5405ce0b 96#define ERR_SUBAGENT_LOAD_FAILED ((DWORD)914)
deb10d32
VK
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)
cbcaf8c8
VK
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
30c68fa1
AK
112//
113// Descriptions for common parameters
114//
115
116#define DCIDESC_DISK_AVAIL "Available disk space on {instance}"
117#define DCIDESC_DISK_AVAILPERC "Percentage of available disk space on {instance}"
118#define DCIDESC_DISK_FREE "Free disk space on {instance}"
119#define DCIDESC_DISK_FREEPERC "Percentage of free disk space on {instance}"
120#define DCIDESC_DISK_TOTAL "Total disk space on {instance}"
121#define DCIDESC_DISK_USED "Used disk space on {instance}"
122#define DCIDESC_DISK_USEDPERC "Percentage of used disk space on {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}"
e7e5ef1c 126#define DCIDESC_NET_INTERFACE_DESCRIPTION "Description of interface {instance}"
30c68fa1
AK
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_OUTERRORS "Number of output errors on interface {instance}"
130#define DCIDESC_NET_INTERFACE_PACKETSIN "Number of input packets on interface {instance}"
131#define DCIDESC_NET_INTERFACE_PACKETSOUT "Number of output packets on interface {instance}"
132#define DCIDESC_NET_INTERFACE_SPEED "Speed of interface {instance}"
133#define DCIDESC_NET_IP_FORWARDING "IP forwarding status"
134#define DCIDESC_NET_IP6_FORWARDING "IPv6 forwarding status"
135#define DCIDESC_PHYSICALDISK_FIRMWARE "Firmware version of hard disk {instance}"
136#define DCIDESC_PHYSICALDISK_MODEL "Model of hard disk {instance}"
137#define DCIDESC_PHYSICALDISK_SERIALNUMBER "Serial number of hard disk {instance}"
138#define DCIDESC_PHYSICALDISK_SMARTATTR ""
139#define DCIDESC_PHYSICALDISK_SMARTSTATUS "Status of hard disk {instance} reported by SMART"
140#define DCIDESC_PHYSICALDISK_TEMPERATURE "Temperature of hard disk {instance}"
141#define DCIDESC_SYSTEM_CPU_COUNT "Number of CPU in the system"
142#define DCIDESC_SYSTEM_HOSTNAME "Host name"
143#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE "Free physical memory"
8a78d30d 144#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE_PCT "Percentage of free physical memory"
30c68fa1
AK
145#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_TOTAL "Total amount of physical memory"
146#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED "Used physical memory"
8a78d30d 147#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED_PCT "Percentage of used physical memory"
30c68fa1 148#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE "Free virtual memory"
8a78d30d 149#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE_PCT "Percentage of free virtual memory"
30c68fa1
AK
150#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_TOTAL "Total amount of virtual memory"
151#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED "Used virtual memory"
8a78d30d 152#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED_PCT "Percentage of used virtual memory"
30c68fa1 153#define DCIDESC_SYSTEM_MEMORY_SWAP_FREE "Free swap space"
8a78d30d 154#define DCIDESC_SYSTEM_MEMORY_SWAP_FREE_PCT "Percentage of free swap space"
30c68fa1
AK
155#define DCIDESC_SYSTEM_MEMORY_SWAP_TOTAL "Total amount of swap space"
156#define DCIDESC_SYSTEM_MEMORY_SWAP_USED "Used swap space"
8a78d30d 157#define DCIDESC_SYSTEM_MEMORY_SWAP_USED_PCT "Percentage of used swap space"
30c68fa1
AK
158#define DCIDESC_SYSTEM_UNAME "System uname"
159#define DCIDESC_AGENT_ACCEPTEDCONNECTIONS "Number of connections accepted by agent"
160#define DCIDESC_AGENT_ACCEPTERRORS "Number of accept() call errors"
161#define DCIDESC_AGENT_ACTIVECONNECTIONS "Number of active connections to agent"
162#define DCIDESC_AGENT_AUTHENTICATIONFAILURES "Number of authentication failures"
522f6f07 163#define DCIDESC_AGENT_CONFIG_SERVER "Configuration server address set on agent startup"
30c68fa1
AK
164#define DCIDESC_AGENT_FAILEDREQUESTS "Number of failed requests to agent"
165#define DCIDESC_AGENT_PROCESSEDREQUESTS "Number of requests processed by agent"
522f6f07 166#define DCIDESC_AGENT_REGISTRAR "Registrar server address set on agent startup"
30c68fa1
AK
167#define DCIDESC_AGENT_REJECTEDCONNECTIONS "Number of connections rejected by agent"
168#define DCIDESC_AGENT_SOURCEPACKAGESUPPORT ""
169#define DCIDESC_AGENT_SUPPORTEDCIPHERS "List of ciphers supported by agent"
170#define DCIDESC_AGENT_TIMEDOUTREQUESTS "Number of timed out requests to agent"
171#define DCIDESC_AGENT_UNSUPPORTEDREQUESTS "Number of requests for unsupported parameters"
172#define DCIDESC_AGENT_UPTIME "Agent's uptime"
173#define DCIDESC_AGENT_VERSION "Agent's version"
174#define DCIDESC_FILE_COUNT "Number of files {instance}"
175#define DCIDESC_FILE_HASH_CRC32 "CRC32 checksum of {instance}"
176#define DCIDESC_FILE_HASH_MD5 "MD5 hash of {instance}"
177#define DCIDESC_FILE_HASH_SHA1 "SHA1 hash of {instance}"
178#define DCIDESC_FILE_SIZE "Size of file {instance}"
179#define DCIDESC_FILE_TIME_ACCESS "Time of last access to file {instance}"
180#define DCIDESC_FILE_TIME_CHANGE "Time of last status change of file {instance}"
181#define DCIDESC_FILE_TIME_MODIFY "Time of last modification of file {instance}"
182#define DCIDESC_SYSTEM_PLATFORMNAME "Platform name"
183#define DCIDESC_PROCESS_COUNT "Number of {instance} processes"
184#define DCIDESC_PROCESS_COUNTEX "Number of {instance} processes (extended)"
ccc34207 185#define DCIDESC_PROCESS_CPUTIME "Total execution time for process {instance}"
a765d97c 186#define DCIDESC_PROCESS_GDIOBJ "GDI objects used by process {instance}"
30c68fa1
AK
187#define DCIDESC_PROCESS_IO_OTHERB ""
188#define DCIDESC_PROCESS_IO_OTHEROP ""
189#define DCIDESC_PROCESS_IO_READB ""
190#define DCIDESC_PROCESS_IO_READOP ""
191#define DCIDESC_PROCESS_IO_WRITEB ""
192#define DCIDESC_PROCESS_IO_WRITEOP ""
761d297e 193#define DCIDESC_PROCESS_KERNELTIME "Total execution time in kernel mode for process {instance}"
a765d97c 194#define DCIDESC_PROCESS_PAGEFAULTS "Page faults for process {instance}"
ccc34207 195#define DCIDESC_PROCESS_SYSCALLS "Number of system calls made by process {instance}"
761d297e 196#define DCIDESC_PROCESS_THREADS "Number of threads in process {instance}"
a765d97c 197#define DCIDESC_PROCESS_USEROBJ "USER objects used by process {instance}"
761d297e 198#define DCIDESC_PROCESS_USERTIME "Total execution time in user mode for process {instance}"
a765d97c
VK
199#define DCIDESC_PROCESS_VMSIZE "Virtual memory used by process {instance}"
200#define DCIDESC_PROCESS_WKSET "Physical memory used by process {instance}"
30c68fa1
AK
201#define DCIDESC_SYSTEM_CONNECTEDUSERS "Number of logged in users"
202#define DCIDESC_SYSTEM_PROCESSCOUNT "Total number of processes"
203#define DCIDESC_SYSTEM_SERVICESTATE "State of {instance} service"
204#define DCIDESC_SYSTEM_PROCESSCOUNT "Total number of processes"
205#define DCIDESC_SYSTEM_THREADCOUNT "Total number of threads"
a765d97c 206#define DCIDESC_PDH_COUNTERVALUE "Value of PDH counter {instance}"
30c68fa1 207#define DCIDESC_PDH_VERSION "Version of PDH.DLL"
30c68fa1
AK
208#define DCIDESC_SYSTEM_UPTIME "System uptime"
209#define DCIDESC_SYSTEM_CPU_LOADAVG "Average CPU load for last minute"
210#define DCIDESC_SYSTEM_CPU_LOADAVG5 "Average CPU load for last 5 minutes"
211#define DCIDESC_SYSTEM_CPU_LOADAVG15 "Average CPU load for last 15 minutes"
ea242c94
AK
212
213
e7e5ef1c
VK
214#define DCIDESC_SYSTEM_CPU_USAGE_EX "Average CPU {instance} utilization for last minute"
215#define DCIDESC_SYSTEM_CPU_USAGE5_EX "Average CPU {instance} utilization for last 5 minutes"
216#define DCIDESC_SYSTEM_CPU_USAGE15_EX "Average CPU {instance} utilization for last 15 minutes"
30c68fa1
AK
217#define DCIDESC_SYSTEM_CPU_USAGE "Average CPU utilization for last minute"
218#define DCIDESC_SYSTEM_CPU_USAGE5 "Average CPU utilization for last 5 minutes"
219#define DCIDESC_SYSTEM_CPU_USAGE15 "Average CPU utilization for last 15 minutes"
ea242c94
AK
220
221#define DCIDESC_SYSTEM_CPU_USAGE_USER_EX "Average CPU {instance} utilization (user) for last minute"
222#define DCIDESC_SYSTEM_CPU_USAGE5_USER_EX "Average CPU {instance} utilization (user) for last 5 minutes"
223#define DCIDESC_SYSTEM_CPU_USAGE15_USER_EX "Average CPU {instance} utilization (user) for last 15 minutes"
224#define DCIDESC_SYSTEM_CPU_USAGE_USER "Average CPU utilization (user) for last minute"
225#define DCIDESC_SYSTEM_CPU_USAGE5_USER "Average CPU utilization (user) for last 5 minutes"
226#define DCIDESC_SYSTEM_CPU_USAGE15_USER "Average CPU utilization (user) for last 15 minutes"
227
228#define DCIDESC_SYSTEM_CPU_USAGE_NICE_EX "Average CPU {instance} utilization (nice) for last minute"
229#define DCIDESC_SYSTEM_CPU_USAGE5_NICE_EX "Average CPU {instance} utilization (nice) for last 5 minutes"
230#define DCIDESC_SYSTEM_CPU_USAGE15_NICE_EX "Average CPU {instance} utilization (nice) for last 15 minutes"
231#define DCIDESC_SYSTEM_CPU_USAGE_NICE "Average CPU utilization (nice) for last minute"
232#define DCIDESC_SYSTEM_CPU_USAGE5_NICE "Average CPU utilization (nice) for last 5 minutes"
233#define DCIDESC_SYSTEM_CPU_USAGE15_NICE "Average CPU utilization (nice) for last 15 minutes"
234
235#define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM_EX "Average CPU {instance} utilization (system) for last minute"
236#define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM_EX "Average CPU {instance} utilization (system) for last 5 minutes"
237#define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM_EX "Average CPU {instance} utilization (system) for last 15 minutes"
238#define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM "Average CPU utilization (system) for last minute"
239#define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM "Average CPU utilization (system) for last 5 minutes"
240#define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM "Average CPU utilization (system) for last 15 minutes"
241
242#define DCIDESC_SYSTEM_CPU_USAGE_IDLE_EX "Average CPU {instance} utilization (idle) for last minute"
243#define DCIDESC_SYSTEM_CPU_USAGE5_IDLE_EX "Average CPU {instance} utilization (idle) for last 5 minutes"
244#define DCIDESC_SYSTEM_CPU_USAGE15_IDLE_EX "Average CPU {instance} utilization (idle) for last 15 minutes"
245#define DCIDESC_SYSTEM_CPU_USAGE_IDLE "Average CPU utilization (idle) for last minute"
246#define DCIDESC_SYSTEM_CPU_USAGE5_IDLE "Average CPU utilization (idle) for last 5 minutes"
247#define DCIDESC_SYSTEM_CPU_USAGE15_IDLE "Average CPU utilization (idle) for last 15 minutes"
248
249#define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last minute"
250#define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last 5 minutes"
251#define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT_EX "Average CPU {instance} utilization (iowait) for last 15 minutes"
252#define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT "Average CPU utilization (iowait) for last minute"
253#define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT "Average CPU utilization (iowait) for last 5 minutes"
254#define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT "Average CPU utilization (iowait) for last 15 minutes"
255
256#define DCIDESC_SYSTEM_CPU_USAGE_IRQ_EX "Average CPU {instance} utilization (irq) for last minute"
257#define DCIDESC_SYSTEM_CPU_USAGE5_IRQ_EX "Average CPU {instance} utilization (irq) for last 5 minutes"
258#define DCIDESC_SYSTEM_CPU_USAGE15_IRQ_EX "Average CPU {instance} utilization (irq) for last 15 minutes"
259#define DCIDESC_SYSTEM_CPU_USAGE_IRQ "Average CPU utilization (irq) for last minute"
260#define DCIDESC_SYSTEM_CPU_USAGE5_IRQ "Average CPU utilization (irq) for last 5 minutes"
261#define DCIDESC_SYSTEM_CPU_USAGE15_IRQ "Average CPU utilization (irq) for last 15 minutes"
262
263#define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last minute"
264#define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last 5 minutes"
265#define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ_EX "Average CPU {instance} utilization (softirq) for last 15 minutes"
266#define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ "Average CPU utilization (softirq) for last minute"
267#define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ "Average CPU utilization (softirq) for last 5 minutes"
268#define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ "Average CPU utilization (softirq) for last 15 minutes"
269
270#define DCIDESC_SYSTEM_CPU_USAGE_STEAL_EX "Average CPU {instance} utilization (steal) for last minute"
271#define DCIDESC_SYSTEM_CPU_USAGE5_STEAL_EX "Average CPU {instance} utilization (steal) for last 5 minutes"
272#define DCIDESC_SYSTEM_CPU_USAGE15_STEAL_EX "Average CPU {instance} utilization (steal) for last 15 minutes"
273#define DCIDESC_SYSTEM_CPU_USAGE_STEAL "Average CPU utilization (steal) for last minute"
274#define DCIDESC_SYSTEM_CPU_USAGE5_STEAL "Average CPU utilization (steal) for last 5 minutes"
275#define DCIDESC_SYSTEM_CPU_USAGE15_STEAL "Average CPU utilization (steal) for last 15 minutes"
276
277
26bba854
VK
278#define DCIDESC_SYSTEM_IO_DISKQUEUE "Average disk queue length for last minute"
279#define DCIDESC_SYSTEM_IO_DISKQUEUE_EX "Average disk queue length of device {instance} for last minute"
a05a2cfc
VK
280#define DCIDESC_SYSTEM_IO_DISKTIME "Percent of CPU time spent on I/O for last minute"
281#define DCIDESC_SYSTEM_IO_DISKTIME_EX "Percent of CPU time spent on I/O on device {instance} for last minute"
26bba854
VK
282#define DCIDESC_SYSTEM_IO_READS "Average number of read operations for last minute"
283#define DCIDESC_SYSTEM_IO_READS_EX "Average number of read operations on device {instance} for last minute"
284#define DCIDESC_SYSTEM_IO_WRITES "Average number of write operations for last minute"
285#define DCIDESC_SYSTEM_IO_WRITES_EX "Average number of write operations on device {instance} for last minute"
286#define DCIDESC_SYSTEM_IO_BYTEREADS "Average number of bytes read for last minute"
287#define DCIDESC_SYSTEM_IO_BYTEREADS_EX "Average number of bytes read on device {instance} for last minute"
288#define DCIDESC_SYSTEM_IO_BYTEWRITES "Average number of bytes written for last minute"
289#define DCIDESC_SYSTEM_IO_BYTEWRITES_EX "Average number of bytes written on device {instance} for last minute"
30c68fa1
AK
290
291
3b376ea0 292//
6827d635 293// Subagent's parameter information
3b376ea0
VK
294//
295
6827d635
VK
296typedef struct
297{
018fda4d 298 TCHAR szName[MAX_PARAM_NAME];
e2d68ddd 299 LONG (* fpHandler)(const TCHAR *, const TCHAR *, TCHAR *);
a765d97c 300 const TCHAR *pArg;
a72a1fb1
VK
301 int iDataType;
302 TCHAR szDescription[MAX_DB_STRING];
6827d635
VK
303} NETXMS_SUBAGENT_PARAM;
304
305
901c96c7
VK
306//
307// Subagent's enum information
308//
309
310typedef struct
311{
018fda4d 312 TCHAR szName[MAX_PARAM_NAME];
6173bea8 313 LONG (* fpHandler)(const TCHAR *, const TCHAR *, StringList *);
a765d97c 314 const TCHAR *pArg;
901c96c7
VK
315} NETXMS_SUBAGENT_ENUM;
316
317
37778a1d
VK
318//
319// Subagent's action information
320//
321
322typedef struct
323{
324 TCHAR szName[MAX_PARAM_NAME];
6173bea8 325 LONG (* fpHandler)(const TCHAR *, StringList *, const TCHAR *);
a765d97c 326 const TCHAR *pArg;
37778a1d
VK
327 TCHAR szDescription[MAX_DB_STRING];
328} NETXMS_SUBAGENT_ACTION;
329
330
6827d635
VK
331//
332// Subagent initialization structure
333//
3b376ea0 334
6173bea8 335#define NETXMS_SUBAGENT_INFO_MAGIC ((DWORD)0x20090905)
ded831ac
VK
336
337class CSCPMessage;
d618c3ae 338
6827d635
VK
339typedef struct
340{
d618c3ae 341 DWORD dwMagic; // Magic number to check if subagent uses correct version of this structure
018fda4d 342 TCHAR szName[MAX_SUBAGENT_NAME];
43caa61e 343 TCHAR szVersion[32];
42a96a81 344 BOOL (* pInit)(Config *); // Called to initialize subagent. Can be NULL.
f0be41a4 345 void (* pShutdown)(void); // Called at subagent unload. Can be NULL.
2e5d6a1e 346 BOOL (* pCommandHandler)(DWORD dwCommand, CSCPMessage *pRequest,
6173bea8 347 CSCPMessage *pResponse, void *session);
6827d635
VK
348 DWORD dwNumParameters;
349 NETXMS_SUBAGENT_PARAM *pParamList;
901c96c7
VK
350 DWORD dwNumEnums;
351 NETXMS_SUBAGENT_ENUM *pEnumList;
37778a1d
VK
352 DWORD dwNumActions;
353 NETXMS_SUBAGENT_ACTION *pActionList;
6827d635 354} NETXMS_SUBAGENT_INFO;
3b376ea0
VK
355
356
cbcaf8c8
VK
357//
358// Inline functions for returning parameters
359//
360
a765d97c 361inline void ret_string(TCHAR *rbuf, const TCHAR *value)
cbcaf8c8 362{
a23d8e0d 363 nx_strncpy(rbuf, value, MAX_RESULT_LENGTH);
cbcaf8c8
VK
364}
365
0212dc5a 366inline void ret_int(TCHAR *rbuf, LONG value)
cbcaf8c8 367{
66d07089 368#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d
VK
369 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%d"), value);
370#else
8b86c5dc 371 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%d"), value);
a23d8e0d 372#endif
cbcaf8c8
VK
373}
374
0212dc5a 375inline void ret_uint(TCHAR *rbuf, DWORD value)
cbcaf8c8 376{
66d07089 377#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d
VK
378 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%u"), value);
379#else
8b86c5dc 380 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%u"), value);
a23d8e0d 381#endif
cbcaf8c8
VK
382}
383
018fda4d 384inline void ret_double(TCHAR *rbuf, double value)
cbcaf8c8 385{
66d07089 386#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d
VK
387 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%f"), value);
388#else
8b86c5dc 389 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%f"), value);
a23d8e0d 390#endif
cbcaf8c8
VK
391}
392
018fda4d 393inline void ret_int64(TCHAR *rbuf, INT64 value)
cbcaf8c8 394{
66d07089 395#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d 396 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%I64d"), value);
cbcaf8c8 397#else /* _WIN32 */
ccc34207 398 _sntprintf(rbuf, MAX_RESULT_LENGTH, INT64_FMT, value);
cbcaf8c8
VK
399#endif /* _WIN32 */
400}
401
018fda4d 402inline void ret_uint64(TCHAR *rbuf, QWORD value)
cbcaf8c8 403{
66d07089 404#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d 405 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%I64u"), value);
cbcaf8c8 406#else /* _WIN32 */
ccc34207 407 _sntprintf(rbuf, MAX_RESULT_LENGTH, UINT64_FMT, value);
cbcaf8c8
VK
408#endif /* _WIN32 */
409}
410
6827d635
VK
411
412//
6173bea8 413// API for subagents
6827d635
VK
414//
415
6173bea8
VK
416BOOL LIBNETXMS_EXPORTABLE AgentGetParameterArg(const TCHAR *param, int index, TCHAR *arg, int maxSize);
417void LIBNETXMS_EXPORTABLE AgentWriteLog(int iLevel, const TCHAR *pszFormat, ...);
418void LIBNETXMS_EXPORTABLE AgentWriteLog2(int iLevel, const TCHAR *pszFormat, va_list args);
419void LIBNETXMS_EXPORTABLE AgentSendTrap(DWORD dwEvent, const char *pszFormat, ...);
420void LIBNETXMS_EXPORTABLE AgentSendTrap2(DWORD dwEvent, int nCount, TCHAR **ppszArgList);
6f1abd2c 421BOOL LIBNETXMS_EXPORTABLE AgentSendFileToServer(void *session, DWORD requestId, const TCHAR *file, long offset);
6827d635 422
cbcaf8c8 423#endif /* _nms_agent_h_ */