imported svn:keywords properties
[public/netxms.git] / src / agent / subagents / linux / linux.cpp
1 /* $Id$ */
2
3 /*
4 ** NetXMS subagent for GNU/Linux
5 ** Copyright (C) 2004 Alex Kirhenshtein
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 **
21 ** File: linux.cpp
22 **
23 **/
24
25 #include <nms_common.h>
26 #include <nms_agent.h>
27
28 #include "net.h"
29 #include "system.h"
30 #include "disk.h"
31 #include "iostat.h"
32
33 //
34 // Initalization callback
35 //
36
37 static BOOL SubAgentInit(TCHAR *pszConfigFile)
38 {
39 StartCpuUsageCollector();
40 return TRUE;
41 }
42
43
44 //
45 // Shutdown callback
46 //
47
48 static void SubAgentShutdown(void)
49 {
50 ShutdownCpuUsageCollector();
51 }
52
53
54 //
55 // Externals
56 //
57
58 LONG H_DRBDDeviceList(char *pszParam, char *pszArg, NETXMS_VALUES_LIST *pValue);
59 LONG H_DRBDDeviceInfo(TCHAR *pszCmd, TCHAR *pArg, TCHAR *pValue);
60 LONG H_PhysicalDiskInfo(char *pszParam, char *pszArg, char *pValue);
61
62
63 //
64 // Subagent information
65 //
66
67 static NETXMS_SUBAGENT_PARAM m_parameters[] =
68 {
69 { "Disk.Avail(*)", H_DiskInfo, (char *)DISK_AVAIL,
70 DCI_DT_UINT64, DCIDESC_DISK_AVAIL },
71 { "Disk.AvailPerc(*)", H_DiskInfo, (char *)DISK_AVAIL_PERC,
72 DCI_DT_FLOAT, DCIDESC_DISK_AVAILPERC },
73 { "Disk.Free(*)", H_DiskInfo, (char *)DISK_FREE,
74 DCI_DT_UINT64, DCIDESC_DISK_FREE },
75 { "Disk.FreePerc(*)", H_DiskInfo, (char *)DISK_FREE_PERC,
76 DCI_DT_FLOAT, DCIDESC_DISK_FREEPERC },
77 { "Disk.Total(*)", H_DiskInfo, (char *)DISK_TOTAL,
78 DCI_DT_UINT64, DCIDESC_DISK_TOTAL },
79 { "Disk.Used(*)", H_DiskInfo, (char *)DISK_USED,
80 DCI_DT_UINT64, DCIDESC_DISK_USED },
81 { "Disk.UsedPerc(*)", H_DiskInfo, (char *)DISK_USED_PERC,
82 DCI_DT_FLOAT, DCIDESC_DISK_USEDPERC },
83
84 { "DRBD.ConnState(*)", H_DRBDDeviceInfo, "c",
85 DCI_DT_INT, "Connection state of DRBD device {instance}" },
86 { "DRBD.ConnStateText(*)", H_DRBDDeviceInfo, "C",
87 DCI_DT_STRING, "Connection state of DRBD device {instance} as text" },
88 { "DRBD.LowerDevice(*)", H_DRBDDeviceInfo, "L",
89 DCI_DT_STRING, "Underlaying device of DRBD device {instance}" },
90 { "DRBD.PeerState(*)", H_DRBDDeviceInfo, "p",
91 DCI_DT_INT, "State of DRBD peer device {instance}" },
92 { "DRBD.PeerStateText(*)", H_DRBDDeviceInfo, "P",
93 DCI_DT_STRING, "State of DRBD peer device {instance} as text" },
94 { "DRBD.State(*)", H_DRBDDeviceInfo, "s",
95 DCI_DT_INT, "State of DRBD device {instance}" },
96 { "DRBD.StateText(*)", H_DRBDDeviceInfo, "S",
97 DCI_DT_STRING, "State of DRBD device {instance} as text" },
98
99 { "Net.Interface.AdminStatus(*)", H_NetIfInfoFromIOCTL, (char *)IF_INFO_ADMIN_STATUS,
100 DCI_DT_INT, DCIDESC_NET_INTERFACE_ADMINSTATUS },
101 { "Net.Interface.BytesIn(*)", H_NetIfInfoFromProc, (char *)IF_INFO_BYTES_IN,
102 DCI_DT_UINT, DCIDESC_NET_INTERFACE_BYTESIN },
103 { "Net.Interface.BytesOut(*)", H_NetIfInfoFromProc, (char *)IF_INFO_BYTES_OUT,
104 DCI_DT_UINT, DCIDESC_NET_INTERFACE_BYTESOUT },
105 { "Net.Interface.Description(*)", H_NetIfInfoFromIOCTL, (char *)IF_INFO_DESCRIPTION,
106 DCI_DT_STRING, DCIDESC_NET_INTERFACE_DESCRIPTION },
107 { "Net.Interface.InErrors(*)", H_NetIfInfoFromProc, (char *)IF_INFO_IN_ERRORS,
108 DCI_DT_UINT, DCIDESC_NET_INTERFACE_INERRORS },
109 { "Net.Interface.Link(*)", H_NetIfInfoFromIOCTL, (char *)IF_INFO_OPER_STATUS,
110 DCI_DT_INT, DCIDESC_NET_INTERFACE_LINK },
111 { "Net.Interface.OutErrors(*)", H_NetIfInfoFromProc, (char *)IF_INFO_OUT_ERRORS,
112 DCI_DT_UINT, DCIDESC_NET_INTERFACE_OUTERRORS },
113 { "Net.Interface.PacketsIn(*)", H_NetIfInfoFromProc, (char *)IF_INFO_PACKETS_IN,
114 DCI_DT_UINT, DCIDESC_NET_INTERFACE_PACKETSIN },
115 { "Net.Interface.PacketsOut(*)", H_NetIfInfoFromProc, (char *)IF_INFO_PACKETS_OUT,
116 DCI_DT_UINT, DCIDESC_NET_INTERFACE_PACKETSOUT },
117 { "Net.IP.Forwarding", H_NetIpForwarding, (char *)4,
118 DCI_DT_INT, DCIDESC_NET_IP_FORWARDING },
119 { "Net.IP6.Forwarding", H_NetIpForwarding, (char *)6,
120 DCI_DT_INT, DCIDESC_NET_IP6_FORWARDING },
121
122 { "PhysicalDisk.SmartAttr(*)", H_PhysicalDiskInfo, "A",
123 DCI_DT_STRING, DCIDESC_PHYSICALDISK_SMARTATTR },
124 { "PhysicalDisk.SmartStatus(*)", H_PhysicalDiskInfo, "S",
125 DCI_DT_INT, DCIDESC_PHYSICALDISK_SMARTSTATUS },
126 { "PhysicalDisk.Temperature(*)", H_PhysicalDiskInfo, "T",
127 DCI_DT_INT, DCIDESC_PHYSICALDISK_TEMPERATURE },
128
129 { "Process.Count(*)", H_ProcessCount, "S",
130 DCI_DT_UINT, DCIDESC_PROCESS_COUNT },
131 { "Process.CountEx(*)", H_ProcessCount, "E",
132 DCI_DT_UINT, DCIDESC_PROCESS_COUNTEX },
133 { "System.ProcessCount", H_ProcessCount, "T",
134 DCI_DT_UINT, DCIDESC_SYSTEM_PROCESSCOUNT },
135
136 { "System.ConnectedUsers", H_ConnectedUsers, NULL,
137 DCI_DT_INT, DCIDESC_SYSTEM_CONNECTEDUSERS },
138
139 { "System.CPU.Count", H_CpuCount, NULL,
140 DCI_DT_UINT, DCIDESC_SYSTEM_CPU_COUNT },
141 { "System.CPU.LoadAvg", H_CpuLoad, (char *)INTERVAL_1MIN,
142 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_LOADAVG },
143 { "System.CPU.LoadAvg5", H_CpuLoad, (char *)INTERVAL_5MIN,
144 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_LOADAVG5 },
145 { "System.CPU.LoadAvg15", H_CpuLoad, (char *)INTERVAL_15MIN,
146 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_LOADAVG15 },
147
148 /**************************************************************/
149 #define P(q, w) (char *)&((struct CpuUsageParam){q, w})
150 /* usage */
151 { "System.CPU.Usage", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_OVERAL),
152 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE },
153 { "System.CPU.Usage5", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_OVERAL),
154 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5 },
155 { "System.CPU.Usage15", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_OVERAL),
156 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15 },
157 { "System.CPU.Usage(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_OVERAL),
158 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_EX },
159 { "System.CPU.Usage5(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_OVERAL),
160 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_EX },
161 { "System.CPU.Usage15(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_OVERAL),
162 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_EX },
163
164 /* user */
165 { "System.CPU.Usage.User", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_USER),
166 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_USER },
167 { "System.CPU.Usage5.User", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_USER),
168 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_USER },
169 { "System.CPU.Usage15.User", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_USER),
170 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_USER },
171 { "System.CPU.Usage.User(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_USER),
172 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_USER_EX },
173 { "System.CPU.Usage5.User(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_USER),
174 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_USER_EX },
175 { "System.CPU.Usage15.User(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_USER),
176 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_USER_EX },
177
178 /* nice */
179 { "System.CPU.Usage.Nice", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_NICE),
180 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_NICE },
181 { "System.CPU.Usage5.Nice", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_NICE),
182 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_NICE },
183 { "System.CPU.Usage15.Nice", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_NICE),
184 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_NICE },
185 { "System.CPU.Usage.Nice(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_NICE),
186 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_NICE_EX },
187 { "System.CPU.Usage5.Nice(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_NICE),
188 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_NICE_EX },
189 { "System.CPU.Usage15.Nice(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_NICE),
190 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_NICE_EX },
191
192 /* system */
193 { "System.CPU.Usage.System", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_SYSTEM),
194 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_SYSTEM },
195 { "System.CPU.Usage5.System", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_SYSTEM),
196 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM },
197 { "System.CPU.Usage15.System", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_SYSTEM),
198 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM },
199 { "System.CPU.Usage.System(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_SYSTEM),
200 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_SYSTEM_EX },
201 { "System.CPU.Usage5.System(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_SYSTEM),
202 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_SYSTEM_EX },
203 { "System.CPU.Usage15.System(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_SYSTEM),
204 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_SYSTEM_EX },
205
206 /* idle */
207 { "System.CPU.Usage.Idle", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_IDLE),
208 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_IDLE },
209 { "System.CPU.Usage5.Idle", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_IDLE),
210 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_IDLE },
211 { "System.CPU.Usage15.Idle", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_IDLE),
212 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_IDLE },
213 { "System.CPU.Usage.Idle(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_IDLE),
214 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_IDLE_EX },
215 { "System.CPU.Usage5.Idle5(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_IDLE),
216 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_IDLE_EX },
217 { "System.CPU.Usage15.Idle(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_IDLE),
218 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_IDLE_EX },
219
220 /* iowait */
221 { "System.CPU.Usage.IoWait", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_IOWAIT),
222 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_IOWAIT },
223 { "System.CPU.Usage5.IoWait", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_IOWAIT),
224 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT },
225 { "System.CPU.Usage15.IoWait", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_IOWAIT),
226 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT },
227 { "System.CPU.Usage.IoWait(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_IOWAIT),
228 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_IOWAIT_EX },
229 { "System.CPU.Usage5.IoWait(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_IOWAIT),
230 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_IOWAIT_EX },
231 { "System.CPU.Usage15.IoWait(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_IOWAIT),
232 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_IOWAIT_EX },
233
234 /* irq */
235 { "System.CPU.Usage.Irq", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_IRQ),
236 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_IRQ },
237 { "System.CPU.Usage5.Irq", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_IRQ),
238 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_IRQ },
239 { "System.CPU.Usage15.Irq", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_IRQ),
240 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_IRQ },
241 { "System.CPU.Usage.Irq(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_IRQ),
242 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_IRQ_EX },
243 { "System.CPU.Usage5.Irq(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_IRQ),
244 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_IRQ_EX },
245 { "System.CPU.Usage15.Irq(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_IRQ),
246 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_IRQ_EX },
247
248 /* softirq */
249 { "System.CPU.Usage.SoftIrq", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_SOFTIRQ),
250 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ },
251 { "System.CPU.Usage5.SoftIrq", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_SOFTIRQ),
252 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ },
253 { "System.CPU.Usage15.SoftIrq", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_SOFTIRQ),
254 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ },
255 { "System.CPU.Usage.SoftIrq(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_SOFTIRQ),
256 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_SOFTIRQ_EX },
257 { "System.CPU.Usage5.SoftIrq(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_SOFTIRQ),
258 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_SOFTIRQ_EX },
259 { "System.CPU.Usage15.SoftIrq(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_SOFTIRQ),
260 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_SOFTIRQ_EX },
261
262 /* steal */
263 { "System.CPU.Usage.Steal", H_CpuUsage, P(INTERVAL_1MIN, CPU_USAGE_STEAL),
264 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_STEAL },
265 { "System.CPU.Usage5.Steal", H_CpuUsage, P(INTERVAL_5MIN, CPU_USAGE_STEAL),
266 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_STEAL },
267 { "System.CPU.Usage15.Steal", H_CpuUsage, P(INTERVAL_15MIN, CPU_USAGE_STEAL),
268 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_STEAL },
269 { "System.CPU.Usage.Steal(*)", H_CpuUsageEx, P(INTERVAL_1MIN, CPU_USAGE_STEAL),
270 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE_STEAL_EX },
271 { "System.CPU.Usage5.Steal(*)", H_CpuUsageEx, P(INTERVAL_5MIN, CPU_USAGE_STEAL),
272 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE5_STEAL_EX },
273 { "System.CPU.Usage15.Steal(*)", H_CpuUsageEx, P(INTERVAL_15MIN, CPU_USAGE_STEAL),
274 DCI_DT_FLOAT, DCIDESC_SYSTEM_CPU_USAGE15_STEAL_EX },
275
276 #undef P
277
278 /**************************************************************/
279 { "System.Hostname", H_Hostname, NULL,
280 DCI_DT_STRING, DCIDESC_SYSTEM_HOSTNAME },
281 { "System.Memory.Physical.Free", H_MemoryInfo, (char *)PHYSICAL_FREE,
282 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_FREE },
283 { "System.Memory.Physical.Total", H_MemoryInfo, (char *)PHYSICAL_TOTAL,
284 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_TOTAL },
285 { "System.Memory.Physical.Used", H_MemoryInfo, (char *)PHYSICAL_USED,
286 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_PHYSICAL_USED },
287 { "System.Memory.Swap.Free", H_MemoryInfo, (char *)SWAP_FREE,
288 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_SWAP_FREE },
289 { "System.Memory.Swap.Total", H_MemoryInfo, (char *)SWAP_TOTAL,
290 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_SWAP_TOTAL },
291 { "System.Memory.Swap.Used", H_MemoryInfo, (char *)SWAP_USED,
292 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_SWAP_USED },
293 { "System.Memory.Virtual.Free", H_MemoryInfo, (char *)VIRTUAL_FREE,
294 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_VIRTUAL_FREE },
295 { "System.Memory.Virtual.Total", H_MemoryInfo, (char *)VIRTUAL_TOTAL,
296 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_VIRTUAL_TOTAL },
297 { "System.Memory.Virtual.Used", H_MemoryInfo, (char *)VIRTUAL_USED,
298 DCI_DT_UINT64, DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED },
299 { "System.Uname", H_Uname, NULL,
300 DCI_DT_STRING, DCIDESC_SYSTEM_UNAME },
301 { "System.Uptime", H_Uptime, NULL,
302 DCI_DT_UINT, DCIDESC_SYSTEM_UPTIME },
303
304 { "Agent.SourcePackageSupport", H_SourcePkgSupport,NULL,
305 DCI_DT_INT, DCIDESC_AGENT_SOURCEPACKAGESUPPORT },
306
307 /* iostat */
308 { "System.IO.TransferRate(*)", H_TransferRate, NULL,
309 DCI_DT_UINT64, "" },
310 { "System.IO.BlockReadRate(*)", H_BlockReadRate, NULL,
311 DCI_DT_UINT64, "" },
312 { "System.IO.BlockWriteRate(*)", H_BlockWriteRate, NULL,
313 DCI_DT_UINT64, "" },
314 { "System.IO.BytesReadRate(*)", H_BytesReadRate, NULL,
315 DCI_DT_UINT64, "" },
316 { "System.IO.BytesWriteRate(*)", H_BytesWriteRate, NULL,
317 DCI_DT_UINT64, "" },
318 { "System.IO.DiskQueue(*)", H_DiskQueue, NULL,
319 DCI_DT_UINT64, "" },
320 { "System.IO.DiskQueue", H_DiskInfo, NULL,
321 DCI_DT_UINT64, "" },
322 { "System.IO.DiskTime", H_DiskTime, NULL,
323 DCI_DT_UINT, "" },
324 };
325
326 static NETXMS_SUBAGENT_ENUM m_enums[] =
327 {
328 { "DRBD.DeviceList", H_DRBDDeviceList, NULL },
329 { "Net.ArpCache", H_NetArpCache, NULL },
330 { "Net.IP.RoutingTable", H_NetRoutingTable, NULL },
331 { "Net.InterfaceList", H_NetIfList, NULL },
332 { "System.ActiveUserSessions", H_ActiveUserSessions, NULL },
333 { "System.ProcessList", H_ProcessList, NULL },
334 };
335
336 static NETXMS_SUBAGENT_INFO m_info =
337 {
338 NETXMS_SUBAGENT_INFO_MAGIC,
339 "Linux",
340 NETXMS_VERSION_STRING,
341 SubAgentInit, /* initialization handler */
342 SubAgentShutdown, /* unload handler */
343 NULL, /* command handler */
344 sizeof(m_parameters) / sizeof(NETXMS_SUBAGENT_PARAM),
345 m_parameters,
346 sizeof(m_enums) / sizeof(NETXMS_SUBAGENT_ENUM),
347 m_enums,
348 0,
349 NULL
350 };
351
352 //
353 // Entry point for NetXMS agent
354 //
355
356 DECLARE_SUBAGENT_ENTRY_POINT(LINUX)
357 {
358 *ppInfo = &m_info;
359 return TRUE;
360 }
361
362
363 //
364 // Entry points for server
365 //
366
367 extern "C" BOOL __NxSubAgentGetIfList(NETXMS_VALUES_LIST *pValue)
368 {
369 return H_NetIfList("Net.InterfaceList", NULL, pValue) == SYSINFO_RC_SUCCESS;
370 }
371
372 extern "C" BOOL __NxSubAgentGetArpCache(NETXMS_VALUES_LIST *pValue)
373 {
374 return H_NetArpCache("Net.ArpCache", NULL, pValue) == SYSINFO_RC_SUCCESS;
375 }
376
377
378 ///////////////////////////////////////////////////////////////////////////////
379 /*
380
381 $Log: not supported by cvs2svn $
382 Revision 1.36 2007/10/31 08:14:33 victor
383 Added per-CPU usage statistics and System.CPU.Count parameter
384
385 Revision 1.35 2007/06/08 00:02:36 alk
386 DECLARE_SUBAGENT_INIT replaced with DECLARE_SUBAGENT_ENTRY_POINT
387
388 NETXMS_SUBAGENT_INFO initialization fixed (actions)
389
390 Revision 1.34 2007/06/07 22:07:11 alk
391 descriptions changed to defines
392
393 Revision 1.33 2007/04/25 07:44:09 victor
394 - Linux and HPUX subagents changed to new model
395 - ODBCQUERY subagent code cleaned
396
397 Revision 1.32 2007/04/24 12:04:10 alk
398 code reformat
399
400 Revision 1.31 2007/02/05 12:57:12 alk
401 *** empty log message ***
402
403 Revision 1.30 2007/01/15 00:16:06 victor
404 Implemented Process.CountEx for Linux
405
406 Revision 1.29 2006/10/30 17:25:10 victor
407 Implemented System.ConnectedUsers and System.ActiveUserSessions
408
409 Revision 1.28 2006/09/21 07:45:53 victor
410 Fixed problems with platform subagent loading by server
411
412 Revision 1.27 2006/09/21 07:24:08 victor
413 Server now can load platform subagents to obtain local ARP cache and interface list
414
415 Revision 1.26 2006/06/09 07:08:40 victor
416 Some minor fixes
417
418 Revision 1.25 2006/06/08 15:21:29 victor
419 Initial support for DRBD device monitoring
420
421 Revision 1.24 2006/03/02 21:08:20 alk
422 implemented:
423 System.CPU.Usage5
424 System.CPU.Usage15
425
426 Revision 1.23 2006/03/01 22:13:09 alk
427 added System.CPU.Usage [broken]
428
429 Revision 1.22 2005/09/15 21:47:02 victor
430 Added macro DECLARE_SUBAGENT_INIT to simplify initialization function declaration
431
432 Revision 1.21 2005/09/15 21:24:54 victor
433 Minor changes
434
435 Revision 1.20 2005/09/15 21:22:58 victor
436 Added possibility to build statically linked agents (with platform subagent linked in)
437 For now, agent has to be linked manually. I'll fix it later.
438
439 Revision 1.19 2005/08/22 00:11:46 alk
440 Net.IP.RoutingTable added
441
442 Revision 1.18 2005/08/19 15:23:50 victor
443 Added new parameters
444
445 Revision 1.17 2005/06/11 16:28:24 victor
446 Implemented all Net.Interface.* parameters except Net.Interface.Speed
447
448 Revision 1.16 2005/06/09 12:15:43 victor
449 Added support for Net.Interface.AdminStatus and Net.Interface.Link parameters
450
451 Revision 1.15 2005/02/24 17:38:49 victor
452 Added HDD monitring via SMART on Linux
453
454 Revision 1.14 2005/02/21 20:16:05 victor
455 Fixes in parameter data types and descriptions
456
457 Revision 1.13 2005/01/24 19:46:50 alk
458 SourcePackageSupport; return type/comment addded
459
460 Revision 1.12 2005/01/24 19:40:31 alk
461 return type/comments added for command list
462
463 System.ProcessCount/Process.Count(*) misunderstanding resolved
464
465 Revision 1.11 2005/01/17 23:31:01 alk
466 Agent.SourcePackageSupport added
467
468 Revision 1.10 2004/12/29 19:42:44 victor
469 Linux compatibility fixes
470
471 Revision 1.9 2004/10/22 22:08:34 alk
472 source restructured;
473 implemented:
474 Net.IP.Forwarding
475 Net.IP6.Forwarding
476 Process.Count(*)
477 Net.ArpCache
478 Net.InterfaceList (if-type not implemented yet)
479 System.ProcessList
480
481 Revision 1.8 2004/10/16 06:32:04 victor
482 Parameter name System.CPU.Procload changed to System.CPU.LoadAvg
483
484 Revision 1.7 2004/10/06 13:23:32 victor
485 Necessary changes to build everything on Linux
486
487 Revision 1.6 2004/08/26 23:51:26 alk
488 cosmetic changes
489
490 Revision 1.5 2004/08/18 00:12:56 alk
491 + System.CPU.Procload* added, SINGLE processor only.
492
493 Revision 1.4 2004/08/17 23:19:20 alk
494 + Disk.* implemented
495
496 Revision 1.3 2004/08/17 15:17:32 alk
497 + linux agent: system.uptime, system.uname, system.hostname
498 ! skeleton: amount of _PARM & _ENUM filled with sizeof()
499
500 Revision 1.1 2004/08/17 10:24:18 alk
501 + subagent selection based on "uname -s"
502
503
504 */