databasectl
databasectl - Insert into/Update to/Delete from Database
databasectl command have the following functions: Inserting into, Updating to, and Deleting from BounceLogs table in a database.
The command will insert(or update) parsed data which are created by
mailboxparser or
logger. This command has been installed in INSTALL-DESTINATION/bin directory.
Usage
databasectl can operate a database like tablectl command
without SQL, and WebUI can do this. but It does not have a full function of databasectl command.
databasectl command is intended for inserting/updating parsed data into the database as a batch process periodically.
Insert/Update today's parsed data
# databasectl --update --today ⏎
Insert/Update yesterday's parsed data
# databasectl -Uy ⏎
Insert/Update parsed data in the file by force
# databasectl --force -U /tmp/log.dat ⏎
Insert/Update data from STDIN
# cat 2009-12-31.log | databasectl --update ⏎
Save parsed data as a file and Insert/Update into the database
# mailboxparser -2 /var/mail/user1 | databasectl --update ⏎
Print help screen
# databasectl --help ⏎
# databasectl --update --today ⏎
Insert/Update yesterday's parsed data
# databasectl -Uy ⏎
Insert/Update parsed data in the file by force
# databasectl --force -U /tmp/log.dat ⏎
Insert/Update data from STDIN
# cat 2009-12-31.log | databasectl --update ⏎
Save parsed data as a file and Insert/Update into the database
# mailboxparser -2 /var/mail/user1 | databasectl --update ⏎
Print help screen
# databasectl --help ⏎
Available Options
Options for database
- -U, --update
- Do update a database with records in a file which is specified in a command line argument.
- --force
- Update by force. By default, If a record in a file is newer than it in a database, databasectl command insert/update the record of the file with verifying a combination of an addresser and a recipient (a message token) except a record which status is whitelist in the database. But databasectl with this --force option overwrite the record (include the status is whitelist) in the database with the record in the file.
- --remove (Begining with ver.2.4.0)
- Delete a record which identified by --id, --token option (described later) from a database. To use this option, Ether --id or --token option should be required.
- --disable (Begining with ver.2.4.0)
- Set the value 1 to a column whose name is disabled of a record. The record which identified by --id, --token options (described later).
- --id Identifier(ID) (Begining with ver.2.4.0)
- Specify an ID of a record which you want to delete/disable by using --remove, --disable options (described earlier). The ID is the ID on the database table.
- --token Identifier(Message Token) (Begining with ver.2.4.0)
- Specify a Message Token string of a record which you want to delete/disable by using --remove, --disable options (described earlier).
Options for Updating
- -b, --before nDays
-
By default, When databasectl is called with the option-U(--update) only,
the command read parsed data from today's file (e.g. Today is 11 February 2011,
The file is hammer.2011-02-11.log) in a log directory which is defined at
etc/bouncehammer.cf .
databasectl with --before 2 read them from hammer.2011-02-09, --before 4 is read them from hammer.2011-02-07.log . --before 1 is equals to the option --yesterday (described later). - -y, --yesterday
- Read parsed data from yesterday's file. If today is 11 February 2011, Yesterday's file is hammer.2011-02-10.log . This option is equals to the option --before 1 (described earlier).
- -t, --today
-
Read parsed data from today's file. If today is 11 February 2011, the file is hammer.2011-02-11.log
in a directory which defined at etc/bouncehammer.cf .
By default, because databasectl read from today's log file, this option can be omitted.This option is equals to the option --before 0 . - -d, --date Date-String (Beginning with ver.2.5.0)
- This option enable to specify a log file with a certain date. If you specify --date 2011/02/11, the log file is hammer.2011-02-11.log . Available format of date is 2011/02/11 or 2011-02-11 .
Common Options
- -B, --batch (Beginning with ver.2.3.1)
- Runs as a batch mode. Results of the command will be displayed as YAML format. It useful to send the results to an administrator with an email.
- -C, --conf /path/to/configuration file
- Use an alternative bounceHammer's configuration file. If this option is omitted, the command will use INSTALL-DESTINATION/etc/bouncehammer.cf .
- -T, --test
- Runs as test mode. This option is equals to the option -C INSTALL-DESTINATION/etc/test-run.cf .
- --silent (Beginning with ver.2.1.0)
- Turn silent mode on. This option makes the command quiet in spite of -v, --verbose option (described later). And when the command is called from a daemon (such as sendmail), the command will exit with status 0 in spite of an error. If an MTA process (e.g. /usr/sbin/sendmail) which is called the command without this --silent option stopped by an error, the command will exit with status 75(EX_TEMPFAIL).
- -v, --verbose
- Turn verbose mode ON.
- --help
- Display help messages of this command.
- --version
- Display the version number of this command.
Screenshot of the running command
No TrackBacks
TrackBack URL: http://bouncehammer.jp/cgi-bin/mt/mt-tb.cgi/108

Leave a comment