$soglia) { $ret = db_qa("show processlist"); foreach ($ret as $k=>$v) { if ($v["Command"] != "Sleep" && $v["Time"] > 0) { $mysqlproclist .= $v["db"] . "|" . $v["Time"] . "|" . $v["State"] . "|" . $v["Command"] . "|" . $v["Info"] . "\n"; } } $url = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; //$load = sys_getloadavg(); //non funziona... $uptime = substr(strrchr(shell_exec("uptime"),":"),1); $load = array_map("trim",explode(",",$uptime)); $sql = "insert into indi_stats set ip = '" . addslashes($_SERVER["REMOTE_ADDR"]) . "' , url = '" . addslashes($url) . "' , post = '" . addslashes($post) . "' , user = '" . addslashes($_SESSION["auth_user"]) . "' , pagina = '" . addslashes($DATI["pagina"]) . "' , tempo_globale = " . $diff_time . " , tempo_db = " . $GLOBALS["indi_stats_db_tempo_db"] . " , proc_list = '" . addslashes($mysqlproclist) . "' , load_avg = " . $load[0]; if (!db_q($sql)) { $err = end($DB["error"]); if ($err[2] == 1146) { //creo tabella $sqlcreate = "CREATE TABLE `indi_stats` ( `id` INT NOT NULL AUTO_INCREMENT, `ts` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `ip` VARCHAR(20) NULL, `url` VARCHAR(1000) NULL, `post` VARCHAR(10000) NULL, `user` VARCHAR(100) NULL, `pagina` VARCHAR(100) NULL, `tempo_globale` FLOAT NULL, `tempo_db` FLOAT NULL, `proc_list` VARCHAR(1000) NULL, `load_avg` FLOAT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM;"; db_q($sqlcreate); db_q($sql); } } //svuoto if (mt_rand(1,30) == 1) { //faccio mtrand per non eseguire sempre la cancellazione ed evitare qualche query al server $giorni = $GLOBALS["indi_stats_db_max_giorni"]; if (!$giorni) $giorni = 30; $sql = "delete from indi_stats where ts < DATE_SUB(NOW(), INTERVAL " . $giorni . " DAY);"; db_q($sql); } } } if($_GET['bench']){ timebench(null,null,true); } // if($_SERVER['REMOTE_ADDR'] == '192.168.0.177' || $_GET['debugtnx']){ // echo '
';
	// $debugBacktrace = debug_backtrace(); array_unshift($debugBacktrace, array('file'=>__FILE__, 'line'=>__LINE__, 'function'=>'debugTnx')); foreach($debugBacktrace as $debugLine) echo "".str_replace("/tnx/www/html/www/", "", $debugLine['file']).""." ".$debugLine['function']."()
"; // $printMe = $GLOBALS['stat3k']; ob_start(); if(is_object($printMe)||is_array($printMe)) print_r($printMe); else var_dump($printMe); echo htmlentities(ob_get_clean(), ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE, 'UTF-8'); // echo '
'; // die; // } if (is_array($DATI["indi_debug_pagina_lenta"])) { $d = $DATI["indi_debug_pagina_lenta"]; //if $CONF['indi_debug_pagina_lenta'] = array("tempo_limite"=>0, "email_to"=>"cecca@tnx.it"); $diff_time = microtime(true) - $indi_start_time; $ignora = false; if ($_GET["utilita"] == "demoCron300") $ignora = true; if (!$ignora && $diff_time >= $d["tempo_limite"]) { $actual_link = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $subj = "indi_debug_pagina_lenta " . $actual_link; $msg = $actual_link . " tempo totale:" . number_format($diff_time, 5) . "( > di " . $d["tempo_limite"] . ") user agent :" . $_SERVER['HTTP_USER_AGENT'] . " _GET:" . print_r($_GET, true) . " _POST:" . print_r($_POST, true) . "\n\nDebug indi:\n"; while(list($k,$v) = each($GLOBALS["DEBUG"])) { if ($lastt) { $tempo = $v["tempo"] - $lastt; $tempo_totale += $v["tempo"] - $lastt; } else { $tempo = 0; $tempo_totale = 0; } $msg .= number_format($tempo_totale, 3) . "\t" . number_format($tempo, 3) . "\t" . $v["tipo"] . "\t" . $v["gruppo"] . "\t" . $v["contesto"] . "\t" . $v["stack_info"] . "\t" . $v["nome"] . "\t" . $v["vari"] . "\n"; $lastt = $v["tempo"]; } mailtnx($d["email_to"], $subj, $msg, "From: cecca@tnx.it\n"); } } ?>