#!/usr/local/sysmansw/runtime/perl/bin/perl -w

## -_- $Name: PerfGraph-2_4d $ % $Id: pgstop,v 1.1.2.3 2001/03/24 18:32:31 sietse Exp $

# Default directory name
$PGDIR = $ENV{'PGDIR'};
$PGDIR = $ENV{'HOME'} . "/perfgraph" if not defined($PGDIR);

sub stop
{
    chomp($thissystem = `uname`);
    if ($thissystem eq "SunOS" || $thissystem eq "HP-UX")
    {
        $pid = `ps -ef|grep $PGDIR/pgstart|grep -v grep`;
        if ($pid ne "")
        {
            @pid = split(' ', $pid);
            $pid = $pid[1];
        }
    } elsif ($thissystem eq "Linux")
    {
        $pid = `ps ax|grep $PGDIR/pgstart|grep -v grep`;
        if ($pid ne "")
        {
            @pid = split(' ', $pid);
            $pid = $pid[0];
        }
    } else
    {
        print "PerfGraph not stopped -- this is a unknown system type\n";
        return;
    }

    if ($pid ne "")
    {
        print "Stopping Perfgraph processes\n";
        kill 15, $pid;
        sleep 5; # let things settle down.
    }
}

stop;
