#usage is perl stress.pl <number of clients to create>
use strict;
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
use Apache::lonnet;

my $perlvar=&LONCAPA::Configuration::read_conf('loncapa.conf');
my $server=$perlvar->{'lonHostID'};

my %requests = 
    (
     'ping' => $server
     );

my $number=$ARGV[0];

while ($number--) {
    my $pid=fork;
    if (!$pid) { last; }
}
while(1) {
    while (my($cmd,$resp)=each(%requests)) {
	my $result=&Apache::lonnet::reply($cmd,$server);
	if ($result ne $resp) {
	    print ("FAILED: $result\n");
	}
    }
}
