steelrose has asked for the wisdom of the Perl Monks concerning the following question:
$pr_envp and $pr_argv hold memory addresses of the command line. Is it possible memory addresses into an array of strings. I know I could write a C program to do this, but I'd like to stay in Perl.foreach $pid (sort {$a<=>$b} <*>) { $uid = getpwuid((lstat "/proc/$pid")[4]); next if $pid == $$; next if $uid ne "netpoint"; open(PSINFO, "/proc/$pid/psinfo") || next; read(PSINFO, $psinfo,256); close PSINFO; my ( $pr_flag, $pr_nlwp, $pr_pid, $pr_ppid, $pr_pgid, $pr_sid, $pr_uid, $pr_euid, $pr_gid, $pr_egid, $pr_addr, $pr_size, $pr_rssize, $pr_pad1, $pr_ttydev, $pr_pctcpu, $pr_pctmem, $pr_start, $pr_time, $pr_ctime, $pr_fname, $pr_psargs, $pr_wstat, $pr_argc, $pr_argv, $pr_envp, $pr_dmodel, $pr_taskid, $pr_projid, $pr_nzomb, $pr_poolid, $pr_zoneid, $filler ) = unpack("iiiiiiiiiiIiiiiSSa8a8a8Z16Z80iiIIaa3iiiiii", $psinfo); print "\n\n---------------\n\nUser: " . $uid; print "\nPID: " . $pid; print "\nMemory: " . ($pr_pctmem / 0x8000 ) * 100; print "\nCPU: " . ($pr_pctcpu / 0x8000 ) * 100; print "\nArguments: " . $pr_envp[1]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Memory Monitoring
by jmcnamara (Monsignor) on Apr 25, 2005 at 13:32 UTC | |
by Anonymous Monk on Apr 25, 2005 at 15:32 UTC | |
|
Re: Memory Monitoring
by Roy Johnson (Monsignor) on Apr 25, 2005 at 13:22 UTC | |
|
Re: Memory Monitoring
by salva (Canon) on Apr 25, 2005 at 13:20 UTC | |
by jhourcle (Prior) on Apr 25, 2005 at 13:44 UTC | |
by salva (Canon) on Apr 25, 2005 at 14:07 UTC | |
|
Re: Memory Monitoring
by naChoZ (Curate) on Apr 26, 2005 at 02:14 UTC | |
by steelrose (Scribe) on Apr 29, 2005 at 15:15 UTC | |
by naChoZ (Curate) on Apr 29, 2005 at 15:52 UTC | |
|
Re: Memory Monitoring
by zentara (Cardinal) on Apr 26, 2005 at 12:19 UTC |