Well, if it's never been touched there was an error in logrotate.. but I was hoping one of guys had corrected.

I would say to search the archives.. but .. here it is, I'll repost.  In this logrotate you'll note that there is one code section that I duplicated.

 The logrotate snippet that drops the old logs is right before the snippet to create the
merge table. The array that feeds both is not updated between. I'll paste my updated
logrotate in below, but I've hacked my logrotate to heck in order to figure everything out.

Anyway, this version uses logsDATE and is meant to run ahead of time, creating each days log file just prior to use. (I run mine at 23:55) This way the log files never get renamed, it just seems to be a really clean way to do it.

--------------------------

 I think I've found the root cause for the issue with logrotate in the 2.8 code.

The logrotate snippet that drops the old logs is right before the snippet to create the
merge table. The array that feeds both is not updated between. I'll paste my updated
logrotate in below, but I've hacked my logrotate to heck in order to figure everything out.


I've updated my version to work the way Jason Taylor outlined here,
http://sourceforge.net/mailarchive/message.php?msg_id=14382261
which is each day going to dateYYYYMMDD and not rotating stuff into a "logs" file and
renaming it. logsYYYYMMDD always contains the data for that day and does not get renamed.
This fixed issues I had with the timing of the logrotate, because by default the data for a
given day would be split between two log files depending on when I ran the rotate.

If you update your syslog.conf line, this code should work verbatim for you.

syslog.conf
destination mysql_dest { pipe("/var/log/mysql.pipe" template("INSERT INTO
logs$YEAR$MONTH$DAY (host, facility, priority, level, tag, datetime, program, msg) VALUES (
'$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC',
'$PROGRAM', '$MSG' );\n") template-escape(yes)) ;};

----------------------------------

logrotate.php
#!/usr/local/bin/php
<?php
// Copyright (C) 2005 Claus Lund, [EMAIL PROTECTED]
echo "\nStarting logrotate";
echo "\n".date("Y-m-d H:i:s")."\n";

$APP_ROOT = '/var/www/html/phpsyslogng';

include_once "$APP_ROOT/includes/common_funcs.php";
include_once "$APP_ROOT/config/config.php";

$dbLink = db_connect_syslog(DBADMIN, DBADMINPW);


// Set filename for new log file
$makelogdate = logs.date("Ymd", mktime(0, 0, 0, date("m"), date("d")+1, date("Y") ));

// Create new table
$result = "CREATE TABLE $makelogdate ( host varchar(32) default NULL, facility varchar(10)
default NULL, priority varchar(10) default NULL, level varchar(10) default NULL, tag
varchar(10) default NULL, datetime datetime default NULL, program varchar(15) default NULL,
msg text, seq bigint(20) unsigned NOT NULL auto_increment, PRIMARY KEY (seq), KEY host
(host), KEY program (program), KEY datetime (datetime), KEY priority (priority), KEY
facility (facility)) TYPE=MyISAM";

if (mysql_query($result)){
echo "success in $makelogdate table creation.\n";
} else {
echo "no $makelogdate table created. May already exist.\n";
}


// Update the list of current tables
if(defined('MERGELOGTABLE') || defined('LOGROTATERETENTION')) {
echo "Getting list of log tables.\n";
$logTableArray = get_logtables($dbLink);
}

// Drop old tables
if(defined('LOGROTATERETENTION') && LOGROTATERETENTION) {
echo "Searching for tables to drop.\n";
foreach($logTableArray as $value) {
if(preg_match("([0-9]{8}$)", $value)) {
// determine is datestamp is old enough
$tableDate = strrev(substr(strrev($value), 0, 8));
$cutoffDate = date("Ymd", mktime(0, 0, 0, date("m"),
date("d")-LOGROTATERETENTION, date("Y")));
if($cutoffDate > $tableDate) {
echo "Dropping ".$value."!\n";
$query = "DROP TABLE ".$value;
perform_query($query, $dbLink);
}
}
}
}



// Drop the merge table
if(defined('MERGELOGTABLE') && MERGELOGTABLE) {
$query = "FLUSH TABLES";
perform_query($query, $dbLink);

$query = "DROP TABLE IF EXISTS ".MERGELOGTABLE;
perform_query($query, $dbLink);
}

// ************* Note this snippet inserted a second time here ****************

// Update the list of current tables
if(defined('MERGELOGTABLE') || defined('LOGROTATERETENTION')) {
echo "Getting list of log tables.\n";
$logTableArray = get_logtables($dbLink);
}

if(defined('MERGELOGTABLE') && MERGELOGTABLE) {
echo "Creating merge table.\n";
$query = "SHOW CREATE TABLE ".DEFAULTLOGTABLE;

$result = perform_query($query, $dbLink);
$row = mysql_fetch_array($result);
$createQuery = $row[1];

$oldStr = "CREATE TABLE `".DEFAULTLOGTABLE."`";
$newStr = "CREATE TABLE `".MERGELOGTABLE."`";
$createQuery = str_replace($oldStr, $newStr, $createQuery);

$oldStr = "ENGINE=MyISAM";
$newStr = "ENGINE=MRG_MyISAM";
$createQuery = str_replace($oldStr, $newStr, $createQuery);
$oldStr = "TYPE=MyISAM";
$newStr = "ENGINE=MRG_MyISAM";
$createQuery = str_replace($oldStr, $newStr, $createQuery);


$createQuery = str_replace('PRIMARY KEY', 'INDEX', $createQuery);


$unionStr = " UNION=(";
foreach($logTableArray as $value) {
$unionStr = $unionStr.$value.", ";
}
$unionStr = rtrim($unionStr, ", ");
$unionStr = $unionStr.")";

$createQuery = $createQuery.$unionStr;

$query = "FLUSH TABLES";
perform_query($createQuery, $dbLink);
}




echo "\n".date("Y-m-d H:i:s")."\n";
echo "All done!\n";
?>



----- Original Message ----
From: Vadim Pushkin <[EMAIL PROTECTED]>
To: [email protected]
Cc: [EMAIL PROTECTED]
Sent: Monday, July 17, 2006 7:46:20 AM
Subject: [Php-syslog-ng-support] Errors Upon Login, Using Latest Code

Hello;

I am using the latest code, and as previously stated in another post, I have
LOGROTATE et to 2.  Well, I've reached that limit after "3" days, and on the
next rotate, I am now getting this message upon login:

Query failed: Can't find file: 'all_logs.MRG' (errno: 2)

Also, somewhat related?  The demo site at http://phlog.gdd.net/ also has
errors upon login, it gives:

Query failed: Table 'syslog.host' doesn't exist

Any fixes or suggestions greatly welcome.

Thanks,

.vp




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Php-syslog-ng-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/php-syslog-ng-support

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Php-syslog-ng-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/php-syslog-ng-support

Reply via email to