additional comments in default hook scripts
[public/netxms.git] / include / nms_agent.h
CommitLineData
cc022855 1/*
7ac71e60 2** NetXMS - Network Management System
d02f6b92 3** Copyright (C) 2003-2013 Victor Kirhenshtein
cbcaf8c8
VK
4**
5** This program is free software; you can redistribute it and/or modify
68f384ea
VK
6** it under the terms of the GNU Lesser General Public License as published by
7** the Free Software Foundation; either version 3 of the License, or
cbcaf8c8
VK
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**
68f384ea 15** You should have received a copy of the GNU Lesser General Public License
cbcaf8c8
VK
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
359784de
VK
26#ifdef _WIN32
27#ifdef LIBNXAGENT_EXPORTS
28#define LIBNXAGENT_EXPORTABLE __declspec(dllexport)
29#else
30#define LIBNXAGENT_EXPORTABLE __declspec(dllimport)
31#endif
32#else /* _WIN32 */
33#define LIBNXAGENT_EXPORTABLE
34#endif
35
36
adc00755 37#include <nms_common.h>
64584976 38#include <nms_util.h>
e6c91aac 39#include <nxconfig.h>
6827d635 40
acc04d96
VK
41/**
42 * Initialization function declaration macro
43 */
a0a945fb 44#if defined(_STATIC_AGENT) || defined(_NETWARE)
e6c91aac 45#define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL NxSubAgentRegister_##name(NETXMS_SUBAGENT_INFO **ppInfo, Config *config)
a0a945fb 46#else
b5138dfb 47#ifdef _WIN32
a0a945fb 48#define DECLSPEC_EXPORT __declspec(dllexport) __cdecl
b5138dfb
VK
49#else
50#define DECLSPEC_EXPORT
51#endif
e6c91aac 52#define DECLARE_SUBAGENT_ENTRY_POINT(name) extern "C" BOOL DECLSPEC_EXPORT NxSubAgentRegister(NETXMS_SUBAGENT_INFO **ppInfo, Config *config)
b5138dfb
VK
53#endif
54
86c126f5
VK
55/**
56 * Constants
57 */
cbcaf8c8 58#define AGENT_LISTEN_PORT 4700
deaa4491 59#define AGENT_PROTOCOL_VERSION 2
cbcaf8c8 60#define MAX_RESULT_LENGTH 256
e22f1644
VK
61#define MAX_CMD_LEN 256
62#define COMMAND_TIMEOUT 60
47e0446b 63#define MAX_SUBAGENT_NAME 64
86c126f5 64#define MAX_INSTANCE_COLUMNS 8
cbcaf8c8 65
d02f6b92
VK
66/**
67 * Agent policy types
68 */
6ca3b41c 69#define AGENT_POLICY_CONFIG 1
f47c176c 70#define AGENT_POLICY_LOG_PARSER 2
6ca3b41c 71
d02f6b92
VK
72/**
73 * Error codes
74 */
967893bb
VK
75#define ERR_SUCCESS ((UINT32)0)
76#define ERR_UNKNOWN_COMMAND ((UINT32)400)
77#define ERR_AUTH_REQUIRED ((UINT32)401)
78#define ERR_ACCESS_DENIED ((UINT32)403)
79#define ERR_UNKNOWN_PARAMETER ((UINT32)404)
80#define ERR_REQUEST_TIMEOUT ((UINT32)408)
81#define ERR_AUTH_FAILED ((UINT32)440)
82#define ERR_ALREADY_AUTHENTICATED ((UINT32)441)
83#define ERR_AUTH_NOT_REQUIRED ((UINT32)442)
84#define ERR_INTERNAL_ERROR ((UINT32)500)
85#define ERR_NOT_IMPLEMENTED ((UINT32)501)
86#define ERR_OUT_OF_RESOURCES ((UINT32)503)
87#define ERR_NOT_CONNECTED ((UINT32)900)
88#define ERR_CONNECTION_BROKEN ((UINT32)901)
89#define ERR_BAD_RESPONSE ((UINT32)902)
90#define ERR_IO_FAILURE ((UINT32)903)
91#define ERR_RESOURCE_BUSY ((UINT32)904)
92#define ERR_EXEC_FAILED ((UINT32)905)
93#define ERR_ENCRYPTION_REQUIRED ((UINT32)906)
94#define ERR_NO_CIPHERS ((UINT32)907)
95#define ERR_INVALID_PUBLIC_KEY ((UINT32)908)
96#define ERR_INVALID_SESSION_KEY ((UINT32)909)
97#define ERR_CONNECT_FAILED ((UINT32)910)
98#define ERR_MALFORMED_COMMAND ((UINT32)911)
99#define ERR_SOCKET_ERROR ((UINT32)912)
100#define ERR_BAD_ARGUMENTS ((UINT32)913)
101#define ERR_SUBAGENT_LOAD_FAILED ((UINT32)914)
102#define ERR_FILE_OPEN_ERROR ((UINT32)915)
103#define ERR_FILE_STAT_FAILED ((UINT32)916)
104#define ERR_MEM_ALLOC_FAILED ((UINT32)917)
105#define ERR_FILE_DELETE_FAILED ((UINT32)918)
9c786c0f 106#define ERR_NO_SESSION_AGENT ((UINT32)919)
87fff547 107#define ERR_SERVER_ID_UNSET ((UINT32)920)
cbcaf8c8 108
d02f6b92
VK
109/**
110 * Parameter handler return codes
111 */
cbcaf8c8
VK
112#define SYSINFO_RC_SUCCESS 0
113#define SYSINFO_RC_UNSUPPORTED 1
114#define SYSINFO_RC_ERROR 2
115
d02f6b92
VK
116/**
117 * WinPerf features
118 */
967893bb
VK
119#define WINPERF_AUTOMATIC_SAMPLE_COUNT ((UINT32)0x00000001)
120#define WINPERF_REMOTE_COUNTER_CONFIG ((UINT32)0x00000002)
cbcaf8c8 121
74540dab
VK
122/**
123 * User session states (used by session agents)
124 */
125#define USER_SESSION_ACTIVE 0
126#define USER_SESSION_CONNECTED 1
127#define USER_SESSION_DISCONNECTED 2
128#define USER_SESSION_IDLE 3
129#define USER_SESSION_OTHER 4
130
d02f6b92
VK
131/**
132 * Descriptions for common parameters
133 */
bf3b7f79
VK
134#define DCIDESC_FS_AVAIL _T("Available space on file system {instance}")
135#define DCIDESC_FS_AVAILPERC _T("Percentage of available space on file system {instance}")
136#define DCIDESC_FS_FREE _T("Free space on file system {instance}")
137#define DCIDESC_FS_FREEPERC _T("Percentage of free space on file system {instance}")
138#define DCIDESC_FS_TOTAL _T("Total space on file system {instance}")
4a675f94 139#define DCIDESC_FS_TYPE _T("Type of file system {instance}")
bf3b7f79
VK
140#define DCIDESC_FS_USED _T("Used space on file system {instance}")
141#define DCIDESC_FS_USEDPERC _T("Percentage of used space on file system {instance}")
11b75b2e 142#define DCIDESC_NET_INTERFACE_64BITCOUNTERS _T("Is 64bit interface counters supported")
bf3b7f79
VK
143#define DCIDESC_NET_INTERFACE_ADMINSTATUS _T("Administrative status of interface {instance}")
144#define DCIDESC_NET_INTERFACE_BYTESIN _T("Number of input bytes on interface {instance}")
145#define DCIDESC_NET_INTERFACE_BYTESOUT _T("Number of output bytes on interface {instance}")
146#define DCIDESC_NET_INTERFACE_DESCRIPTION _T("Description of interface {instance}")
147#define DCIDESC_NET_INTERFACE_INERRORS _T("Number of input errors on interface {instance}")
148#define DCIDESC_NET_INTERFACE_LINK _T("Link status for interface {instance}")
149#define DCIDESC_NET_INTERFACE_MTU _T("MTU for interface {instance}")
150#define DCIDESC_NET_INTERFACE_OPERSTATUS _T("Operational status of interface {instance}")
151#define DCIDESC_NET_INTERFACE_OUTERRORS _T("Number of output errors on interface {instance}")
152#define DCIDESC_NET_INTERFACE_PACKETSIN _T("Number of input packets on interface {instance}")
153#define DCIDESC_NET_INTERFACE_PACKETSOUT _T("Number of output packets on interface {instance}")
154#define DCIDESC_NET_INTERFACE_SPEED _T("Speed of interface {instance}")
155#define DCIDESC_NET_IP_FORWARDING _T("IP forwarding status")
156#define DCIDESC_NET_IP6_FORWARDING _T("IPv6 forwarding status")
ecdf8898
VK
157#define DCIDESC_NET_RESOLVER_ADDRBYNAME _T("Resolver: address for name {instance}")
158#define DCIDESC_NET_RESOLVER_NAMEBYADDR _T("Resolver: name for address {instance}")
bf3b7f79
VK
159#define DCIDESC_PHYSICALDISK_FIRMWARE _T("Firmware version of hard disk {instance}")
160#define DCIDESC_PHYSICALDISK_MODEL _T("Model of hard disk {instance}")
161#define DCIDESC_PHYSICALDISK_SERIALNUMBER _T("Serial number of hard disk {instance}")
162#define DCIDESC_PHYSICALDISK_SMARTATTR _T("")
163#define DCIDESC_PHYSICALDISK_SMARTSTATUS _T("Status of hard disk {instance} reported by SMART")
164#define DCIDESC_PHYSICALDISK_TEMPERATURE _T("Temperature of hard disk {instance}")
165#define DCIDESC_SYSTEM_CPU_COUNT _T("Number of CPU in the system")
166#define DCIDESC_SYSTEM_HOSTNAME _T("Host name")
5741ae09
VK
167#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_AVAILABLE _T("Available physical memory")
168#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_AVAILABLE_PCT _T("Percentage of available physical memory")
169#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_BUFFERS _T("Physical memory used for buffers")
170#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_BUFFERS_PCT _T("Percentage of physical memory used for buffers")
171#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_CACHED _T("Physical memory used for cache")
172#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_CACHED_PCT _T("Percentage of physical memory used for cache")
bf3b7f79
VK
173#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE _T("Free physical memory")
174#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE_PCT _T("Percentage of free physical memory")
175#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_TOTAL _T("Total amount of physical memory")
176#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED _T("Used physical memory")
177#define DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED_PCT _T("Percentage of used physical memory")
03a48429
VK
178#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_ACTIVE _T("Active virtual memory")
179#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_ACTIVE_PCT _T("Percentage of active virtual memory")
bf3b7f79
VK
180#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE _T("Free virtual memory")
181#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE_PCT _T("Percentage of free virtual memory")
182#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_TOTAL _T("Total amount of virtual memory")
183#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED _T("Used virtual memory")
184#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED_PCT _T("Percentage of used virtual memory")
185#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_AVAILABLE _T("Available virtual memory")
186#define DCIDESC_SYSTEM_MEMORY_VIRTUAL_AVAILABLE_PCT _T("Percentage of available virtual memory")
187#define DCIDESC_SYSTEM_MEMORY_SWAP_FREE _T("Free swap space")
188#define DCIDESC_SYSTEM_MEMORY_SWAP_FREE_PCT _T("Percentage of free swap space")
189#define DCIDESC_SYSTEM_MEMORY_SWAP_TOTAL _T("Total amount of swap space")
190#define DCIDESC_SYSTEM_MEMORY_SWAP_USED _T("Used swap space")
191#define DCIDESC_SYSTEM_MEMORY_SWAP_USED_PCT _T("Percentage of used swap space")
192#define DCIDESC_SYSTEM_UNAME _T("System uname")
193#define DCIDESC_AGENT_ACCEPTEDCONNECTIONS _T("Number of connections accepted by agent")
194#define DCIDESC_AGENT_ACCEPTERRORS _T("Number of accept() call errors")
195#define DCIDESC_AGENT_ACTIVECONNECTIONS _T("Number of active connections to agent")
196#define DCIDESC_AGENT_AUTHENTICATIONFAILURES _T("Number of authentication failures")
197#define DCIDESC_AGENT_CONFIG_SERVER _T("Configuration server address set on agent startup")
198#define DCIDESC_AGENT_FAILEDREQUESTS _T("Number of failed requests to agent")
199#define DCIDESC_AGENT_GENERATED_TRAPS _T("Number of traps generated by agent")
05db3127 200#define DCIDESC_AGENT_IS_SUBAGENT_LOADED _T("Check if given subagent is loaded")
bf3b7f79
VK
201#define DCIDESC_AGENT_LAST_TRAP_TIME _T("Timestamp of last generated trap")
202#define DCIDESC_AGENT_PROCESSEDREQUESTS _T("Number of requests processed by agent")
203#define DCIDESC_AGENT_REGISTRAR _T("Registrar server address set on agent startup")
204#define DCIDESC_AGENT_REJECTEDCONNECTIONS _T("Number of connections rejected by agent")
205#define DCIDESC_AGENT_SENT_TRAPS _T("Number of traps successfully sent to server")
05db3127 206#define DCIDESC_AGENT_SOURCEPACKAGESUPPORT _T("Check if source packages are supported")
bf3b7f79 207#define DCIDESC_AGENT_SUPPORTEDCIPHERS _T("List of ciphers supported by agent")
374afd7b
VK
208#define DCIDESC_AGENT_THREADPOOL_ACTIVEREQUESTS _T("Agent thread pool {instance}: active requests")
209#define DCIDESC_AGENT_THREADPOOL_CURRSIZE _T("Agent thread pool {instance}: current size")
210#define DCIDESC_AGENT_THREADPOOL_LOAD _T("Agent thread pool {instance}: current load")
211#define DCIDESC_AGENT_THREADPOOL_LOADAVG _T("Agent thread pool {instance}: load average (1 minute)")
212#define DCIDESC_AGENT_THREADPOOL_LOADAVG_5 _T("Agent thread pool {instance}: load average (5 minutes)")
213#define DCIDESC_AGENT_THREADPOOL_LOADAVG_15 _T("Agent thread pool {instance}: load average (15 minutes)")
214#define DCIDESC_AGENT_THREADPOOL_MAXSIZE _T("Agent thread pool {instance}: max size")
215#define DCIDESC_AGENT_THREADPOOL_MINSIZE _T("Agent thread pool {instance}: min size")
216#define DCIDESC_AGENT_THREADPOOL_USAGE _T("Agent thread pool {instance}: usage")
bf3b7f79
VK
217#define DCIDESC_AGENT_TIMEDOUTREQUESTS _T("Number of timed out requests to agent")
218#define DCIDESC_AGENT_UNSUPPORTEDREQUESTS _T("Number of requests for unsupported parameters")
219#define DCIDESC_AGENT_UPTIME _T("Agent's uptime")
220#define DCIDESC_AGENT_VERSION _T("Agent's version")
221#define DCIDESC_FILE_COUNT _T("Number of files {instance}")
5ad4ed06 222#define DCIDESC_FILE_FOLDERCOUNT _T("Number of folders {instance}")
bf3b7f79
VK
223#define DCIDESC_FILE_HASH_CRC32 _T("CRC32 checksum of {instance}")
224#define DCIDESC_FILE_HASH_MD5 _T("MD5 hash of {instance}")
225#define DCIDESC_FILE_HASH_SHA1 _T("SHA1 hash of {instance}")
226#define DCIDESC_FILE_SIZE _T("Size of file {instance}")
227#define DCIDESC_FILE_TIME_ACCESS _T("Time of last access to file {instance}")
228#define DCIDESC_FILE_TIME_CHANGE _T("Time of last status change of file {instance}")
229#define DCIDESC_FILE_TIME_MODIFY _T("Time of last modification of file {instance}")
8ce7501b 230#define DCIDESC_SYSTEM_CURRENTTIME _T("Current system time")
bf3b7f79
VK
231#define DCIDESC_SYSTEM_PLATFORMNAME _T("Platform name")
232#define DCIDESC_PROCESS_COUNT _T("Number of {instance} processes")
233#define DCIDESC_PROCESS_COUNTEX _T("Number of {instance} processes (extended)")
234#define DCIDESC_PROCESS_CPUTIME _T("Total execution time for process {instance}")
235#define DCIDESC_PROCESS_GDIOBJ _T("GDI objects used by process {instance}")
92b25da9 236#define DCIDESC_PROCESS_HANDLES _T("Number of handles in process {instance}")
bf3b7f79
VK
237#define DCIDESC_PROCESS_IO_OTHERB _T("")
238#define DCIDESC_PROCESS_IO_OTHEROP _T("")
239#define DCIDESC_PROCESS_IO_READB _T("")
240#define DCIDESC_PROCESS_IO_READOP _T("")
241#define DCIDESC_PROCESS_IO_WRITEB _T("")
242#define DCIDESC_PROCESS_IO_WRITEOP _T("")
243#define DCIDESC_PROCESS_KERNELTIME _T("Total execution time in kernel mode for process {instance}")
244#define DCIDESC_PROCESS_PAGEFAULTS _T("Page faults for process {instance}")
245#define DCIDESC_PROCESS_SYSCALLS _T("Number of system calls made by process {instance}")
246#define DCIDESC_PROCESS_THREADS _T("Number of threads in process {instance}")
247#define DCIDESC_PROCESS_USEROBJ _T("USER objects used by process {instance}")
248#define DCIDESC_PROCESS_USERTIME _T("Total execution time in user mode for process {instance}")
249#define DCIDESC_PROCESS_VMSIZE _T("Virtual memory used by process {instance}")
250#define DCIDESC_PROCESS_WKSET _T("Physical memory used by process {instance}")
92b25da9 251#define DCIDESC_PROCESS_ZOMBIE_COUNT _T("Number of {instance} zombie processes")
bf3b7f79
VK
252#define DCIDESC_SYSTEM_APPADDRESSSPACE _T("Address space available to applications (MB)")
253#define DCIDESC_SYSTEM_CONNECTEDUSERS _T("Number of logged in users")
92b25da9 254#define DCIDESC_SYSTEM_HANDLECOUNT _T("Total number of handles")
bf3b7f79
VK
255#define DCIDESC_SYSTEM_PROCESSCOUNT _T("Total number of processes")
256#define DCIDESC_SYSTEM_SERVICESTATE _T("State of {instance} service")
bf3b7f79
VK
257#define DCIDESC_SYSTEM_THREADCOUNT _T("Total number of threads")
258#define DCIDESC_PDH_COUNTERVALUE _T("Value of PDH counter {instance}")
259#define DCIDESC_PDH_VERSION _T("Version of PDH.DLL")
260#define DCIDESC_SYSTEM_UPTIME _T("System uptime")
261#define DCIDESC_SYSTEM_CPU_LOADAVG _T("Average CPU load for last minute")
262#define DCIDESC_SYSTEM_CPU_LOADAVG5 _T("Average CPU load for last 5 minutes")
263#define DCIDESC_SYSTEM_CPU_LOADAVG15 _T("Average CPU load for last 15 minutes")
264
265
266#define DCIDESC_SYSTEM_CPU_USAGE_EX _T("Average CPU {instance} utilization for last minute")
267#define DCIDESC_SYSTEM_CPU_USAGE5_EX _T("Average CPU {instance} utilization for last 5 minutes")
268#define DCIDESC_SYSTEM_CPU_USAGE15_EX _T("Average CPU {instance} utilization for last 15 minutes")
269#define DCIDESC_SYSTEM_CPU_USAGE _T("Average CPU utilization for last minute")
270#define DCIDESC_SYSTEM_CPU_USAGE5 _T("Average CPU utilization for last 5 minutes")
271#define DCIDESC_SYSTEM_CPU_USAGE15 _T("Average CPU utilization for last 15 minutes")
272
273#define DCIDESC_SYSTEM_CPU_USAGE_USER_EX _T("Average CPU {instance} utilization (user) for last minute")
274#define DCIDESC_SYSTEM_CPU_USAGE5_USER_EX _T("Average CPU {instance} utilization (user) for last 5 minutes")
275#define DCIDESC_SYSTEM_CPU_USAGE15_USER_EX _T("Average CPU {instance} utilization (user) for last 15 minutes")
276#define DCIDESC_SYSTEM_CPU_USAGE_USER _T("Average CPU utilization (user) for last minute")
277#define DCIDESC_SYSTEM_CPU_USAGE5_USER _T("Average CPU utilization (user) for last 5 minutes")
278#define DCIDESC_SYSTEM_CPU_USAGE15_USER _T("Average CPU utilization (user) for last 15 minutes")
279
280#define DCIDESC_SYSTEM_CPU_USAGE_NICE_EX _T("Average CPU {instance} utilization (nice) for last minute")
281#define DCIDESC_SYSTEM_CPU_USAGE5_NICE_EX _T("Average CPU {instance} utilization (nice) for last 5 minutes")
282#define DCIDESC_SYSTEM_CPU_USAGE15_NICE_EX _T("Average CPU {instance} utilization (nice) for last 15 minutes")
283#define DCIDESC_SYSTEM_CPU_USAGE_NICE _T("Average CPU utilization (nice) for last minute")
284#define DCIDESC_SYSTEM_CPU_USAGE5_NICE _T("Average CPU utilization (nice) for last 5 minutes")
285#define DCIDESC_SYSTEM_CPU_USAGE15_NICE _T("Average CPU utilization (nice) for last 15 minutes")
286
287#define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM_EX _T("Average CPU {instance} utilization (system) for last minute")
288#define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM_EX _T("Average CPU {instance} utilization (system) for last 5 minutes")
289#define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM_EX _T("Average CPU {instance} utilization (system) for last 15 minutes")
290#define DCIDESC_SYSTEM_CPU_USAGE_SYSTEM _T("Average CPU utilization (system) for last minute")
291#define DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM _T("Average CPU utilization (system) for last 5 minutes")
292#define DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM _T("Average CPU utilization (system) for last 15 minutes")
293
294#define DCIDESC_SYSTEM_CPU_USAGE_IDLE_EX _T("Average CPU {instance} utilization (idle) for last minute")
295#define DCIDESC_SYSTEM_CPU_USAGE5_IDLE_EX _T("Average CPU {instance} utilization (idle) for last 5 minutes")
296#define DCIDESC_SYSTEM_CPU_USAGE15_IDLE_EX _T("Average CPU {instance} utilization (idle) for last 15 minutes")
297#define DCIDESC_SYSTEM_CPU_USAGE_IDLE _T("Average CPU utilization (idle) for last minute")
298#define DCIDESC_SYSTEM_CPU_USAGE5_IDLE _T("Average CPU utilization (idle) for last 5 minutes")
299#define DCIDESC_SYSTEM_CPU_USAGE15_IDLE _T("Average CPU utilization (idle) for last 15 minutes")
300
301#define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT_EX _T("Average CPU {instance} utilization (iowait) for last minute")
302#define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT_EX _T("Average CPU {instance} utilization (iowait) for last 5 minutes")
303#define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT_EX _T("Average CPU {instance} utilization (iowait) for last 15 minutes")
304#define DCIDESC_SYSTEM_CPU_USAGE_IOWAIT _T("Average CPU utilization (iowait) for last minute")
305#define DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT _T("Average CPU utilization (iowait) for last 5 minutes")
306#define DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT _T("Average CPU utilization (iowait) for last 15 minutes")
307
308#define DCIDESC_SYSTEM_CPU_USAGE_IRQ_EX _T("Average CPU {instance} utilization (irq) for last minute")
309#define DCIDESC_SYSTEM_CPU_USAGE5_IRQ_EX _T("Average CPU {instance} utilization (irq) for last 5 minutes")
310#define DCIDESC_SYSTEM_CPU_USAGE15_IRQ_EX _T("Average CPU {instance} utilization (irq) for last 15 minutes")
311#define DCIDESC_SYSTEM_CPU_USAGE_IRQ _T("Average CPU utilization (irq) for last minute")
312#define DCIDESC_SYSTEM_CPU_USAGE5_IRQ _T("Average CPU utilization (irq) for last 5 minutes")
313#define DCIDESC_SYSTEM_CPU_USAGE15_IRQ _T("Average CPU utilization (irq) for last 15 minutes")
314
315#define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ_EX _T("Average CPU {instance} utilization (softirq) for last minute")
316#define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ_EX _T("Average CPU {instance} utilization (softirq) for last 5 minutes")
317#define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ_EX _T("Average CPU {instance} utilization (softirq) for last 15 minutes")
318#define DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ _T("Average CPU utilization (softirq) for last minute")
319#define DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ _T("Average CPU utilization (softirq) for last 5 minutes")
320#define DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ _T("Average CPU utilization (softirq) for last 15 minutes")
321
322#define DCIDESC_SYSTEM_CPU_USAGE_STEAL_EX _T("Average CPU {instance} utilization (steal) for last minute")
323#define DCIDESC_SYSTEM_CPU_USAGE5_STEAL_EX _T("Average CPU {instance} utilization (steal) for last 5 minutes")
324#define DCIDESC_SYSTEM_CPU_USAGE15_STEAL_EX _T("Average CPU {instance} utilization (steal) for last 15 minutes")
325#define DCIDESC_SYSTEM_CPU_USAGE_STEAL _T("Average CPU utilization (steal) for last minute")
326#define DCIDESC_SYSTEM_CPU_USAGE5_STEAL _T("Average CPU utilization (steal) for last 5 minutes")
327#define DCIDESC_SYSTEM_CPU_USAGE15_STEAL _T("Average CPU utilization (steal) for last 15 minutes")
328
329#define DCIDESC_SYSTEM_CPU_USAGE_GUEST_EX _T("Average CPU {instance} utilization (guest) for last minute")
330#define DCIDESC_SYSTEM_CPU_USAGE5_GUEST_EX _T("Average CPU {instance} utilization (guest) for last 5 minutes")
331#define DCIDESC_SYSTEM_CPU_USAGE15_GUEST_EX _T("Average CPU {instance} utilization (guest) for last 15 minutes")
332#define DCIDESC_SYSTEM_CPU_USAGE_GUEST _T("Average CPU utilization (guest) for last minute")
333#define DCIDESC_SYSTEM_CPU_USAGE5_GUEST _T("Average CPU utilization (guest) for last 5 minutes")
334#define DCIDESC_SYSTEM_CPU_USAGE15_GUEST _T("Average CPU utilization (guest) for last 15 minutes")
335
336#define DCIDESC_SYSTEM_IO_DISKQUEUE _T("Average disk queue length for last minute")
3e00a175
VK
337#define DCIDESC_SYSTEM_IO_DISKQUEUE_MIN _T("Minimum disk queue length for last minute")
338#define DCIDESC_SYSTEM_IO_DISKQUEUE_MAX _T("Maximum disk queue length for last minute")
bf3b7f79 339#define DCIDESC_SYSTEM_IO_DISKQUEUE_EX _T("Average disk queue length of device {instance} for last minute")
3e00a175
VK
340#define DCIDESC_SYSTEM_IO_DISKQUEUE_EX_MIN _T("Minimum disk queue length of device {instance} for last minute")
341#define DCIDESC_SYSTEM_IO_DISKQUEUE_EX_MAX _T("Maximum disk queue length of device {instance} for last minute")
bf3b7f79
VK
342#define DCIDESC_SYSTEM_IO_DISKTIME _T("Percent of CPU time spent on I/O for last minute")
343#define DCIDESC_SYSTEM_IO_DISKTIME_EX _T("Percent of CPU time spent on I/O on device {instance} for last minute")
344#define DCIDESC_SYSTEM_IO_WAITTIME _T("Average I/O request wait time")
345#define DCIDESC_SYSTEM_IO_WAITTIME_EX _T("Average I/O request wait time for device {instance}")
346#define DCIDESC_SYSTEM_IO_READS _T("Average number of read operations for last minute")
3e00a175
VK
347#define DCIDESC_SYSTEM_IO_READS_MIN _T("Minimum number of read operations for last minute")
348#define DCIDESC_SYSTEM_IO_READS_MAX _T("Maximum number of read operations for last minute")
bf3b7f79 349#define DCIDESC_SYSTEM_IO_READS_EX _T("Average number of read operations on device {instance} for last minute")
3e00a175
VK
350#define DCIDESC_SYSTEM_IO_READS_EX_MIN _T("Minimum number of read operations on device {instance} for last minute")
351#define DCIDESC_SYSTEM_IO_READS_EX_MAX _T("Maximum number of read operations on device {instance} for last minute")
bf3b7f79 352#define DCIDESC_SYSTEM_IO_WRITES _T("Average number of write operations for last minute")
3e00a175
VK
353#define DCIDESC_SYSTEM_IO_WRITES_MIN _T("Minimum number of write operations for last minute")
354#define DCIDESC_SYSTEM_IO_WRITES_MAX _T("Maximum number of write operations for last minute")
bf3b7f79 355#define DCIDESC_SYSTEM_IO_WRITES_EX _T("Average number of write operations on device {instance} for last minute")
3e00a175
VK
356#define DCIDESC_SYSTEM_IO_WRITES_EX_MIN _T("Minimum number of write operations on device {instance} for last minute")
357#define DCIDESC_SYSTEM_IO_WRITES_EX_MAX _T("Maximum number of write operations on device {instance} for last minute")
bf3b7f79 358#define DCIDESC_SYSTEM_IO_XFERS _T("Average number of I/O transfers for last minute")
3e00a175
VK
359#define DCIDESC_SYSTEM_IO_XFERS_MIN _T("Minimum number of I/O transfers for last minute")
360#define DCIDESC_SYSTEM_IO_XFERS_MAX _T("Maximum number of I/O transfers for last minute")
bf3b7f79 361#define DCIDESC_SYSTEM_IO_XFERS_EX _T("Average number of I/O transfers on device {instance} for last minute")
3e00a175
VK
362#define DCIDESC_SYSTEM_IO_XFERS_EX_MIN _T("Minimum number of I/O transfers on device {instance} for last minute")
363#define DCIDESC_SYSTEM_IO_XFERS_EX_MAX _T("Maximum number of I/O transfers on device {instance} for last minute")
bf3b7f79 364#define DCIDESC_SYSTEM_IO_BYTEREADS _T("Average number of bytes read for last minute")
3e00a175
VK
365#define DCIDESC_SYSTEM_IO_BYTEREADS_MIN _T("Minimum number of bytes read for last minute")
366#define DCIDESC_SYSTEM_IO_BYTEREADS_MAX _T("Maximum number of bytes read for last minute")
bf3b7f79 367#define DCIDESC_SYSTEM_IO_BYTEREADS_EX _T("Average number of bytes read on device {instance} for last minute")
3e00a175
VK
368#define DCIDESC_SYSTEM_IO_BYTEREADS_EX_MIN _T("Minimum number of bytes read on device {instance} for last minute")
369#define DCIDESC_SYSTEM_IO_BYTEREADS_EX_MAX _T("Maximum number of bytes read on device {instance} for last minute")
bf3b7f79 370#define DCIDESC_SYSTEM_IO_BYTEWRITES _T("Average number of bytes written for last minute")
3e00a175
VK
371#define DCIDESC_SYSTEM_IO_BYTEWRITES_MIN _T("Minimum number of bytes written for last minute")
372#define DCIDESC_SYSTEM_IO_BYTEWRITES_MAX _T("Maximum number of bytes written for last minute")
bf3b7f79 373#define DCIDESC_SYSTEM_IO_BYTEWRITES_EX _T("Average number of bytes written on device {instance} for last minute")
3e00a175
VK
374#define DCIDESC_SYSTEM_IO_BYTEWRITES_EX_MIN _T("Minimum number of bytes written on device {instance} for last minute")
375#define DCIDESC_SYSTEM_IO_BYTEWRITES_EX_MAX _T("Maximum number of bytes written on device {instance} for last minute")
bf3b7f79
VK
376#define DCIDESC_SYSTEM_IO_OPENFILES _T("Number of open files")
377
378
379#define DCIDESC_DEPRECATED _T("<deprecated>")
30c68fa1
AK
380
381
74540dab 382#define DCTDESC_AGENT_SESSION_AGENTS _T("Registered session agents")
ad12a86f 383#define DCTDESC_AGENT_SUBAGENTS _T("Loaded subagents")
a8799146 384#define DCTDESC_FILESYSTEM_VOLUMES _T("File system volumes")
ac60d715 385#define DCTDESC_SYSTEM_INSTALLED_PRODUCTS _T("Installed products")
92b25da9 386#define DCTDESC_SYSTEM_OPEN_FILES _T("Open files")
ad12a86f 387#define DCTDESC_SYSTEM_PROCESSES _T("Processes")
cc8ce218 388
5944946e
VK
389/**
390 * API for CommSession
391 */
6fbaa926 392class AbstractCommSession : public RefCountObject
5944946e
VK
393{
394public:
9319c166
VK
395 virtual bool isMasterServer() = 0;
396 virtual bool isControlServer() = 0;
0d956dd9 397 virtual bool canAcceptTraps() = 0;
e13420c1 398 virtual bool canAcceptFileUpdates() = 0;
e9902466 399 virtual UINT64 getServerId() = 0;
8c75ad41 400 virtual const InetAddress& getServerAddress() = 0;
9319c166 401
ea3993c8
VK
402 virtual bool isIPv6Aware() = 0;
403
6fbaa926
VK
404 virtual void sendMessage(NXCPMessage *msg) = 0;
405 virtual void sendRawMessage(NXCP_MESSAGE *msg) = 0;
9319c166 406 virtual bool sendFile(UINT32 requestId, const TCHAR *file, long offset) = 0;
63ff3c9d 407 virtual UINT32 doRequest(NXCPMessage *msg, UINT32 timeout) = 0;
6fbaa926 408 virtual UINT32 generateRequestId() = 0;
9319c166 409 virtual UINT32 openFile(TCHAR* nameOfFile, UINT32 requestId) = 0;
5944946e
VK
410};
411
0f506caa
VK
412/**
413 * Subagent's parameter information
414 */
6827d635
VK
415typedef struct
416{
4687826e 417 TCHAR name[MAX_PARAM_NAME];
060c5a11 418 LONG (* handler)(const TCHAR *, const TCHAR *, TCHAR *, AbstractCommSession *);
4687826e
VK
419 const TCHAR *arg;
420 int dataType; // Use DT_DEPRECATED to indicate deprecated parameter
421 TCHAR description[MAX_DB_STRING];
6827d635
VK
422} NETXMS_SUBAGENT_PARAM;
423
0f506caa
VK
424/**
425 * Subagent's push parameter information
426 */
f480bdd4
VK
427typedef struct
428{
429 TCHAR name[MAX_PARAM_NAME];
430 int dataType;
431 TCHAR description[MAX_DB_STRING];
432} NETXMS_SUBAGENT_PUSHPARAM;
433
0f506caa
VK
434/**
435 * Subagent's list information
436 */
901c96c7
VK
437typedef struct
438{
4687826e 439 TCHAR name[MAX_PARAM_NAME];
060c5a11 440 LONG (* handler)(const TCHAR *, const TCHAR *, StringList *, AbstractCommSession *);
4687826e 441 const TCHAR *arg;
cb97f4dd 442 TCHAR description[MAX_DB_STRING];
4687826e
VK
443} NETXMS_SUBAGENT_LIST;
444
cb97f4dd
VK
445/**
446 * Subagent's table column information
447 */
448typedef struct
449{
450 TCHAR name[MAX_COLUMN_NAME];
451 TCHAR displayName[MAX_COLUMN_NAME];
452 int dataType;
453 bool isInstance;
454} NETXMS_SUBAGENT_TABLE_COLUMN;
455
0f506caa
VK
456/**
457 * Subagent's table information
458 */
4687826e
VK
459typedef struct
460{
461 TCHAR name[MAX_PARAM_NAME];
060c5a11 462 LONG (* handler)(const TCHAR *, const TCHAR *, Table *, AbstractCommSession *);
4687826e 463 const TCHAR *arg;
52f5ee00 464 TCHAR instanceColumns[MAX_COLUMN_NAME * MAX_INSTANCE_COLUMNS];
cc8ce218 465 TCHAR description[MAX_DB_STRING];
cb97f4dd
VK
466 int numColumns;
467 NETXMS_SUBAGENT_TABLE_COLUMN *columns;
4687826e 468} NETXMS_SUBAGENT_TABLE;
901c96c7 469
0f506caa
VK
470/**
471 * Subagent's action information
472 */
37778a1d
VK
473typedef struct
474{
4687826e 475 TCHAR name[MAX_PARAM_NAME];
060c5a11 476 LONG (* handler)(const TCHAR *, StringList *, const TCHAR *, AbstractCommSession *);
4687826e
VK
477 const TCHAR *arg;
478 TCHAR description[MAX_DB_STRING];
37778a1d
VK
479} NETXMS_SUBAGENT_ACTION;
480
cb97f4dd 481#define NETXMS_SUBAGENT_INFO_MAGIC ((UINT32)0x20150626)
ded831ac 482
b368969c 483class NXCPMessage;
d618c3ae 484
5944946e
VK
485/**
486 * Subagent initialization structure
487 */
6827d635
VK
488typedef struct
489{
967893bb 490 UINT32 magic; // Magic number to check if subagent uses correct version of this structure
4687826e
VK
491 TCHAR name[MAX_SUBAGENT_NAME];
492 TCHAR version[32];
493 BOOL (* init)(Config *); // Called to initialize subagent. Can be NULL.
494 void (* shutdown)(); // Called at subagent unload. Can be NULL.
b368969c 495 BOOL (* commandHandler)(UINT32 command, NXCPMessage *request, NXCPMessage *response, AbstractCommSession *session);
967893bb 496 UINT32 numParameters;
4687826e 497 NETXMS_SUBAGENT_PARAM *parameters;
967893bb 498 UINT32 numLists;
4687826e 499 NETXMS_SUBAGENT_LIST *lists;
967893bb 500 UINT32 numTables;
4687826e 501 NETXMS_SUBAGENT_TABLE *tables;
967893bb 502 UINT32 numActions;
4687826e 503 NETXMS_SUBAGENT_ACTION *actions;
967893bb 504 UINT32 numPushParameters;
4687826e 505 NETXMS_SUBAGENT_PUSHPARAM *pushParameters;
6827d635 506} NETXMS_SUBAGENT_INFO;
3b376ea0 507
0f506caa
VK
508/**
509 * Inline functions for returning parameters
510 */
a765d97c 511inline void ret_string(TCHAR *rbuf, const TCHAR *value)
cbcaf8c8 512{
a23d8e0d 513 nx_strncpy(rbuf, value, MAX_RESULT_LENGTH);
cbcaf8c8
VK
514}
515
f3387429
VK
516inline void ret_wstring(TCHAR *rbuf, const WCHAR *value)
517{
518#ifdef UNICODE
519 nx_strncpy(rbuf, value, MAX_RESULT_LENGTH);
520#else
521 WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, value, -1, rbuf, MAX_RESULT_LENGTH, NULL, NULL);
522 rbuf[MAX_RESULT_LENGTH - 1] = 0;
523#endif
524}
525
526inline void ret_mbstring(TCHAR *rbuf, const char *value)
527{
528#ifdef UNICODE
529 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, value, -1, rbuf, MAX_RESULT_LENGTH);
530 rbuf[MAX_RESULT_LENGTH - 1] = 0;
531#else
532 nx_strncpy(rbuf, value, MAX_RESULT_LENGTH);
533#endif
534}
535
0212dc5a 536inline void ret_int(TCHAR *rbuf, LONG value)
cbcaf8c8 537{
66d07089 538#if defined(_WIN32) && (_MSC_VER >= 1300)
6e38075b 539 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%ld"), (long)value);
a23d8e0d 540#else
6e38075b 541 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%ld"), (long)value);
a23d8e0d 542#endif
cbcaf8c8
VK
543}
544
967893bb 545inline void ret_uint(TCHAR *rbuf, UINT32 value)
cbcaf8c8 546{
66d07089 547#if defined(_WIN32) && (_MSC_VER >= 1300)
6e38075b 548 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%lu"), (unsigned long)value);
a23d8e0d 549#else
6e38075b 550 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%lu"), (unsigned long)value);
a23d8e0d 551#endif
cbcaf8c8
VK
552}
553
018fda4d 554inline void ret_double(TCHAR *rbuf, double value)
cbcaf8c8 555{
66d07089 556#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d
VK
557 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%f"), value);
558#else
8b86c5dc 559 _sntprintf(rbuf, MAX_RESULT_LENGTH, _T("%f"), value);
a23d8e0d 560#endif
cbcaf8c8
VK
561}
562
018fda4d 563inline void ret_int64(TCHAR *rbuf, INT64 value)
cbcaf8c8 564{
66d07089 565#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d 566 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%I64d"), value);
cbcaf8c8 567#else /* _WIN32 */
ccc34207 568 _sntprintf(rbuf, MAX_RESULT_LENGTH, INT64_FMT, value);
cbcaf8c8
VK
569#endif /* _WIN32 */
570}
571
018fda4d 572inline void ret_uint64(TCHAR *rbuf, QWORD value)
cbcaf8c8 573{
66d07089 574#if defined(_WIN32) && (_MSC_VER >= 1300)
a23d8e0d 575 _sntprintf_s(rbuf, MAX_RESULT_LENGTH, _TRUNCATE, _T("%I64u"), value);
cbcaf8c8 576#else /* _WIN32 */
ccc34207 577 _sntprintf(rbuf, MAX_RESULT_LENGTH, UINT64_FMT, value);
cbcaf8c8
VK
578#endif /* _WIN32 */
579}
580
359784de
VK
581/**
582 * API for subagents
583 */
0e0867c6 584bool LIBNXAGENT_EXPORTABLE AgentGetParameterArgA(const TCHAR *param, int index, char *arg, int maxSize, bool inBrackets = true);
585bool LIBNXAGENT_EXPORTABLE AgentGetParameterArgW(const TCHAR *param, int index, WCHAR *arg, int maxSize, bool inBrackets = true);
f3387429
VK
586#ifdef UNICODE
587#define AgentGetParameterArg AgentGetParameterArgW
588#else
589#define AgentGetParameterArg AgentGetParameterArgA
590#endif
591
359784de 592void LIBNXAGENT_EXPORTABLE AgentWriteLog(int logLevel, const TCHAR *format, ...)
6e383343 593#if !defined(UNICODE) && (defined(__GNUC__) || defined(__clang__))
640b6719
VK
594 __attribute__ ((format(printf, 2, 3)))
595#endif
596;
359784de
VK
597void LIBNXAGENT_EXPORTABLE AgentWriteLog2(int logLevel, const TCHAR *format, va_list args);
598void LIBNXAGENT_EXPORTABLE AgentWriteDebugLog(int level, const TCHAR *format, ...)
6e383343 599#if !defined(UNICODE) && (defined(__GNUC__) || defined(__clang__))
640b6719
VK
600 __attribute__ ((format(printf, 2, 3)))
601#endif
602;
359784de
VK
603void LIBNXAGENT_EXPORTABLE AgentWriteDebugLog2(int level, const TCHAR *format, va_list args);
604
605void LIBNXAGENT_EXPORTABLE AgentSendTrap(UINT32 dwEvent, const TCHAR *eventName, const char *pszFormat, ...);
606void LIBNXAGENT_EXPORTABLE AgentSendTrap2(UINT32 dwEvent, const TCHAR *eventName, int nCount, TCHAR **ppszArgList);
607
34b9a3e7 608bool LIBNXAGENT_EXPORTABLE AgentEnumerateSessions(EnumerationCallbackResult (* callback)(AbstractCommSession *, void *), void *data);
6fbaa926 609AbstractCommSession LIBNXAGENT_EXPORTABLE *AgentFindServerSession(UINT64 serverId);
359784de
VK
610
611bool LIBNXAGENT_EXPORTABLE AgentSendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset);
612
613bool LIBNXAGENT_EXPORTABLE AgentPushParameterData(const TCHAR *parameter, const TCHAR *value);
614bool LIBNXAGENT_EXPORTABLE AgentPushParameterDataInt32(const TCHAR *parameter, LONG value);
615bool LIBNXAGENT_EXPORTABLE AgentPushParameterDataUInt32(const TCHAR *parameter, UINT32 value);
616bool LIBNXAGENT_EXPORTABLE AgentPushParameterDataInt64(const TCHAR *parameter, INT64 value);
617bool LIBNXAGENT_EXPORTABLE AgentPushParameterDataUInt64(const TCHAR *parameter, QWORD value);
618bool LIBNXAGENT_EXPORTABLE AgentPushParameterDataDouble(const TCHAR *parameter, double value);
619
620CONDITION LIBNXAGENT_EXPORTABLE AgentGetShutdownCondition();
621bool LIBNXAGENT_EXPORTABLE AgentSleepAndCheckForShutdown(UINT32 sleepTime);
622
623Config LIBNXAGENT_EXPORTABLE *AgentOpenRegistry();
624void LIBNXAGENT_EXPORTABLE AgentCloseRegistry(bool modified);
625
626const TCHAR LIBNXAGENT_EXPORTABLE *AgentGetDataDirectory();
23d3d35d 627
cbcaf8c8 628#endif /* _nms_agent_h_ */