#!/usr/bin/perl
open(JOBSTAT, "jobstat -u marki |");
$queuing = 0;
$running = 0;
$holding = 0;
$undefined = 0;
while (<JOBSTAT>) {
    #print;
    chomp;
    split/\s+/;
    $user = $_[1];
    $status = $_[2];
    $jobname = $_[5];
    if ($user eq 'marki' && $jobname eq 'fitter') {
	if ($status eq 'Q') {
	    $queuing++;
	} elsif ($status eq 'R') {
	    $running++;
	} elsif ($status eq 'H') {
	    $holding++;
	} else {
	    $undefined++;
	}
    }
}
$total = $queuing + $running + $undefined;
print "queuing = $queuing, running = $running, holding = $holding, undefined = $undefined, total = $total\n";
if ($queuing < 1) {
    print "not enough jobs queuing, submit ten\n";
    for ($isub = 0; $isub < 10; $isub++) {
	system("jsub /home/marki/jsub/fitter.jsub");
    }
}
exit;
