Script for manual housekkeping of zabbix
This script has not yet been extensively tested and has not yet been reviewed by others. Use at your own risk.
Usage: (-d |--database( |=))[OPTION] (-h|--help) …
Specifies the maximum age of the values, in unix timestamp format.
The database to use.
Enable debug mode.
You can define a regular expression, which makes sure that the table is not treated when it is hit.
Used grep -Pq, for more information use 'man grep'
Use --dry-run for test. The skipped step have no output.
Example: --exclude-table '^(history|history_uints)$'
Display a help message and exit.
Specifies the maximum age of the values, in unix timestamp format.
Connect to the mysql server on the given host.
Add the LIMIT row_count statement to the DELETE query.
Add the LOW_PRIORITY statement to the DELETE query.
The password to use when connecting to the server.
The TCP/IP port number to use for the connection or 0 for default to, in order of preference, my.cnf, , /etc/services, built-in default (3306).
Set the max runs for deletions replays.
For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
Run the DELETE query for the 'history' table.
Run the DELETE query for the 'history_log' table.
Run the DELETE query for the 'history_str' table.
Run the DELETE query for the 'history_text' table.
Run the DELETE query for the 'history_uint' table.
Run the DELETE query for the 'trends' table.
Run the DELETE query for the 'trends_uint' table.
Add time output lines. (iso-8601)
Specifies the maximum age of the values, in unix timestamp format.
The MariaDB user name to use when connecting to the server.
Delete all values from the trends tables that are older than 354 days with the LOW_PRIORITY specification and a LIMIT of 1000.
./zabbix-housekeeping.sh --database=example --host=127.0.0.1 --password='example' --user=example --trends-age=$(expr \`date +%s\` - $((60*60*24*354)) ) --low-priority --limit=1000
Delete all values from the alerts table that are older than 354 days with the LOW_PRIORITY specification and without LIMIT.
./zabbix-housekeeping.sh --database=example --host=127.0.0.1 --password='example' --user=example --trends-age=$(expr `date +%s` - $((60*60*24*354)) ) --low-priority
Delete all values from the historys tables that are older than 354 days without the LOW_PRIORITY specification and without LIMIT.
./zabbix-housekeeping.sh --database=example --host=127.0.0.1 --password='example' --user=example --trends-age=$(expr `date +%s` - $((60*60*24*354)) )