Solaris subagent: implemented System.Memory.Physical.* parameters
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 27 Feb 2005 11:53:55 +0000 (11:53 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 27 Feb 2005 11:53:55 +0000 (11:53 +0000)
ChangeLog
src/agent/subagents/sunos/main.cpp
src/agent/subagents/sunos/process.cpp
src/agent/subagents/sunos/sunos_subagent.h
src/agent/subagents/sunos/system.cpp

index 30fd24c..30ada4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,8 +7,8 @@
 - Added support of HDD temperature monitoring under Windows and Linux
 - Added PhysicalDisk.Model, PhysicalDisk.SerialNumber and
   PhysicalDisk.Firmware parameters under Windows
 - Added support of HDD temperature monitoring under Windows and Linux
 - Added PhysicalDisk.Model, PhysicalDisk.SerialNumber and
   PhysicalDisk.Firmware parameters under Windows
-- Added parameters System.CPU.Count, System.CPU.Usage* and System.KStat(*)
-  to Solaris subagent
+- Added parameters System.CPU.Count, System.CPU.Usage*, System.KStat(*)
+  and System.Memory.Physical.* to Solaris subagent
 
 
 *
 
 
 *
index b5b4625..d04c870 100644 (file)
@@ -120,7 +120,7 @@ static NETXMS_SUBAGENT_PARAM m_parameters[] =
    { "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.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.Physical.Used", H_MemoryInfo, (char *)MEMINFO_PHYSICAL_USED, 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.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" },
index 4f7afad..87045c0 100644 (file)
@@ -196,7 +196,7 @@ LONG H_ProcessCount(char *pszParam, char *pArg, char *pValue)
 
 LONG H_SysProcCount(char *pszParam, char *pArg, char *pValue)
 {
 
 LONG H_SysProcCount(char *pszParam, char *pArg, char *pValue)
 {
-       return ReadKStatValue("unix", 0, "system_misc", "nproc", pValue);
+       return ReadKStatValue("unix", 0, "system_misc", "nproc", pValue, NULL);
 }
 
 
 }
 
 
index 67ce02e..80bc474 100644 (file)
@@ -85,7 +85,8 @@ typedef struct t_ProcEnt
 //
 
 int mac_addr_dlpi(char *pszIfName, u_char *pMacAddr);
 //
 
 int mac_addr_dlpi(char *pszIfName, u_char *pMacAddr);
-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_named_t *pRawValue);
 
 THREAD_RESULT THREAD_CALL CPUStatCollector(void *pArg);
 
 
 THREAD_RESULT THREAD_CALL CPUStatCollector(void *pArg);
 
index b14a72c..2638392 100644 (file)
@@ -175,7 +175,7 @@ LONG H_KStat(char *pszParam, char *pArg, char *pValue)
                nInstance = 0;
        }
 
                nInstance = 0;
        }
 
-       return ReadKStatValue(szModule, nInstance, szName, szStat, pValue);
+       return ReadKStatValue(szModule, nInstance, szName, szStat, pValue, NULL);
 }
 
 
 }
 
 
@@ -185,7 +185,7 @@ LONG H_KStat(char *pszParam, char *pArg, char *pValue)
 
 LONG H_CPUCount(char *pszParam, char *pArg, char *pValue)
 {
 
 LONG H_CPUCount(char *pszParam, char *pArg, char *pValue)
 {
-       return ReadKStatValue("unix", 0, "system_misc", "ncpus", pValue);
+       return ReadKStatValue("unix", 0, "system_misc", "ncpus", pValue, NULL);
 }
 
 
 }
 
 
@@ -194,7 +194,7 @@ LONG H_CPUCount(char *pszParam, char *pArg, char *pValue)
 //
 
 LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName,
 //
 
 LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName,
-                    char *pszStat, char *pValue)
+                    char *pszStat, char *pValue, kstat_named_t *pRawValue)
 {
        kstat_ctl_t *kc;
        kstat_t *kp;
 {
        kstat_ctl_t *kc;
        kstat_t *kp;
@@ -213,33 +213,42 @@ LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName,
                                kn = (kstat_named_t *)kstat_data_lookup(kp, pszStat);
                                if (kn != NULL)
                                {
                                kn = (kstat_named_t *)kstat_data_lookup(kp, pszStat);
                                if (kn != NULL)
                                {
-               switch(kn->data_type)
-               {
-                  case KSTAT_DATA_CHAR:
-                     ret_string(pValue, kn->value.c);
-                     break;
-                  case KSTAT_DATA_INT32:
-                     ret_int(pValue, kn->value.i32);
-                     break;
-                  case KSTAT_DATA_UINT32:
-                     ret_uint(pValue, kn->value.ui32);
-                     break;
-                  case KSTAT_DATA_INT64:
-                     ret_int64(pValue, kn->value.i64);
-                     break;
-                  case KSTAT_DATA_UINT64:
-                     ret_uint64(pValue, kn->value.ui64);
-                     break;
-                  case KSTAT_DATA_FLOAT:
-                     ret_double(pValue, kn->value.f);
-                     break;
-                  case KSTAT_DATA_DOUBLE:
-                     ret_double(pValue, kn->value.d);
-                     break;
-                  default:
-                     ret_int(pValue, 0);
-                                                       break;
+                                       if (pValue != NULL)
+                                       {
+                      switch(kn->data_type)
+                   {
+                   case KSTAT_DATA_CHAR:
+                           ret_string(pValue, kn->value.c);
+                        break;
+                          case KSTAT_DATA_INT32:
+                          ret_int(pValue, kn->value.i32);
+                       break;
+                         case KSTAT_DATA_UINT32:
+                         ret_uint(pValue, kn->value.ui32);
+                      break;
+                        case KSTAT_DATA_INT64:
+                        ret_int64(pValue, kn->value.i64);
+                             break;
+                       case KSTAT_DATA_UINT64:
+                        ret_uint64(pValue, kn->value.ui64);
+                      break;
+                        case KSTAT_DATA_FLOAT:
+                        ret_double(pValue, kn->value.f);
+                             break;
+                       case KSTAT_DATA_DOUBLE:
+                       ret_double(pValue, kn->value.d);
+                       break;
+                                                       default:
+                       ret_int(pValue, 0);
+                                                               break;
+                                               }
                }
                }
+
+                                       if (pRawValue != NULL)
+                                       {
+                                               memcpy(pRawValue, kn, sizeof(kstat_named_t));
+                                       }
+
                                        nRet = SYSINFO_RC_SUCCESS;
                                }
                        }
                                        nRet = SYSINFO_RC_SUCCESS;
                                }
                        }
@@ -258,11 +267,29 @@ LONG ReadKStatValue(char *pszModule, LONG nInstance, char *pszName,
 LONG H_MemoryInfo(char *pszParam, char *pArg, char *pValue)
 {
        LONG nRet = SYSINFO_RC_SUCCESS;
 LONG H_MemoryInfo(char *pszParam, char *pArg, char *pValue)
 {
        LONG nRet = SYSINFO_RC_SUCCESS;
+       kstat_named_t kn;
+       QWORD qwPageSize;
+
+       qwPageSize = sysconf(_SC_PAGESIZE);
 
        switch((int)pArg)
        {
                case MEMINFO_PHYSICAL_TOTAL:
 
        switch((int)pArg)
        {
                case MEMINFO_PHYSICAL_TOTAL:
-                       ret_uint64(pValue, (QWORD)sysconf(_SC_PAGESIZE) * (QWORD)sysconf(_SC_PHYS_PAGES));
+                       ret_uint64(pValue, (QWORD)sysconf(_SC_PHYS_PAGES) * qwPageSize);
+                       break;
+               case MEMINFO_PHYSICAL_FREE:
+                       nRet = ReadKStatValue("unix", 0, "system_pages", "freemem", NULL, &kn);
+                       if (nRet == SYSINFO_RC_SUCCESS)
+                       {
+                               ret_uint64(pValue, (QWORD)kn.value.ul * qwPageSize);
+                       }
+                       break;
+               case MEMINFO_PHYSICAL_USED:
+                       nRet = ReadKStatValue("unix", 0, "system_pages", "freemem", NULL, &kn);
+                       if (nRet == SYSINFO_RC_SUCCESS)
+                       {
+                               ret_uint64(pValue, (QWORD)(sysconf(_SC_PHYS_PAGES) - kn.value.ul) * qwPageSize);
+                       }
                        break;
                default:
                        nRet = SYSINFO_RC_UNSUPPORTED;
                        break;
                default:
                        nRet = SYSINFO_RC_UNSUPPORTED;