Megatest

Check-in [202169a23d]
Login
Overview
Comment:Merged loadrunner and nbfake into single script
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.55
Files: files | file ages | folders
SHA1: 202169a23dd18f414279ddda03b5e8d83d1513c5
User & Date: matt on 2014-06-19 00:27:05
Other Links: branch diff | manifest | tags
Context
2014-06-19
00:34
Added random delay to help spread out invocations of loadrunner check-in: 25320ac902 user: matt tags: v1.55
00:27
Merged loadrunner and nbfake into single script check-in: 202169a23d user: matt tags: v1.55
2014-06-18
15:53
Improvements to build for chicken/iup/sqlite3, see installck.sh check-in: f4214bf31e user: mrwellan tags: v1.55
Changes

Modified utils/loadrunner from [23d28d64a3] to [e593a821d5].

1
2
3
4
5
6
7
8





















9
10
11
12
13
14
15
#!/bin/bash 

LOADRUNNER=$0

# load=`uptime|awk '{print $10}'|cut -d, -f1`
load=$(uptime|perl -pe 's/.*: (\d+.\d+),.*/$1/')
load2=$(uptime|perl -pe 's/.*: (\d+.\d+), (\d+.\d+),.*/$2/')
# echo "load2=$load2, load=$load"






















if which cpucheck > /dev/null;then
    numcpu=`cpucheck|tail -1|awk '{print $6}'`
elif which lscpu > /dev/null;then
    numcpu=`lscpu|grep "CPU.s.:"|awk '{print $2}'`
else
    numcpu=2








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash 

LOADRUNNER=$0

# load=`uptime|awk '{print $10}'|cut -d, -f1`
load=$(uptime|perl -pe 's/.*: (\d+.\d+),.*/$1/')
load2=$(uptime|perl -pe 's/.*: (\d+.\d+), (\d+.\d+),.*/$2/')
# echo "load2=$load2, load=$load"

# Run a job detached from stdin/stdout (i.e. daemonized)
# Launch on remotehost if specified by TARGETHOST
#
function launchjob () {
  # Can't always trust $PWD
  CURRWD=`pwd`
  if [[ $TARGETHOST_LOGF == "" ]]; then
      TARGETHOST_LOGF=NBFAKE-`date +%GWW%V.%u_%T`
  fi
  echo "#======================================================================"
  echo "# NBFAKE Running command:"
  echo "#     \"$*\""
  echo "#======================================================================"
  
  if [[ $TARGETHOST == ""  ]]; then
    sh -c "cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* > $TARGETHOST_LOGF 2>&1 &"
  else
    ssh -n -f $TARGETHOST "sh -c \"cd $CURRWD;export DISPLAY=$DISPLAY; export PATH=$PATH; nohup $* > $TARGETHOST_LOGF 2>&1 &\""
  fi
}

if which cpucheck > /dev/null;then
    numcpu=`cpucheck|tail -1|awk '{print $6}'`
elif which lscpu > /dev/null;then
    numcpu=`lscpu|grep "CPU.s.:"|awk '{print $2}'`
else
    numcpu=2
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
lfile=/tmp/loadrunner-$USER.lockfile
lockfile -r 5 -l 60 $lfile

if [[  $lperc -lt $max_load ]];then
  if [[ $lperc -le $lperc2 ]];then
    echo "Load acceptable: lperc=$lperc %, max_load=$max_load %, load=$load, numcpu=$numcpu, MAX_ALLOWED_LOAD=$MAX_ALLOWED_LOAD % and $lperc2 < $lperc"
    echo "Starting command: \"$@\""
    nbfake "$@"
    # we sleep ten seconds here to keep the lock a little longer and give time for
    # the uptime to show a response
    sleep 10
  else
   echo "$LOADRUNNER $@" | at now + 2 minutes 2> /dev/null
  fi
else
  # echo "Load too high: lperc=$lperc, max_load=$max_load, waiting two minutes before trying to run command: \"$@\""
  echo "$LOADRUNNER $@" | at now + 2 minutes 2> /dev/null
fi

sleep 4
rm -f $lfile







|













49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
lfile=/tmp/loadrunner-$USER.lockfile
lockfile -r 5 -l 60 $lfile

if [[  $lperc -lt $max_load ]];then
  if [[ $lperc -le $lperc2 ]];then
    echo "Load acceptable: lperc=$lperc %, max_load=$max_load %, load=$load, numcpu=$numcpu, MAX_ALLOWED_LOAD=$MAX_ALLOWED_LOAD % and $lperc2 < $lperc"
    echo "Starting command: \"$@\""
    launchjob "$@"
    # we sleep ten seconds here to keep the lock a little longer and give time for
    # the uptime to show a response
    sleep 10
  else
   echo "$LOADRUNNER $@" | at now + 2 minutes 2> /dev/null
  fi
else
  # echo "Load too high: lperc=$lperc, max_load=$max_load, waiting two minutes before trying to run command: \"$@\""
  echo "$LOADRUNNER $@" | at now + 2 minutes 2> /dev/null
fi

sleep 4
rm -f $lfile