#!/usr/X11R6/bin/perl -w #using strict; #Perforce processes from the system chomp(my @psaux =`ps aux | grep "p4d"`); #Perforce processes using pgrep chomp(my @pgrep =`pgrep p4d`); #Perforce processes using p4 command chomp(my @p4monitor=`p4 monitor show | cut -f1 -d' '`); my $f_file = "pgrep.log"; my $s_file = "p4mon.log"; #delete the previously created log files if(-f $f_file) { unlink $f_file; } if(-f $s_file) { unlink $s_file; } open(PGREP,">>$f_file"); open(P4MON,">>$s_file"); #boolean check to see whether there is any match between the system and p4 command #and the system and pgrep my $pgrep_match = 0; my $p4monitor_match = 0; my $count = 0; foreach my $ps (@psaux) { #get pid from the system my ($d,$pid,$d2) = split(/ /, $ps,3); foreach (@pgrep) { #match against pgrep if($_ eq $pid) { $count = $count + 1; print PGREP "$count " . $ps . "\n"; $pgrep_match = 1; } } foreach (@p4monitor) { #match againt p4monitor if($_ eq $pid) { $count = $count + 1; print P4MON "$count " . $ps . "\n"; $p4monitor_match = 1; } } } if ($pgrep_match == 0) { print PGREP "No matching 'pgreq p4d' processes with 'ps aux | grep p4d'"; } if ($p4monitor_match == 0) { print P4MON "No matching 'p4 monitor show' processes with 'ps aux | grep p4d'"; } close(PGREP); close(P4MON);