* "C" program difference on V5.X vs V4.x
@ 2002-04-04 4:34 redhatcat
0 siblings, 0 replies; only message in thread
From: redhatcat @ 2002-04-04 4:34 UTC (permalink / raw)
To: tru64-unix-managers
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------=_NextPart_000_00A3_01C1DB68.0A56B1A0", Size: 12854 bytes --]
This is a multi-part message in MIME format.
------=_NextPart_000_00A3_01C1DB68.0A56B1A0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_00A4_01C1DB68.0A56B1A0"
------=_NextPart_001_00A4_01C1DB68.0A56B1A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
----- I am submitting this for someone who did not know about this =
list (they are joining )---TIA---rhc
Subject: C question
The problem is this: within the Oracle space, on Tru64 we check for =
processes using the ps command.=20
Sometimes, it misses processes, tells us they are not there when in fact =
they are.=20
We have coded around this by trying it more than once with a delay if we =
get a missing process.
So we were looking for other ways to get process information, and we =
wound up looking at the /proc filesystem.
So I cobbled together a small program from pieces I found here and =
there. It prints the pid, and two fields from the procfs.h prpsinfo =
structure, pr_fname and pr_psargs.
V4.x ---> This compiles and runs fine on a v4 machine.
V5.x -->it compiles and runs on a v5 machine, but does not display all =
the information expected in the psargs field
IE on a v4 machine the output looks like:
# ./getcmdline/getcmdline98
1 init /sbin/init -a
9 kloadsrv /sbin/kloadsrv
27 vold /sbin/vold
70 update /sbin/update
195 syslogd /usr/sbin/syslogd
199 binlogd /usr/sbin/binlogd
384 portmap /usr/sbin/portmap
389 mountd /usr/sbin/mountd -i
391 nfsd /usr/sbin/nfsd -t8 -u8
393 nfsiod /usr/sbin/nfsiod 7
396 rpc.statd /usr/sbin/rpc.statd
398 rpc.lockd /usr/sbin/rpc.lockd
480 xntpd /usr/sbin/xntpd -g -c /etc/ntp.conf
485 sendmail sendmail: accepting connections on
5309 emacs /freeware/bin/emacs -g 80x32 -fg gold -bg firebrick -cr =
lightblue getcmdline.c
6160 ksh -ksh
6462 doit_on.exp expect -- bin/tnet decedidb_odr_dr
6558 telnetd telnetd
9470 more more /var/upgrade_guide.txt
13467 sh sh -c DB_RPT_HOME=3D/usr/users/db_rpts;export =
DB_RPT_HOME;/usr/users/db_rpt/bin
13484 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on ne_o_prod =
/usr/users/db_rpt/doitcmds
18276 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on _prod =
/usr/users/db_rpt/doitcmd
22870 getcmdline98 /usr/users/tomas/getcmdline/getcmdline98
On a v5 machine the output looks like:
xxddbs_expect_doit : ./getcmdline98
524288 kernel idle
524289 init /sbin/init
524290 kproc_creator_da
524291 icssvr_nomem_dae
524292 icssvr_throttle_
524293 icssvr_daemon_fr
524294 icssvr_daemon_fr
524295 icssvr_nanny
524296 icscli_throttle_
524297 icssvr_daemon_fr
524298 icssvr_daemon_fr
524299 icssvr_daemon_fr
524300 icssvr_daemon_fr
524301 icssvr_daemon_fr
524302 CFS daemon
524303 icssvr_daemon_pe
524304 icssvr_daemon_pe
524305 icssvr_daemon_pe
524307 kloadsrv /sbin/kloadsrv
524309 hotswapd /sbin/hotswapd
524387 esmd /usr/sbin/esmd
524398 update /sbin/update
524514 evmd /usr/sbin/evmd
524587 evmlogger /usr/sbin/evmlogger
524588 evmchmgr /usr/sbin/evmchmgr
524754 niffd /usr/sbin/niffd
524788 syslogd /usr/sbin/syslogd
524792 binlogd /usr/sbin/binlogd
529620 icssvr_daemon_pe
529621 icssvr_daemon_pe
529622 icssvr_daemon_pe
529623 icssvr_daemon_fr
529625 icssvr_daemon_pe
529627 icssvr_daemon_fr
529628 icssvr_daemon_fr
529629 icssvr_daemon_fr
529630 icssvr_daemon_fr
529643 icssvr_daemon_pe
620931 telnetd telnetd
620932 csh -csh
620952 csh -csh
621291 getcmdline98 ./getcmdline98
562469 saposcol /usr/sap/XXD/SYS/exe/run/saposcol
563789 icssvr_daemon_pe
563844 tnslsnr /oracle/XXD/817_64/bin/tnslsnr
563850 oracle ora_pmon_XXD
563852 oracle ora_dbw0_XXD
563854 oracle ora_lgwr_XXD
563856 oracle ora_ckpt_XXD
563858 oracle ora_smon_XXD
563860 oracle ora_reco_XXD
563862 oracle ora_arc0_XXD
563917 perl5.6.0 perl
563921 perl5.6.0 perl
563925 perl5.6.0 perl
564339 sapstart /usr/sap/XXD/SYS/exe/run/sapstart
564348 msg_server ms.sapXXD_DVEBMGS01
564349 disp+work dw.sapXXD_DVEBMGS01
564350 rslgcoll co.sapXXD_DVEBMGS01
564371 disp+work dw.sapXXD_DVEBMGS01
564372 disp+work dw.sapXXD_DVEBMGS01
564373 disp+work dw.sapXXD_DVEBMGS01
564382 oracle oracleXXD
564384 oracle oracleXXD
564386 oracle oracleXXD
564388 oracle oracleXXD
C Code: sent as attachment =20
------=_NextPart_001_00A4_01C1DB68.0A56B1A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2712.300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>
<P><FONT face=3DArial> ----- I am submitting this for someone who =
did not=20
know about this list (they are joining )---TIA---rhc</FONT></P>
<P><FONT face=3DArial></FONT> </P>
<P>Subject: C question</P>
<P>The problem is this: within the Oracle space, on Tru64 we check =
for =20
processes using the ps command. </P>
<P>Sometimes, it misses processes, tells us they are not there when in =
fact they=20
are. </P>
<P>We have coded around this by trying it more than once with a delay if =
we get=20
a missing process.</P>
<P>So we were looking for other ways to get process information, and we =
wound up=20
looking at the /proc filesystem.</P>
<P>So I cobbled together a small program from pieces I found here and =
there. It=20
prints the pid, and two fields from the procfs.h prpsinfo structure, =
pr_fname=20
and pr_psargs.</P>
<P>V4.x ---> This compiles and runs fine on a =
v4=20
machine.</P>
<P>V5.x -->it compiles and runs on a v5 machine, but does not display =
all the=20
information expected in the psargs field</P>
<P><FONT face=3DArial></FONT> </P>
<P><FONT face=3DArial></FONT> </P>
<P>IE on a v4 machine the output looks like:</P>
<P> # ./getcmdline/getcmdline98</P>
<P>1 init /sbin/init -a</P>
<P>9 kloadsrv /sbin/kloadsrv</P>
<P>27 vold /sbin/vold</P>
<P>70 update /sbin/update</P>
<P>195 syslogd /usr/sbin/syslogd</P>
<P>199 binlogd /usr/sbin/binlogd</P>
<P>384 portmap /usr/sbin/portmap</P>
<P>389 mountd /usr/sbin/mountd -i</P>
<P>391 nfsd /usr/sbin/nfsd -t8 -u8</P>
<P>393 nfsiod /usr/sbin/nfsiod 7</P>
<P>396 rpc.statd /usr/sbin/rpc.statd</P>
<P>398 rpc.lockd /usr/sbin/rpc.lockd</P>
<P>480 xntpd /usr/sbin/xntpd -g -c /etc/ntp.conf</P>
<P>485 sendmail sendmail: accepting connections on</P>
<P>5309 emacs /freeware/bin/emacs -g 80x32 -fg gold -bg firebrick -cr =
lightblue=20
getcmdline.c</P>
<P>6160 ksh -ksh</P>
<P>6462 doit_on.exp expect -- bin/tnet decedidb_odr_dr</P>
<P>6558 telnetd telnetd</P>
<P>9470 more more /var/upgrade_guide.txt</P>
<P>13467 sh sh -c DB_RPT_HOME=3D/usr/users/db_rpts;export=20
DB_RPT_HOME;/usr/users/db_rpt/bin</P>
<P>13484 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on ne_o_prod=20
/usr/users/db_rpt/doitcmds</P>
<P>18276 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on _prod=20
/usr/users/db_rpt/doitcmd</P>
<P>22870 getcmdline98 /usr/users/tomas/getcmdline/getcmdline98</P>
<P><FONT face=3DArial></FONT> </P>
<P><FONT face=3DArial></FONT> </P>
<P><FONT face=3DArial></FONT> </P>
<P>On a v5 machine the output looks like:</P>
<P>xxddbs_expect_doit : ./getcmdline98</P>
<P>524288 kernel idle</P>
<P>524289 init /sbin/init</P>
<P>524290 kproc_creator_da</P>
<P>524291 icssvr_nomem_dae</P>
<P>524292 icssvr_throttle_</P>
<P>524293 icssvr_daemon_fr</P>
<P>524294 icssvr_daemon_fr</P>
<P>524295 icssvr_nanny</P>
<P>524296 icscli_throttle_</P>
<P>524297 icssvr_daemon_fr</P>
<P>524298 icssvr_daemon_fr</P>
<P>524299 icssvr_daemon_fr</P>
<P>524300 icssvr_daemon_fr</P>
<P>524301 icssvr_daemon_fr</P>
<P>524302 CFS daemon</P>
<P>524303 icssvr_daemon_pe</P>
<P>524304 icssvr_daemon_pe</P>
<P>524305 icssvr_daemon_pe</P>
<P>524307 kloadsrv /sbin/kloadsrv</P>
<P>524309 hotswapd /sbin/hotswapd</P>
<P>524387 esmd /usr/sbin/esmd</P>
<P>524398 update /sbin/update</P>
<P>524514 evmd /usr/sbin/evmd</P>
<P>524587 evmlogger /usr/sbin/evmlogger</P>
<P>524588 evmchmgr /usr/sbin/evmchmgr</P>
<P>524754 niffd /usr/sbin/niffd</P>
<P>524788 syslogd /usr/sbin/syslogd</P>
<P>524792 binlogd /usr/sbin/binlogd</P>
<P>529620 icssvr_daemon_pe</P>
<P>529621 icssvr_daemon_pe</P>
<P>529622 icssvr_daemon_pe</P>
<P>529623 icssvr_daemon_fr</P>
<P>529625 icssvr_daemon_pe</P>
<P>529627 icssvr_daemon_fr</P>
<P>529628 icssvr_daemon_fr</P>
<P>529629 icssvr_daemon_fr</P>
<P>529630 icssvr_daemon_fr</P>
<P>529643 icssvr_daemon_pe</P>
<P>620931 telnetd telnetd</P>
<P>620932 csh -csh</P>
<P>620952 csh -csh</P>
<P>621291 getcmdline98 ./getcmdline98</P>
<P>562469 saposcol /usr/sap/XXD/SYS/exe/run/saposcol</P>
<P>563789 icssvr_daemon_pe</P>
<P>563844 tnslsnr /oracle/XXD/817_64/bin/tnslsnr</P>
<P>563850 oracle ora_pmon_XXD</P>
<P>563852 oracle ora_dbw0_XXD</P>
<P>563854 oracle ora_lgwr_XXD</P>
<P>563856 oracle ora_ckpt_XXD</P>
<P>563858 oracle ora_smon_XXD</P>
<P>563860 oracle ora_reco_XXD</P>
<P>563862 oracle ora_arc0_XXD</P>
<P>563917 perl5.6.0 perl</P>
<P>563921 perl5.6.0 perl</P>
<P>563925 perl5.6.0 perl</P>
<P>564339 sapstart /usr/sap/XXD/SYS/exe/run/sapstart</P>
<P>564348 msg_server ms.sapXXD_DVEBMGS01</P>
<P>564349 disp+work dw.sapXXD_DVEBMGS01</P>
<P>564350 rslgcoll co.sapXXD_DVEBMGS01</P>
<P>564371 disp+work dw.sapXXD_DVEBMGS01</P>
<P>564372 disp+work dw.sapXXD_DVEBMGS01</P>
<P>564373 disp+work dw.sapXXD_DVEBMGS01</P>
<P>564382 oracle oracleXXD</P>
<P>564384 oracle oracleXXD</P>
<P>564386 oracle oracleXXD</P>
<P>564388 oracle oracleXXD</P>
<P><FONT face=3DArial></FONT> </P>
<P>C Code: sent as attachment =
</P>
<P><FONT face=3DArial></FONT> </P>
<P><FONT face=3DArial></FONT></FONT> </P></DIV></BODY></HTML>
------=_NextPart_001_00A4_01C1DB68.0A56B1A0--
------=_NextPart_000_00A3_01C1DB68.0A56B1A0
Content-Type: text/plain;
name="cprogram.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="cprogram.txt"
#define PRG_MODULE "$Rcsfile$"
#define PRG_VERSION " $Revision$ "
/*
** Package :
** General Description
**
**
** Modification History
**
** Rev: Date Initials Reason
** ---- ---- -------- ------
**$Log$
**
**
** Compile/Build Instructions
**
**
**
*/
/*
** PREPROCESSOR
*/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdarg.h>
#include <sys/resource.h>
#include <unistd.h>
#include <sys/proc.h> /* needed for process state constants */ #include =
<sys/table.h> /* needed for process state constants */ #include =
<sys/statvfs.h> #include <sys/types.h> #include <sys/procfs.h> #include =
<sys/signal.h> #include <sys/fault.h> #include <sys/syscall.h> #include =
<values.h>
/* As of version 5.005_something it seems sv_undef has been supplanted =
by PL_sv_undef. */ #ifdef sv_undef #define PL_sv_undef sv_undef #endif
/* How many processes to get at once from table() */
#define PROCCNT 8
/*
** PROTOTYPES
*/
/* prototypes to make the compiler shut up */
/*
** EXTERNALS
*/
main (int argc, char *argv)
{ =20
/*
** FUNCTIONS
*/
/*
** ARRAYS
*/
char sFilename[16+1];
char pathbuf[MAXPATHLEN+1];
/*
** SCALARS
*/
int ifd =3D 0;
int maxproc =3D 0;
int procnum =3D 0;
int procbase =3D 0;
int psdata =3D 0;
int nproc =3D 0;
int idx1 =3D 0;
int idx2 =3D 0;
int ret =3D 0;
/*
** POINTERS
*/
=20
/*
** STRUCTURES and UNIONS
*/
struct statvfs svfs;
/* defined in <sys/table.h> */
struct tbl_procinfo pstbl[PROCCNT];
/* defined in <sys/procfs.h> */
struct prpsinfo psbuf;
struct prcred pscredbuf;
/*
** WINDOWS and FILES
*/
/*
** BEGIN MAIN PROCESSING
*/
if( statvfs("/proc", &svfs) =3D=3D -1 ) {
(void) fprintf(stderr, "/proc unavailable...ABORTING\n");
exit(1);
}
/* Make sure /proc is mounted */
nproc =3D table(TBL_PROCINFO, 0, 0, MAXINT, 0);
/* loop over all processes */
(void) fprintf(stderr, "PID\tfname\tpsargs\n");
(void) fprintf(stderr, =
"------------------------------------------------\n");
for (idx1=3D0; idx1<nproc; idx1 +=3D PROCCNT) {
ret =3D table(TBL_PROCINFO, idx1, (struct tbl_procinfo *)pstbl, =
PROCCNT, sizeof(struct tbl_procinfo));
for (idx2=3D0; idx2 < ret; idx2++) {
if ((pstbl[idx2].pi_pid !=3D 0) && (pstbl[idx2].pi_status =3D=3D =
PI_ACTIVE)) {
sprintf( pathbuf, "/proc/%d", pstbl[idx2].pi_pid );
/* Construct path of the form /proc/proc_number */
=20
if( (psdata =3D open( pathbuf, O_RDONLY )) =3D=3D -1 ) continue;
=20
if( ioctl(psdata, PIOCPSINFO, &psbuf) =3D=3D -1 ) continue;=20
=20
(void) fprintf(stderr, =
"%d\t%s\t%s\n",pstbl[idx2].pi_pid,psbuf.pr_fname,psbuf.pr_psargs);
close(psdata);
}
}
}
/*
** END MAIN PROCESSING
*/
TERMINATE:
exit(0);
}
------=_NextPart_000_00A3_01C1DB68.0A56B1A0--
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-04-04 4:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-04 4:34 "C" program difference on V5.X vs V4.x redhatcat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox