# 1) Calcular la gente a la que se le han de aplicar penalizaciones ids=$(mysql estadisticas -u ibercivis -N -e "select user.id from ibercivis.user, (select fecha, maquina.userid, max(tiempo_cpu_valido/p_ncpus - if(castigo is null, 0, castigo)) tiempo from ibercivis.host, maquina left outer join (select fecha,hostid, sum(penalizacion) castigo from penalty group by hostid,fecha) tabla on tabla.hostid=maquina.hostid and tabla.fecha=maquina.fecha where host.id = maquina.hostid and fecha >= 20090601 and fecha >= date_sub(curdate(), interval 7 day) and fecha < curdate() group by fecha, userid) as tabla where userid = user.id and user.participa = 1 group by userid having round(sum(tiempo)/3600,2)/count(*)>24*1.12 and sum(tiempo) != 0 order by sum(tiempo) desc limit 30;") echo $ids for i in $ids do fecha=$(mysql estadisticas -u ibercivis -N -e "select fecha from maquina,ibercivis.host where tiempo_cpu_valido/p_ncpus=(select max(tiempos) from (select hostid,max(tiempo_cpu_valido/p_ncpus) tiempos from maquina, ibercivis.host where maquina.userid = '$i' and fecha >= 20090601 and fecha < curdate() and host.id = hostid group by fecha) tabla) and host.id=maquina.hostid and host.userid='$i';") hostid=$(mysql estadisticas -u ibercivis -N -e "select hostid from maquina,ibercivis.host where tiempo_cpu_valido/p_ncpus=(select max(tiempos) from (select hostid,max(tiempo_cpu_valido/p_ncpus) tiempos from maquina, ibercivis.host where maquina.userid = '$i' and fecha >= 20090601 and fecha < curdate() and host.id = hostid group by fecha) tabla) and host.id=maquina.hostid and host.userid='$i';") penalizacion=$(mysql estadisticas -u ibercivis -N -e "select tiempo_cpu_valido/p_ncpus-86400 from maquina,ibercivis.host where maquina.hostid=host.id and maquina.hostid='$hostid' and fecha='$fecha';") echo $i $fecha $hostid $penalizacion mysql estadisticas -u ibercivis -e "insert ignore into penalty set hostid = $hostid, fecha=\"$fecha\", penalizacion=$penalizacion, razon='Exceso'" done # 2) AƱadirlos a la tabla de penalizaciones #for i in $ids #do # mysql estadisticas -u ibercivis -e "insert ignore into penalty set hostid = $i, fecha=curdate(), razon='Exceso'" #done # 3) Cambiar las consultas para mostrar las clasificaciones contando con las amonestaciones # 4) Cambiar las tablas para mostrar las amonestaciones y el total final