~ubuntu-branches/ubuntu/lucid/rsyslog/lucid

« back to all changes in this revision

Viewing changes to plugins/ommysql/contrib/delete_mysql

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2007-10-19 17:21:49 UTC
  • Revision ID: james.westby@ubuntu.com-20071019172149-ie6ej2xve33mxiu7
Tags: upstream-1.19.10
ImportĀ upstreamĀ versionĀ 1.19.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
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!
 
6
 
 
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!
 
12
 
 
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.
 
17
 
 
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.
 
22
 
 
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.
 
26
 
 
27
# Change these variables to reflect your situation.
 
28
database=sqlrsyslogd
 
29
dbhost="localhost"
 
30
export table=systemevents
 
31
sqluser=""
 
32
password=""
 
33
 
 
34
# Location of the mysql daemon:
 
35
mysqld=/usr/bin/mysql
 
36
 
 
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;"
 
47
 
 
48
# After a large amount of rows have been deleted, we should # optimize the table.
 
49
SQL_OPT="OPTIMIZE TABLE $table;";
 
50
 
 
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