logrotated #5
Description
logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large. . This charm can be deployed alongside principle charms to enable logrotate management across deployed services.
- Tags:
- misc ›
Deprecated
The logrotated charm will no longer be maintained by logrotate-charmers. If you have this charm installed without a publisher (i.e. "cs:logrotated") you do not need to do anything. The charm will automatically update to the new maintainer. If you are referencing "~logrotate-charmers/logrotate-charm" you will need to update to the new maintainer: "~llama-charmers/logrotated" (https://jaas.ai/u/llama-charmers/logroated)
Overview
logrotate is a subordinate charm that ensure that all logrotate.d configurations within /etc/logrotate.d/ folder are modified accordingly to a retention period defined in the charm
Build
cd charm-logrotate
charm build
Usage
Add to an existing application using juju-info relation.
Example:
juju deploy ubuntu
juju deploy ./charm-logrotate
juju add-unit ubuntu
juju add-relation ubuntu logrotate
Configuration
The user can configure the following parameters:
* logrotate-retention
(default: 180
): The logrotate retention period in days. The charm will go through ALL
logrotate entries in /etc/logrotate.d/ and set the rotate
config to the appropriate value, depending on the rotation interval used. For example if rotation is monthy and retention is 180 days -> rotate 6
or rotation is daily and retention is 90 days -> rotate 90
or rotation is weekly and retention is 21 days -> rotate 3
Weekly will round up the week count, for example if retention is set to 180 days -> rotate 26
(26 weeks x 7 days = 182 days) Yearly will put rotate to 1 and increase it with 1 for each 360 days. Monthly will round up, using 30 days for a month. Yearly will round up, adding a year for each 360 days.
override
: (default:[]
): JSON formatted field containing a list of files that need to have custom logrotate interval and count. The format is as follows: [ {"path": "/etc/logrotate.d/rotatefile", "rotate": 5, "interval": "weekly"}, {}, ... ]
Mind the double quotes for the properties/values!
Valid options for rotate: any integer value
Valid options for interval: 'daily', 'weekly', 'monthly', 'yearly'
Testing
Unit tests have been developed to test return values from the charm helper class, while modifying pre-defined string entries with the logrotate syntax.
To run unit tests:
tox -e unit
Functional tests have been developed using python-libjuju, deploying a simple ubuntu charm and adding logortate as a subordinate.
To run tests using python-libjuju:
tox -e functional
Contact Information
Diko Parvanov diko.parvanov@canonical.com
Configuration
- logrotate-cronjob
- (boolean) Enabled or disables the creation of a cronjob for the automatic updating of the logrotate files.
- True
- logrotate-cronjob-frequency
- (string) If logrotate-cronjob is True, then this value is used to determine the location of the cronjob file. Valid options are 'hourly', 'daily', 'weekly', 'monthly'.
- hourly
- logrotate-retention
- (int) The logrotate retention period in days. The charm will go through `ALL` logrotate entries in /etc/logrotate.d/ and set the `rotate` config to the appropriate value, depending on the rotation interval used. For example if rotation is monthy and retention is 180 days -> `rotate 6` or rotation is daily and retention is 90 days -> `rotate 90` or rotation is weekly and retention is 21 days -> `rotate 3` Weekly will round up the week count, for example if retention is set to 180 days -> `rotate 26` (26 weeks x 7 days = 182 days) Yearly will put rotate to 1 and increase it with 1 for each 360 days.
- 30
- override
- (string) JSON-formatted string with override options for files in /etc/logrotate.d/ This override takes precendence over all other options. Format is: [ {"path": "/etc/logrotate.d/rotatefile", "rotate": 5, "interval": "weekly"}, {}, ... ] Mind the quotes for JSON properties/values! Valid options for rotate: any integer value Valid options for interval: 'daily', 'weekly', 'monthly', 'yearly'
- []