Giter VIP home page Giter VIP logo

logrotated's Introduction

logrotated

Build Status PyPI PypI

Why does your volume keep exploding? It's not ISIS! It's your logs!

logrotated is a CLI and Pythonic API for logrotate and LogRotateWin (SOON!). It aims to make logrotation easier without having to know the ins and outs of logrotate.

Features

Compatibility

Currently, tested on Python 2.6.x and 2.7.x Will be adding Python 3.x support soon enough.

Installation

sudo pip install logrotated

For dev:

sudo pip install https://github.com/nir0s/logrotated/archive/master.tar.gz

Usage

$ sudo rotatethis --help
Usage: rotatethis [OPTIONS] PATH...

  Generates a logrotate configuration and deploys it if necessary.

Options:
  -n, --name TEXT                 The name of the logrotation script.
                                  [required]
  -d, --deploy                    Deploy the configuration on the current
                                  machine.
  -f, --frequency [daily|weekly|monthly|yearly]
                                  How often to rotate the files.
  -s, --size TEXT                 Size of file at which rotation will take
                                  place. (e.g. 100k, 100M, 100G)
  -k, --keep TEXT                 How many files to keep when rotating.
  -c, --compress                  Whether to compress rotated log files or
                                  not.
  --create TEXT...                Created new log files using `mod user
                                  password`.
  -l, --delay-compression TEXT    Delay the compression by one file. This will
                                  leave one rotated log file uncompressed
                                  until the next rotation.
  --nocompress                    Negates --compress (in case it is configured
                                  in the main logrotate config.
  --dont-rotate-empty             Do not rotate empty files.
  -m, --ignore-missing            If there are no logs, don't fail.. just
                                  continue.
  --shared-postscript             Run postrotate script only after all logs in
                                  path have been checked.
  -p, --post-rotate TEXT          A script to run post rotation. This is
                                  required by some applications.
  --overwrite                     Whether to overwrite a logrotate config or
                                  not.
  -v, --verbose
  --help                          Show this message and exit.
...

Rotating Paths

$ rotatethis '/var/log/mongodb/*.log' '/var/log/mongos' --name mongo -v -p '/usr/bin/killall -SIGUSR1 mongod' -p '/usr/bin/killall -SIGUSR1 mongos' --keep 5 --frequency daily --create 644 user group --dont-rotate-empty --deploy
...

INFO - Generating logrotate config...
INFO - Deploying /tmp/logrotate-test/test to /etc/logrotate.d/test...
INFO - Deployment successful!
...

$ cat /etc/logrotate.d/mongo

/var/log/mongodb/*.log /var/log/mongos { 
    daily
    rotate 5
    notifempty
    compress
    create 644 user group 
    postrotate
        /usr/bin/killall -SIGUSR1 mongod
        /usr/bin/killall -SIGUSR1 mongos
    endscript
}

Generating only

If the --deploy flag isn't provided, the file will be saved under /tmp/logrotate-NAME/NAME for future use.

Python API

raise NotImplementedError()

Testing

git clone [email protected]:nir0s/logrotated.git
cd logrotated
pip install tox
tox

Contributions..

Pull requests are always welcome.

logrotated's People

Contributors

nir0s avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.