niceload --sensor ... -l with negative number means: Run if values less than number.

This commit is contained in:
Ole Tange 2012-12-02 21:11:27 +01:00
parent bc0f7701ec
commit 111c7384f7
7 changed files with 37 additions and 10 deletions

View file

@ -455,10 +455,16 @@ sub over_run_limit {
$status += (::max(1,$self->{'runmem'}/$mem)-1); $status += (::max(1,$self->{'runmem'}/$mem)-1);
} }
if($self->{'runload'}) { if($self->{'runload'}) {
# load should be between 0-10ish # If used with other limits load should be between 0-10ish
# 0 load => 0 no warnings 'numeric';
my $load = $self->load_status(); my $load = $self->load_status();
$status += ::max(0,$load - $self->{'runload'}); if($self->{'runload'} > 0) {
# Stop if the load is above the limit
$status += ::max(0,$load - $self->{'runload'});
} else {
# Stop if the load is below the limit (for sensor)
$status += ::max(0,-$load - $self->{'runload'});
}
} }
if($self->{'runnoswap'}) { if($self->{'runnoswap'}) {
# swap should be between 0-10ish # swap should be between 0-10ish
@ -494,8 +500,15 @@ sub over_start_limit {
if($self->{'startload'}) { if($self->{'startload'}) {
# load should be between 0-10ish # load should be between 0-10ish
# 0 load => 0 # 0 load => 0
no warnings 'numeric';
my $load = $self->load_status(); my $load = $self->load_status();
$status += ::max(0,$load - $self->{'startload'}); if($self->{'startload'} > 0) {
# Stop if the load is above the limit
$status += ::max(0,$load - $self->{'startload'});
} else {
# Stop if the load is below the limit (for sensor)
$status += ::max(0,-$load - $self->{'startload'});
}
} }
if($self->{'startnoswap'}) { if($self->{'startnoswap'}) {
# swap should be between 0-10ish # swap should be between 0-10ish

View file

@ -452,6 +452,13 @@ Set the end of file string to eof-str. If the end of file string
occurs as a line of input, the rest of the input is ignored. If occurs as a line of input, the rest of the input is ignored. If
neither @strong{-E} nor @strong{-e} is used, no end of file string is used. neither @strong{-E} nor @strong{-e} is used, no end of file string is used.
@item @strong{--delay} @emph{secs} (alpha testing)
@anchor{@strong{--delay} @emph{secs} (alpha testing)}
Delay starting next job @emph{secs} seconds. GNU @strong{parallel} will pause
@emph{secs} seconds after starting each job. @emph{secs} can be less than 1
seconds.
@item @strong{--dry-run} @item @strong{--dry-run}
@anchor{@strong{--dry-run}} @anchor{@strong{--dry-run}}

View file

@ -6,6 +6,9 @@ testdb: ../src/parallel tests-to-run/*sql* wanted-results/*sql* prereqdb
time sh Start.sh sql time sh Start.sh sql
date date
local: testlocal
true
testlocal: ../src/parallel tests-to-run/*local* wanted-results/*local* prereqlocal testlocal: ../src/parallel tests-to-run/*local* wanted-results/*local* prereqlocal
time sh Start.sh local time sh Start.sh local
date date

View file

@ -4,7 +4,10 @@ echo '### Test niceload exit code'
niceload "perl -e 'exit(3)'" ; echo $? eq 3 niceload "perl -e 'exit(3)'" ; echo $? eq 3
niceload "perl -e 'exit(0)'" ; echo $? eq 0 niceload "perl -e 'exit(0)'" ; echo $? eq 0
# force load > 10
while uptime | grep -v age:.[1-9][0-9].[0-9][0-9] >/dev/null ; do (timeout 5 nice burnP6 2>/dev/null &) done
echo '### Test -p' echo '### Test -p'
perl -e '$|=1;while($t++<3){sleep(1);print "."}' & perl -e '$|=1;while($t++<3){sleep(1);print "."}' &
# The above should be suspended for at least 4 seconds # The above should be suspended for at least 4 seconds
stdout /usr/bin/time -f %e niceload -D -l -2 -p $! | perl -ne '$_ > 6 and print "OK\n"' stdout /usr/bin/time -f %e niceload -D -l 9 -p $! | perl -ne '$_ > 6 and print "OK\n"'

View file

@ -6,7 +6,8 @@ SERVER2=parallel-server2
# -L1 will join lines ending in ' ' # -L1 will join lines ending in ' '
cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j10 -k -L1 cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j10 -k -L1
echo "### Test --delay" echo "### Test --delay"
seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.3 true {} 2>&1 | perl -pe 's/.[0-9]+$//' seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.53 true {} 2>&1 |
perl -ne '$_ > 5 and print "More than 5 secs: OK\n"'
echo '### Test -k 5'; echo '### Test -k 5';
sleep 5 sleep 5

View file

@ -23,7 +23,7 @@ rm /tmp/basic--shebang-wrap
echo "### Test --shebang-wrap with parser options" echo "### Test --shebang-wrap with parser options"
cat <<EOF > /tmp/with-parser--shebang-wrap cat <<EOF > /tmp/with-parser--shebang-wrap
#!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl -p #!/usr/local/bin/parallel --shebang-wrap -k /usr/bin/perl -p
print "Shebang from perl with args @ARGV\n"; print "Shebang from perl with args @ARGV\n";
EOF EOF
@ -31,11 +31,11 @@ EOF
chmod 755 /tmp/with-parser--shebang-wrap chmod 755 /tmp/with-parser--shebang-wrap
/tmp/with-parser--shebang-wrap /tmp/in12 /tmp/in45 /tmp/with-parser--shebang-wrap /tmp/in12 /tmp/in45
echo "### Same as" echo "### Same as"
parallel /usr/bin/perl -p /tmp/with-parser--shebang-wrap ::: /tmp/in12 /tmp/in45 parallel -k /usr/bin/perl -p /tmp/with-parser--shebang-wrap ::: /tmp/in12 /tmp/in45
echo "### stdin" echo "### stdin"
(echo /tmp/in12; echo /tmp/in45) | /tmp/with-parser--shebang-wrap (echo /tmp/in12; echo /tmp/in45) | /tmp/with-parser--shebang-wrap
echo "### Same as" echo "### Same as"
(echo /tmp/in12; echo /tmp/in45) | parallel /usr/bin/perl /tmp/with-parser--shebang-wrap (echo /tmp/in12; echo /tmp/in45) | parallel -k /usr/bin/perl /tmp/with-parser--shebang-wrap
rm /tmp/with-parser--shebang-wrap rm /tmp/with-parser--shebang-wrap

View file

@ -1,5 +1,5 @@
### Test --delay ### Test --delay
3 More than 5 secs: OK
### Test -k 5 ### Test -k 5
### Test -k 3 ### Test -k 3
### Test -k 4 ### Test -k 4