Added parameter System.Hostname
[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_NetIfList(char *pszParam, char *pArg, NETXMS_VALUES_LIST *pValue);
33 LONG H_ProcessCount(char *pszParam, char *pArg, char *pValue);
34 LONG H_ProcessInfo(char *pszParam, char *pArg, char *pValue);
35 LONG H_ProcessList(char *pszParam, char *pArg, NETXMS_VALUES_LIST *pValue);
36 LONG H_SysProcCount(char *pszParam, char *pArg, char *pValue);
37 LONG H_Uname(char *pszParam, char *pArg, char *pValue);
38 LONG H_Uptime(char *pszParam, char *pArg, char *pValue);
39
40
41 //
42 // Detect support for source packages
43 //
44
45 LONG H_SourcePkg(char *pszParam, char *pArg, char *pValue)
46 {
47 ret_int(pValue, 1);
48 return SYSINFO_RC_SUCCESS;
49 }
50
51
52 //
53 // Called by master agent at unload
54 //
55
56 static void UnloadHandler(void)
57 {
58 }
59
60
61 //
62 // Subagent information
63 //
64
65 static NETXMS_SUBAGENT_PARAM m_parameters[] =
66 {
67 { "Agent.SourcePackageSupport", H_SourcePkg, NULL, DCI_DT_INT, "" },
68 { "Disk.Free(*)", H_DiskInfo, (char *)DISK_FREE, DCI_DT_UINT64, "Free disk space on *" },
69 { "Disk.Total(*)", H_DiskInfo, (char *)DISK_TOTAL, DCI_DT_UINT64, "Total disk space on *" },
70 { "Disk.Used(*)", H_DiskInfo, (char *)DISK_USED, DCI_DT_UINT64, "Used disk space on *" },
71 { "Process.Count(*)", H_ProcessCount, NULL, DCI_DT_UINT, "" },
72 { "Process.KernelTime(*)", H_ProcessInfo, (char *)PROCINFO_KTIME, DCI_DT_UINT64, "" },
73 { "Process.PageFaults(*)", H_ProcessInfo, (char *)PROCINFO_PF, DCI_DT_UINT64, "" },
74 { "Process.UserTime(*)", H_ProcessInfo, (char *)PROCINFO_UTIME, DCI_DT_UINT64, "" },
75 { "System.Hostname", H_Hostname, NULL, DCI_DT_STRING, "Host name" },
76 { "System.ProcessCount", H_SysProcCount, NULL, DCI_DT_INT, "Total number of processes" },
77 { "System.Uname", H_Uname, NULL, DCI_DT_STRING, "System uname" },
78 { "System.Uptime", H_Uptime, NULL, DCI_DT_UINT, "System uptime" }
79 };
80 static NETXMS_SUBAGENT_ENUM m_enums[] =
81 {
82 { "Net.InterfaceList", H_NetIfList, NULL },
83 { "System.ProcessList", H_ProcessList, NULL }
84 };
85
86 static NETXMS_SUBAGENT_INFO m_info =
87 {
88 NETXMS_SUBAGENT_INFO_MAGIC,
89 _T("SUNOS"), NETXMS_VERSION_STRING,
90 UnloadHandler, NULL,
91 sizeof(m_parameters) / sizeof(NETXMS_SUBAGENT_PARAM),
92 m_parameters,
93 sizeof(m_enums) / sizeof(NETXMS_SUBAGENT_ENUM),
94 m_enums
95 };
96
97
98 //
99 // Entry point for NetXMS agent
100 //
101
102 extern "C" BOOL NxSubAgentInit(NETXMS_SUBAGENT_INFO **ppInfo, TCHAR *pszConfigFile)
103 {
104 *ppInfo = &m_info;
105 return TRUE;
106 }