- quick and dirty Process.VMSize
authorAlex Kalimulin <alex@netxms.org>
Tue, 13 Sep 2011 21:44:21 +0000 (21:44 +0000)
committerAlex Kalimulin <alex@netxms.org>
Tue, 13 Sep 2011 21:44:21 +0000 (21:44 +0000)
src/agent/subagents/hpux/main.cpp
src/agent/subagents/hpux/system.cpp
src/agent/subagents/hpux/system.h

index 28ca0b2..9118d05 100644 (file)
@@ -126,6 +126,8 @@ static NETXMS_SUBAGENT_PARAM m_parameters[] =
 
        { "Process.Count(*)",             H_ProcessCount,    NULL,
                DCI_DT_UINT,    DCIDESC_PROCESS_COUNT },
+       { "Process.VMSize(*)",            H_ProcessDetails,  CAST_TO_POINTER(PROCINFO_VMSIZE, const char *),
+               DCI_DT_INT64,   DCIDESC_PROCESS_VMSIZE },
 
        { "System.ConnectedUsers",        H_ConnectedUsers,  NULL,
                DCI_DT_UINT,    DCIDESC_SYSTEM_CONNECTEDUSERS },
index 5e82c3a..6822d3d 100644 (file)
@@ -409,6 +409,51 @@ LONG H_ProcessCount(const char *pszParam, const char *pArg, char *pValue)
        return nRet;
 }
 
+//
+// Handler for Process.VMSize(*) parameter
+//
+
+LONG H_ProcessDetails(const char *pszParam, const char *pArg, char *pValue)
+{
+       INT64 value = 0;
+       struct pst_status *pst;
+       int i, nCount, nTotal;
+       char szArg[256];
+       LONG nRet = SYSINFO_RC_ERROR;
+
+       if (!AgentGetParameterArg(pszParam, 1, szArg, sizeof(szArg)))
+               return SYSINFO_RC_UNSUPPORTED;
+
+       pst = GetProcessList(&nCount);
+       if (pst != NULL)
+       {
+               for (i = 0, nTotal = 0; i < nCount; i++)
+               {
+                       if (!strcasecmp(pst[i].pst_ucomm, szArg))
+                       {
+                               value += 
+                                       pst[i].pst_vtsize + /* text */
+                                       + pst[i].pst_vdsize + /* data */
+                                       + pst[i].pst_vssize + /* stack */
+                                       + pst[i].pst_vshmsize + /* shared memory */
+                                       + pst[i].pst_vmmsize + /* mem-mapped files */
+                                       + pst[i].pst_vusize + /* U-Area & K-Stack */
+                                       + pst[i].pst_viosize; /* I/O dev mapping */ 
+                               break;
+                       }
+               }
+               free(pst);
+               if (i == nCount) // not found
+                       nRet = SYSINFO_RC_ERROR;
+               else
+               {
+                       ret_int64(pValue, value);
+                       nRet = SYSINFO_RC_SUCCESS;
+               }
+       }
+
+       return nRet;
+}
 
 //
 // Handler for System.ProcessList enum
index 822682a..83de467 100644 (file)
@@ -50,6 +50,7 @@ LONG H_Hostname(const char *, const char *, char *);
 LONG H_CpuLoad(const char *, const char *, char *);
 LONG H_CpuUsage(const char *, const char *, char *);
 LONG H_ProcessCount(const char *, const char *, char *);
+LONG H_ProcessDetails(const char *, const char *, char *);
 LONG H_SysProcessCount(const char *, const char *, char *);
 LONG H_MemoryInfo(const char *, const char *, char *);
 LONG H_SourcePkgSupport(const char *, const char *, char *);