summaryrefslogtreecommitdiff
path: root/postpost/status
blob: dc845253ed22e0e264dab1eb243ef54107ef9888 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh

printsizes=false
printload=false
printnames=true
for s in $*
do
  if [ $s = "-v" ] || [ $s = "--verbose" ]
  then
    printsizes=true;
    printload=true;
  fi
  if [ $s = "-s" ] || [ $s = "--size" ]
  then
    printsizes=true;
  fi
  if [ $s = "-l" ] || [ $s = "--load" ]
  then
    printload=true;
  fi
  if [ $s = "-n" ] || [ $s = "--no-name" ]
  then
    printnames=false;
  fi
  if [ $s = "-h" ] || [ $s = "--help" ]
  then
    echo "Usage:"
    echo "$0 directory [-s|-l|-h|-v]"
    echo
    echo "-v|--verbose print also directory-sizes and CPU-load"
    echo "-s|--size    print also directory-sizes"
    echo "-l|--load    print also CPU-load"
    echo "-n|--no-name don't print names of lost processes"
    echo "-h|--help    print this help"
    exit 0;
  fi
done

Verz=`dirname $1`
Name=`basename $1`

finished=`find $1* -name times* | grep -c . `
total=`ls -1 $Verz | grep -c $Name`
running=`ps -A | grep -c lpic`
queued=`grep -c "cd /home/simulation/lpic-1.3.1/lpic; ./lpic" ../../jobcontrol/todolist`

if [ $total = 1 ]
then
  echo $finished of $total process correct finished
else
  echo $finished of $total processes correct finished
fi

if [ $running = 1 ]
then
  echo $running process still running
else
  echo $running processes still running
fi

if [ $queued = 1 ]
then
  echo $queued process queued
else
  echo $queued processes queued
fi

if [ $(($running + $finished + $queued - $total)) -ne 0 ]
then
  echo
  echo "*********************************************************"
  echo "*                                                       *"
  echo "*  There's at least one not correct finished process!   *"
  echo "*                                                       *"
  echo "*********************************************************"
  if $printnames
  then
    echo
    echo "The bad guys are:"
    for s in `ls -1 $Verz | grep $Name`
    do
      istokay=false
      if [ "$(ls -1 "$Verz/$s" | grep -c "times")" = "1" ] || [ "$(ps -eo args | grep "\./lpic" | grep -v "grep" | awk '{ print "lpic/"$2; }' | awk '{ print "../"$1; }' | ./outputdir_of_inputfile | grep -c "$Verz/$s" )" = "1" ]
      then
        istokay=true
        continue
      fi
      for t in $(grep "cd /home/simulation/lpic-1.3.1/lpic; ./lpic" ../../jobcontrol/todolist)
      do
        if [ -e "../lpic/$t" ] && [ ! "$t" = "./lpic" ]
        then
          if [ "$(echo "../lpic/$t" | ./outputdir_of_inputfile | grep -c "$Verz/$s")" = "1" ]
          then
            istokay=true
            break
          fi
        fi
      done
      if ! $istokay
      then
        echo " "$Verz/$s" ... das ist "$(grep -l "$Verz/$s" ../lpic/input*);
      fi
    done
  fi
fi

echo 
df -hP 2> /dev/null | grep "/home\$" | awk '{ print $3 " of " $2 " used (" $4 " free, " $ 5 " occupied)" }'
echo
if $printload
then
  ps -eo stime,time,pcpu,size,args | grep "\./lpic" | grep -v grep | awk '{ mem = int($4/1024); print "\"" $6 "\" since " $1 " (" $2 " time, " mem "MB used) " $3 "% load" }' | grep -v "(00:00:00 time,"
  echo
fi
if $printsizes
then
  echo "Verzeichnisgrößen"
  echo "-------------------"
  du -hs $1*
  echo
fi