OK, this is diff from what I am running and from what Ian posted, but I will
run this and let you know my results tomorrow.'
Thanks!
.vp
>Hmmm...
>Not sure, try this script:
>
>#!/usr/bin/php
><?php
>// Copyright (C) 2005 Claus Lund, [EMAIL PROTECTED]
>echo "\nStarting logrotate\n";
>echo date("Y-m-d H:i:s");
>
>$basePath = dirname( __FILE__ );
>include_once "$basePath/../includes/common_funcs.php";
>include_once "$basePath/../config/config.php";
>
>$dbLink = db_connect_syslog(DBADMIN, DBADMINPW);
>echo "\nStarting logrotate\n";
>echo date("Y-m-d H:i:s");
>
>// Drop temp table if it exists
>$query = "DROP TABLE IF EXISTS temp".DEFAULTLOGTABLE;
>perform_query($query, $dbLink);
>
>// Create new table
>$query = "SHOW CREATE TABLE ".DEFAULTLOGTABLE;
>
>$result = perform_query($query, $dbLink);
>$row = mysql_fetch_array($result);
>$createQuery = $row[1];
>$search = "CREATE TABLE `".DEFAULTLOGTABLE."`";
>$replace = "CREATE TABLE `temp".DEFAULTLOGTABLE."`";
>$createQuery = str_replace($search, $replace, $createQuery);
>perform_query($createQuery, $dbLink);
>
>$today = date("Ymd");
>
>// 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);
>}
>
>// Rename the two tables
>$query = "RENAME TABLE ".DBNAME.".".DEFAULTLOGTABLE." TO
>".DBNAME.".".DEFAULTLOGTABLE.$today.", "
>.DBNAME.".temp".DEFAULTLOGTABLE." TO ".DBNAME.".".DEFAULTLOGTABLE;
>perform_query($query, $dbLink);
>
>echo "\nLog rotate ended successfully.\n";
>echo "Now optimizing the old logs.\n";
>$query = "OPTIMIZE TABLE ".DBNAME.".".DEFAULTLOGTABLE.$today;
>perform_query($query, $dbLink);
>
>if(defined('LOGROTATERETENTION') && LOGROTATERETENTION) {
> echo "Getting list of log tables.\n";
> $logTableArray = get_logtables($dbLink);
> 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);
> }
> }
> }
>}
>
>if(defined('MERGELOGTABLE') && MERGELOGTABLE) {
> echo "Getting list of log tables.\n";
> $logTableArray = get_logtables($dbLink);
> 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";
>
>
>?>
>
>
>On 9/19/06, Vadim Pushkin <[EMAIL PROTECTED]> wrote:
>>but both logs20060917 and logs20060917 are *not* older than 2. If I set
>>this to 90, then I will have to wait 90 days to encounter this bug.
>>
>>It keeps the proper tablename in the pulldown, the tables exist, and
>>contain
>>data, but I am unable to search them using the GUI.
>>
>>.vp
>>
>> >Well that's why, if you set retention to 2, it will delete anything
>>older.
>> >Try setting to 90
>> >
>> >
>> >On 9/19/06, Vadim Pushkin <[EMAIL PROTECTED]> wrote:
>> >>HI Clayton;
>> >>
>> >>Welcome back!
>> >>
>> >>I am still having one issue, I am able to see data when using the
>>pulldown
>> >>for either:
>> >>
>> >>logs
>> >>all_logs
>> >>logs20060919 (today)
>> >>
>> >>I am *unable* to see any data for either:
>> >>
>> >>logs20060917 (two days ago)
>> >>logs20060918 (yesterday)
>> >>
>> >>Incidentally, all_logs and logs contain only what is contained in
>>todays
>> >>(logs20060919) logs.
>> >>
>> >>So, while the logrotate is better, and I am able to see a login screen
>>and
>> >>login sucessfully, I am no longer able to see any data that is older
>>than
>> >>todays date.
>> >>
>> >>Lastly, I have my logrotate set to 2 (reasoning why I am only seeing
>>two
>> >>days worth of options in my pulldown) within my config.php as:
>> >>
>> >>define('LOGROTATERETENTION', 2);
>> >>
>> >>Thanks in advance all,
>> >>
>> >>.vp
>> >>
>> >> >I've confirmed that the logrotate fixes are working as well.
>> >> >
>> >> >
>> >> >On 8/31/06, Vadim Pushkin <[EMAIL PROTECTED]> wrote:
>> >> >>Great news Ian. Are you also able to see data within the various
>>logs
>> >> >>with
>> >> >>a date?
>> >> >>
>> >> >>Regards,
>> >> >>
>> >> >>.vp
>> >> >>
>> >> >> >I incorporated MattW's fix into logrotate.php which you can find
>>as
>> >>an
>> >> >> >attachment here:
>> >> >> >
>> >> >> >http://code.google.com/p/php-syslog-ng/issues/list
>> >> >> >
>> >> >> >See item ID 6.
>> >> >> >
>> >> >> >I've used it for a week and it fixes the GUI login problem and
>> >>deletes
>> >> >> >the old tables as specified by the retention config setting.
>> >> >> >
>> >> >> >On 8/29/06, Vadim Pushkin <[EMAIL PROTECTED]> wrote:
>> >> >> >>
>> >> >> >>Help!
>> >> >> >>
>> >> >> >>Has anyone been able to fix or test Matts new logrotate? So far,
>> >>this
>> >> >>is
>> >> >> >>the only bug, albeit a big one, in this entire package!
>> >> >> >>
>> >> >> >>Thank you,
>> >> >> >>
>> >> >> >>.vp
>> >> >> >>
>> >> >> >>
>> >> >> >> >From: "Vadim Pushkin" <[EMAIL PROTECTED]>
>> >> >> >> >To: [EMAIL PROTECTED],
>>[email protected]
>> >> >> >> >Subject: Re: [Php-syslog-ng-support] Logrotate.php
>> >> >> >>
>> >> >> >> >Hi Matt;
>> >> >> >> >
>> >> >> >> >Have you been able to determine if your changes worked?
>> >> >> >> >
>> >> >> >> >1. Were you able to sucessfully rotate logs?
>> >> >> >> >2. Were you able to keep n number of days worth of logs within
>> >>the
>> >> >> >> >all_logs
>> >> >> >> >table?
>> >> >> >> >
>> >> >> >> >Thank you,
>> >> >> >> >
>> >> >> >> >.vp
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > >From: "Matt Westby" <[EMAIL PROTECTED]>
>> >> >> >> > >To: <[email protected]>
>> >> >> >> > >Subject: Re: [Php-syslog-ng-support] Logrotate.php
>> >> >> >> > >Date: Thu, 17 Aug 2006 12:40:07 +0100
>> >> >> >> >
>> >> >> >> > >... The script therefore becomes
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >-- snip --
>> >> >> >> >
>> >> >> >> > >-- snip --
>> >> >> >> > >
>> >> >> >> > >Not tested it yet ... Waiting for tonight's logrotate.
>> >> >> >> > >
>> >> >> >> > >Matt
>> >> >> >> > >
>> >> >> >> > >-----Original Message-----
>> >> >> >> > >From: Vadim Pushkin [mailto:
>> >> >> >> > >Sent: 17 August 2006 12:33
>> >> >> >> > >To: Matt Westby
>> >> >> >> > >Subject: RE: [Php-syslog-ng-support] Logrotate.php
>> >> >> >> > >
>> >> >> >> > >Did you fix the script? I am suffering badly from this bug
>> >>right
>> >> >> >>now...
>> >> >> >> > >
>> >> >> >> > >.vp
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > > >
>> >> >> >> > > >Have just implemented the logretention settings withing
>> >>logrotate
>> >> >> >>after
>> >> >> >> > >
>> >> >> >> > > >filling up the drive space rather quickly.
>> >> >> >> > > >
>> >> >> >> > > >Looking at the list archive - it seems that others have
>>come
>> >> >>across
>> >> >> >>the
>> >> >> >> > >
>> >> >> >> > > >issue that I am now seeing.
>> >> >> >> > > >
>> >> >> >> > > >After the logrotate in the evening - the Web GUI no longer
>> >>works
>> >> >> >>with a
>> >> >> >> > >
>> >> >> >> > > >Query failed: Can't find file: 'all_logs' (errno: 2)
>> >> >> >> > > >
>> >> >> >> > > >This is because we have created the merged all_logs table
>> >>using
>> >> >>an
>> >> >> >> > > >outdated list of available log tables.
>> >> >> >> > > >
>> >> >> >> > > >The current logic is:
>> >> >> >> > > >Get list of all tables if creating merge tables or dropping
>> >>table
>> >> >> >>Are
>> >> >> >> > > >we looking to drop a table? Yes : Search list for old table
>>&
>> >> >>drop
>> >> >> >>it
>> >> >> >> > > >Do we want to create merge table? Yes : create merge using
>> >>list
>> >> >>we
>> >> >> >>have
>> >> >> >> > >
>> >> >> >> > > >got.
>> >> >> >> > > >
>> >> >> >> > > >The list includes the table we just dropped - hence the
>>error
>> >> >> >> > > >
>> >> >> >> > > >Change the script to
>> >> >> >> > > >
>> >> >> >> > > >Are we looking to drop a table? Yes : get a list of tables.
>> >> >>Search
>> >> >> >>list
>> >> >> >> > >
>> >> >> >> > > >for old table & drop it Do we want to create merge table?
>>Yes
>> >>:
>> >> >>get
>> >> >> >>a
>> >> >> >> > > >list of tables. Create merge.
>> >> >> >> > > >
>> >> >> >> > > >Maybe a FLUSHTABLES is needed in there -- but not sure
>> >> >> >> > > >
>> >> >> >> > > >Matt
>> >> >> >> > > >
>> >> >> >> > > >Matt Westby | Senior Technical Analyst
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Php-syslog-ng-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/php-syslog-ng-support