Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Find related processes with a Perl script UNIX
I wrote a Perl script I call psmonitor long ago to massage the output of the ps command into a list that tells the parent processes of a searched-for program. I have placed the code (as well as some of my other simple scripts) on my website for easy access.

Here's some sample output:
% psmonitor mysql
  ---------------------------------------
  root 11159 0:00.00 con- 0.0 (mysql)
  ---------------------------------------
  hmelton 11204 0:00.02 p2 6.0 ./bin/mysql -e insert into status
     values(53,"7"); writing
  hmelton 11158 0:00.07 p2 0.4 perl -w /Users/hmelton/bin/mkstatus
  hmelton 11157 0:00.01 p2 0.0 perl -w /Users/hmelton/bin/status
  hmelton 11156 0:00.04 p2 0.0 -tcsh (tcsh)
  hmelton 11029 0:12.15 ?? 6.9 /Applications/Utilities/Terminal.app/
     Contents/MacOS/Terminal -psn_0_79953921
  hmelton 176 73:25.55 ?? 0.3 /System/Library/CoreServices/
     WindowServer -daemon
  root 1 0:00.06 ?? 0.0 /sbin/init
  ---------------------------------------
  mysql 362 0:00.44 ?? 0.0 /usr/local/mysql-3.23.51/bin/mysqld
  root 338 0:00.06 ?? 0.0 sh ./bin/safe_mysqld
  root 1 0:00.06 ?? 0.0 /sbin/init
[robg adds: I broke some of the output lines for a narrower display width...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[3,561 views]  

Find related processes with a Perl script | 3 comments | Create New Account
Click here to return to the 'Find related processes with a Perl script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
pstree
Authored by: hayne on Jul 04, '03 01:36:48PM

The command-line program 'pstree' (available via fink) does something very similar if you use the "-s" option.
Your example would be: pstree -s mysql



[ Reply to This | # ]
Find related processes with a Perl script
Authored by: TvE on Jul 05, '03 04:39:37AM

I believe that Panthers Process Viewer application shows the parent processes in a nifty way (it's a GUI thing though)...

:-) TvE



[ Reply to This | # ]
Find related processes with a Perl script
Authored by: Vocal Velocity on Jul 08, '03 12:20:24AM

I know this is very off topic. But the author of this hint is Henry Melton! A great Sci-Fi author and programmer!
I remember the Tor Beast!!!



[ Reply to This | # ]