function mod_status_all() { $unix = new unix(); if (!$GLOBALS["VERBOSE"]) { $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidtime = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($unix->file_time_min($pidtime) < 15) { die; } $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { return; } @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, getmypid()); } $table_name = "apache_stats_" . date('Ym'); $q = new mysql(); $sql = "CREATE TABLE IF NOT EXISTS `artica_events`.`{$table_name}` (\n\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t`servername` VARCHAR( 255 ) NOT NULL ,\n\t`UPTIME` VARCHAR( 255 ) NOT NULL ,\n\t`total_traffic` INT UNSIGNED ,\n\t`total_memory` INT UNSIGNED ,\n\t`requests_second` DOUBLE( 100, 2 ) NOT NULL ,\n\t`traffic_second` INT UNSIGNED ,\n\t`traffic_request` INT UNSIGNED ,\n\t INDEX ( `zDate` , `total_traffic` , `total_memory` , `requests_second` , `traffic_second` , `traffic_request`),\n\t KEY `servername` (`servername`))\n\t"; $q->QUERY_SQL($sql, "artica_events"); $ssq = mod_status(); if ($ssq == null) { return; } if ($GLOBALS["VERBOSE"]) { echo "TABLE = {$table_name}\n"; } $sql = "INSERT IGNORE INTO `{$table_name}` (`servername`,`total_traffic`,`total_memory`,`requests_second`,`traffic_second`,`traffic_request`,`UPTIME`) VALUES {$ssq}"; $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { echo $q->mysql_error; } }
function mod_status_all() { $unix = new unix(); if (!$GLOBALS["VERBOSE"]) { $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidtime = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($unix->file_time_min($pidtime) < 15) { die; } $oldpid = @file_get_contents($pidfile); if ($unix->process_exists($oldpid, basename(__FILE__))) { return; } @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, getmypid()); } $table_name = "apache_stats_" . date('Ym'); $q = new mysql(); $sql = "CREATE TABLE IF NOT EXISTS `artica_events`.`{$table_name}` (\n\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t`servername` VARCHAR( 255 ) NOT NULL ,\n\t`UPTIME` VARCHAR( 255 ) NOT NULL ,\n\t`total_traffic` INT( 100 ) NOT NULL ,\n\t`total_memory` INT( 100 ) NOT NULL ,\n\t`requests_second` DOUBLE( 100, 2 ) NOT NULL ,\n\t`traffic_second` INT( 100 ) NOT NULL ,\n\t`traffic_request` INT( 100 ) NOT NULL ,\n\t INDEX ( `zDate` , `total_traffic` , `total_memory` , `requests_second` , `traffic_second` , `traffic_request`),\n\t KEY `servername` (`servername`))\n\t"; $q->QUERY_SQL($sql, "artica_events"); $sql = "SELECT * FROM freeweb ORDER BY servername"; $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { if ($GLOBALS["VERBOSE"]) { echo $q->mysql_error . "\n"; return; } } $prefix = "INSERT INTO {$table_name} (servername,total_traffic,total_memory,requests_second,traffic_second,traffic_request,`UPTIME` ) VALUES"; while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $hostname = $ligne["servername"]; if (trim($hostname) == null) { continue; } mod_status($hostname); } if (count($GLOBALS["MODSTATUSQ"]) == 0) { if ($GLOBALS["VERBOSE"]) { echo "No rows\n"; } return; } $sql = $prefix . @implode(",", $GLOBALS["MODSTATUSQ"]); $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { echo $q->mysql_error; } }