#!/bin/bash
#Das Programm MonCPU wie's die IHK haben will

cpuutil=0;
cpulimit=60;
maxh=10;

sumstd=0;
usedCPU=(24 23 79 85 95 99 45 12 89 90 67 90 24 23 79 85 95 99 45 12 89 90 67 90);
for ((i=0;$i<24;i++))
 do
  #echo ${usedCPU[$i]};
  if test ${usedCPU[$i]} -gt ${cpulimit}
   then
   # echo "DEBUG: ZUviiiielll!!";
    ((sumstd++));
  fi
 done

#So. Und hier klären wir die Frage, ob die Auslastung mehr als 18 mal über 80% war
 #echo "DEBUG: Wir haben ${sumstd} mal \"ZUviiiielll\" ausgegeben...";
message="Die Auslastung war ganz schön übel gestern:
${sumstd} Stunden über ${cpulimit}% sogar...";
title="MonCPU";
 if test ${sumstd} -gt $maxh
  then
   echo $title;
   echo $message;
  else
   echo "CPU Auslastung nur ${sumstd} mal ZUviiiielll... das geht noch, sag'n'se."
 fi
