
my $procs;

unless( $procs = $memory{"procs_$args{frequency}_$args{host}_$args{alternate}"} ) {
    &uxmon::load_module( "procs" );
    &uxmon::checker(
	$memory{"procs_$args{frequency}_$args{host}_$args{alternate}"} = $procs = Monitor::procs->new()
    );
    $procs->sched_frequency( $args{"frequency"} );
}
my( $proc, $min, $max );

$args{"_exec"} = $procs;
do "_executor";

if( $args{"pscomm"} ) {
    $procs->set_pscomm( $args{"pscomm"} );
}
else {
    $procs->guess_pscomm();
}

# this works around some truly pathological ps variants (Tru64...)
if( $args{"alternate"} =~ /^-o/ ) {
    $procs->set_alternate( $args{"alternate"} );
}
elsif( $args{"alternate"} =~ /^[yjt1]/i ) {
    $procs->set_alternate( 1 );
}

$args{"check"} ||= "procs";
$args{"down"} ||= "red";

foreach $proc ( split(",",$args{"procs"}) ) {
    $min = 1;
    $max = undef;
    if( ($proc =~ /\((\d*)-(\d*)\)$/) || ($proc =~ /\((\d+)\)$/ ) ) {
	$min = $1;
	$max = $2;
	$proc = $`;
    }
    $proc =~ s#\\\(#\(#g;
    $proc =~ s#\\\)#\)#g;
    $min = undef unless( length($min) );
    $max = undef unless( length($max) );
    my $domain = $args{"domain"};
    $domain = $args{"host"}.":procs" unless( $domain );
    $procs->add_check( $proc, $args{"alias"}.".".$args{"check"}, $min, $max, $domain, $args{"down"} );
}

1;
