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