Added support for System.CPU.LoadAvg
[public/netxms.git] / src / agent / subagents / sunos / main.cpp
1 /*
2 ** NetXMS subagent for SunOS/Solaris
3 ** Copyright (C) 2004, 2005 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** $module: main.cpp
20 **
21 **/
22
23 #include "sunos_subagent.h"
24
25
26 //
27 // Hanlder functions
28 //
29
30 LONG H_DiskInfo(char *pszParam, char *pArg, char *pValue);
31 LONG H_Hostname(char *pszParam, char *pArg, char *pValue);
32 LONG H_LoadAvg(char *pszParam, char *pArg, char *pValue);
33 LONG H_NetIfList(char *pszParam, char *pArg, NETXMS_VALUES_LIST *pValue);
34 LONG H_ProcessCount(char *pszParam, char *pArg, char *pValue);
35 LONG H_ProcessInfo(char *pszParam, char *pArg, char *pValue);
36 LONG H_ProcessList(char *pszParam, char *pArg, NETXMS_VALUES_LIST *pValue);
37 LONG H_SysProcCount(char *pszParam, char *pArg, char *pValue);
38 LONG H_Uname(char *pszParam, char *pArg, char *pValue);
39 LONG H_Uptime(char *pszParam, char *pArg, char *pValue);
40
41
42 //
43 // Detect support for source packages
44 //
45
46 LONG H_SourcePkg(char *pszParam, char *pArg, char *pValue)
47 {
48 ret_int(pValue, 1);
49 return SYSINFO_RC_SUCCESS;
50 }
51
52
53 //
54 // Called by master agent at unload
55 //
56
57 static void UnloadHandler(void)
58 {
59 }
60
61
62 //
63 // Subagent information
64 //
65
66 static NETXMS_SUBAGENT_PARAM m_parameters[] =
67 {
68 { "Agent.SourcePackageSupport", H_SourcePkg, NULL, DCI_DT_INT, "" },
69 { "Disk.Free(*)", H_DiskInfo, (char *)DISK_FREE, DCI_DT_UINT64, "Free disk space on *" },
70 { "Disk.Total(*)", H_DiskInfo, (char *)DISK_TOTAL, DCI_DT_UINT64, "Total disk space on *" },
71 { "Disk.Used(*)", H_DiskInfo, (char *)DISK_USED, DCI_DT_UINT64, "Used disk space on *" },
72 { "Process.Count(*)", H_ProcessCount, NULL, DCI_DT_UINT, "" },
73 { "Process.KernelTime(*)", H_ProcessInfo, (char *)PROCINFO_KTIME, DCI_DT_UINT64, "" },
74 { "Process.PageFaults(*)", H_ProcessInfo, (char *)PROCINFO_PF, DCI_DT_UINT64, "" },
75 { "Process.UserTime(*)", H_ProcessInfo, (char *)PROCINFO_UTIME, DCI_DT_UINT64, "" },
76 { "System.CPU.LoadAvg", H_LoadAvg, (char *)0, DCI_DT_FLOAT, "Average CPU load for last minute" },
77 { "System.CPU.LoadAvg5", H_LoadAvg, (char *)1, DCI_DT_FLOAT, "Average CPU load for last 5 minutes" },
78 { "System.CPU.LoadAvg15", H_LoadAvg, (char *)2, DCI_DT_FLOAT, "Average CPU load for last 15 minutes" },
79 { "System.Hostname", H_Hostname, NULL, DCI_DT_STRING, "Host name" },
80 { "System.ProcessCount", H_SysProcCount, NULL, DCI_DT_INT, "Total number of processes" },
81 { "System.Uname", H_Uname, NULL, DCI_DT_STRING, "System uname" },
82 { "System.Uptime", H_Uptime, NULL, DCI_DT_UINT, "System uptime" }
83 };
84 static NETXMS_SUBAGENT_ENUM m_enums[] =
85 {
86 { "Net.InterfaceList", H_NetIfList, NULL },
87 { "System.ProcessList", H_ProcessList, NULL }
88 };
89
90 static NETXMS_SUBAGENT_INFO m_info =
91 {
92 NETXMS_SUBAGENT_INFO_MAGIC,
93 _T("SUNOS"), NETXMS_VERSION_STRING,
94 UnloadHandler, NULL,
95 sizeof(m_parameters) / sizeof(NETXMS_SUBAGENT_PARAM),
96 m_parameters,
97 sizeof(m_enums) / sizeof(NETXMS_SUBAGENT_ENUM),
98 m_enums
99 };
100
101
102 //
103 // Entry point for NetXMS agent
104 //
105
106 extern "C" BOOL NxSubAgentInit(NETXMS_SUBAGENT_INFO **ppInfo, TCHAR *pszConfigFile)
107 {
108 *ppInfo = &m_info;
109 return TRUE;
110 }