Implemented parameter System.Memory.Physical.Free
authorVictor Kirhenshtein <victor@netxms.org>
Sat, 26 Feb 2005 22:37:24 +0000 (22:37 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 26 Feb 2005 22:37:24 +0000 (22:37 +0000)
src/agent/subagents/sunos/main.cpp
src/agent/subagents/sunos/sunos_subagent.h
src/agent/subagents/sunos/system.cpp

index 6978f00..b5b4625 100644 (file)
@@ -33,6 +33,7 @@ LONG H_DiskInfo(char *pszParam, char *pArg, char *pValue);
 LONG H_Hostname(char *pszParam, char *pArg, char *pValue);
 LONG H_KStat(char *pszParam, char *pArg, char *pValue);
 LONG H_LoadAvg(char *pszParam, char *pArg, char *pValue);
+LONG H_MemoryInfo(char *pszParam, char *pArg, char *pValue);
 LONG H_NetIfList(char *pszParam, char *pArg, NETXMS_VALUES_LIST *pValue);
 LONG H_NetIfAdminStatus(char *pszParam, char *pArg, char *pValue);
 LONG H_NetIfDescription(char *pszParam, char *pArg, char *pValue);
@@ -117,6 +118,12 @@ static NETXMS_SUBAGENT_PARAM m_parameters[] =
    { "System.CPU.Usage15(*)", H_CPUUsage, "C2", DCI_DT_FLOAT, "Average CPU {instance} utilization for last 15 minutes" },
    { "System.Hostname", H_Hostname, NULL, DCI_DT_STRING, "Host name" },
    { "System.KStat(*)", H_KStat, NULL, DCI_DT_STRING, "" },
+       { "System.Memory.Physical.Free", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_FREE, DCI_DT_UINT64, "Available physical memory" },
+       { "System.Memory.Physical.Total", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_TOTAL, DCI_DT_UINT64, "Total amount of physical memory" },
+       { "System.Memory.Physical.Used", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_FREE, DCI_DT_UINT64, "Used physical memory" },
+   { "System.Memory.Swap.Free", H_MemoryInfo, (char *)MEMINFO_SWAP_FREE, DCI_DT_UINT64, "Free swap space" },
+   { "System.Memory.Swap.Total", H_MemoryInfo, (char *)MEMINFO_SWAP_TOTAL, DCI_DT_UINT64, "Total amount of swap space" },
+   { "System.Memory.Swap.Used", H_MemoryInfo, (char *)MEMINFO_SWAP_USED, DCI_DT_UINT64, "Used swap space" },
    { "System.ProcessCount", H_SysProcCount, NULL, DCI_DT_INT, "Total number of processes" },
    { "System.Uname", H_Uname, NULL, DCI_DT_STRING, "System uname" },
    { "System.Uptime", H_Uptime, NULL, DCI_DT_UINT, "System uptime" }
index f09a792..67ce02e 100644 (file)
 #define DISK_TOTAL     2
 
 
+//
+// Request types for H_MemoryInfo
+//
+
+#define MEMINFO_PHYSICAL_FREE    1
+#define MEMINFO_PHYSICAL_TOTAL   2
+#define MEMINFO_PHYSICAL_USED    3
+#define MEMINFO_SWAP_FREE        4
+#define MEMINFO_SWAP_TOTAL       5
+#define MEMINFO_SWAP_USED        6
+#define MEMINFO_VIRTUAL_FREE     7
+#define MEMINFO_VIRTUAL_TOTAL    8
+#define MEMINFO_VIRTUAL_USED     9
+
+
 //
 // Types for Process.XXX() parameters
 //
index 0e83319..b14a72c 100644 (file)
@@ -193,7 +193,8 @@ LONG H_CPUCount(char *pszParam, char *pArg, char *pValue)
 // Handler for generic kstat parameter
 //
 
-LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName, char *pszStat, char *pValue)
+LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName,
+                    char *pszStat, char *pValue)
 {
        kstat_ctl_t *kc;
        kstat_t *kp;
@@ -248,3 +249,25 @@ LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName, char *pszSta
 
        return nRet;
 }
+
+
+//
+// Handler for System.CPU.Count
+//
+
+LONG H_MemoryInfo(char *pszParam, char *pArg, char *pValue)
+{
+       LONG nRet = SYSINFO_RC_SUCCESS;
+
+       switch((int)pArg)
+       {
+               case MEMINFO_PHYSICAL_TOTAL:
+                       ret_uint64(pValue, (QWORD)sysconf(_SC_PAGESIZE) * (QWORD)sysconf(_SC_PHYS_PAGES));
+                       break;
+               default:
+                       nRet = SYSINFO_RC_UNSUPPORTED;
+                       break;
+       }
+
+       return nRet;
+}