3
# Database maintance script which can be used for rsyslog
4
# and phplogcon default database schema.
5
# Michael Mansour suggested it to be included - thx!
7
# This program was original part of of PHPloghost
8
# Copyright (C) 2004 Tuatha de Dana
9
# some modifications for rsyslog by mmeckelein at 2007-08-08
10
# 2007-08-13 mmeckelein: added dbhost and some other improvements
11
# suggested by Michael Mansour - thx a lot!
13
# This program is free software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111- 1307, USA.
27
# Change these variables to reflect your situation.
30
export table=systemevents
34
# Location of the mysql daemon:
37
# A couple of steps should be taken to maintain your database.
38
# If not, the number of messages will fill your database.
39
# By default, logs are deleted after they're 30 days old.
40
# Change this to meet your requirements.
41
# rsyslog's default database template use two date columns
42
# ReceivedAt and DeviceReportedTime. You can use either of
43
# the two and in most cases it doesn't make a huge difference.
44
# See the property replacer doc at http://www.rsyslog.com/doc
45
# for details on the two dates.
46
SQL_DELETE="DELETE FROM $table WHERE ReceivedAt < CURDATE() - INTERVAL 30 DAY;"
48
# After a large amount of rows have been deleted, we should # optimize the table.
49
SQL_OPT="OPTIMIZE TABLE $table;";
51
$mysqld -u$sqluser -p$password -h$dbhost -e"$SQL_DELETE" -D$database
52
$mysqld -u$sqluser -p$password -h$dbhost -e"$SQL_OPT" -D$database