From 4bffa314d22ded5195026a7241ee558cbd6239a9 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 17 Apr 2009 18:31:35 -0700 Subject: [PATCH 1/4] (SIGAR-131) switch to pst_fileinfo2 on all HPUX flavors --- src/os/hpux/hpux_sigar.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index ad7274a0..da4cbec1 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -16,10 +16,6 @@ * USA. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "sigar.h" #include "sigar_private.h" #include "sigar_util.h" @@ -419,12 +415,8 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_fd_t *procfd) { struct pst_status status; - int idx, i, n; -#ifdef HAVE_STRUCT_PST_FILEINFO2 + int idx=0, n; struct pst_fileinfo2 psf[16]; -#else - struct pst_fileinfo psf[16]; -#endif procfd->total = 0; @@ -433,28 +425,13 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid, } /* HPUX 11.31 removed the deprecated pstat_getfile call */ -#ifdef HAVE_STRUCT_PST_FILEINFO2 - idx = status.pst_idx; - while ((n = pstat_getfile2(psf, sizeof(psf[0]), sizeof(psf)/sizeof(psf[0]), idx, pid)) > 0) { procfd->total += n; - idx = psf[n-1].psf_fd; + idx = psf[n-1].psf_fd + 1; } -#else - /* man pstat_getfile for index splaination */ - idx = (status.pst_idx << 16) | (0 & 0xffff); - - while ((n = pstat_getfile(psf, sizeof(psf[0]), - sizeof(psf)/sizeof(psf[0]), - idx)) > 0) - { - procfd->total += n; - idx = psf[n-1].psf_idx + 1; - } -#endif if (n == -1) { return errno; From 4d0046fa251915dac5594a4a1442aad78c6c83a3 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 18 Apr 2009 08:57:41 -0700 Subject: [PATCH 2/4] (SIGAR-130) Use pstat_getcommandline on HP-UX 11iv2+ --- src/os/hpux/hpux_sigar.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index da4cbec1..081356d6 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -380,15 +380,18 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, return SIGAR_OK; } -/* - * XXX: pst_cmd is only 64 chars of the command args. - * according to HP forums there isn't a way to get them - * all if > 64 - */ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_args_t *procargs) { char *args, *arg; +#ifdef PSTAT_GETCOMMANDLINE + char buf[1024]; /* kernel limit */ + + if (pstat_getcommandline(buf, sizeof(buf), sizeof(buf[0]), pid) == -1) { + return errno; + } + args = buf; +#else struct pst_status status; if (pstat_getproc(&status, sizeof(status), 0, pid) == -1) { @@ -396,6 +399,7 @@ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid, } args = status.pst_cmd; +#endif while (*args && (arg = sigar_getword(&args, ' '))) { SIGAR_PROC_ARGS_GROW(procargs); From de915ae0d13c2e1da26f722f7e95a0b98e2f9656 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 25 Apr 2009 07:46:40 -0700 Subject: [PATCH 3/4] (SIGAR-130) Use pstat(PSTAT_GETCOMMANDLINE,...) on HP-UX < 11iv2 --- src/os/hpux/hpux_sigar.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 081356d6..26fb314a 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -387,9 +387,19 @@ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid, #ifdef PSTAT_GETCOMMANDLINE char buf[1024]; /* kernel limit */ +# ifdef pstat_getcommandline /* 11i v2 + */ if (pstat_getcommandline(buf, sizeof(buf), sizeof(buf[0]), pid) == -1) { return errno; } +# else + union pstun pu; + + pu.pst_command = buf; + if (pstat(PSTAT_GETCOMMANDLINE, pu, sizeof(buf), sizeof(buf[0]), pid) == -1) { + return errno; + } +# endif /* pstat_getcommandline */ + args = buf; #else struct pst_status status; From 80016c67c712711ba13b94d599c94358e2a4b7cf Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 8 Jul 2009 18:02:34 -0700 Subject: [PATCH 4/4] cherry-picked hpux fixes from master --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index a57a31a6..6465efb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,14 @@ * 1.6.3 release +2009-07-08 Doug MacEachern + + * (SIGAR-130) Use pstat(PSTAT_GETCOMMANDLINE,...) on HP-UX < 11iv2 + + * (SIGAR-130) Use pstat_getcommandline on HP-UX 11iv2+ + + * (SIGAR-131) switch to pst_fileinfo2 on all HPUX flavors + 2009-07-08 Jon Travis * (SIGAR-150) Wrapper class to synchronize Sigar method invocation