Article Figure 1 Figure 2 Listing 1 Listing 2
Listing 3 Listing 4 Listing 5 Listing 6 Sidebar 1
Sidebar 2 Table 1 Table 2 Table 3 may2006.tar

Listing 4 Process table

use Proc::ProcessTable;

unless (&check_proc('java -server -Djava_app1','3000')) {
    logit('JAVA APP 1 Offline OLY monitor should return false');
    exit 100;
}

sub check_proc {
    my ($proc,$uid) = @_;
    my $pid;
    my $t = new Proc::ProcessTable;
    foreach my $p ( @{$t->table} ){
        unless($p->cmndline =~ /\b$proc\b/ && $p->uid =~ /$uid/) {
            next;
        }
        $pid = $p->pid;
        debug($proc,'OK');
    }

    unless ($pid) {
        debug($proc,'DOWN');
        return 0;
    }
}