Code Monkey home page Code Monkey logo

gofsmon's Introduction

Gofsmon Automated File Cleanup In GO


  1. Overview
  2. Getting Started

Overview

Gofsmon reads from a config file and cleans files accordsing to certain rules.

Currently runs on linux and osx

Getting Started

Creating Config File

Currently gofsmon reads from a YAML file.

There are two objecst that can be created. Each object can take similar parameters with the exception of the threshold and time parameters. For each file regex you would like to clean you need a new object

object

  • timefs - These objects clean directories for any files that match the regex and older than x seconds
  • thresholdfs - These objects clean directories for any files that match the regex and whose filesystem mount point exceeds threshold x

parameters

  • mountpoint - This is the mountpoint that is being checked
  • truncate - Bool can be provided with yes or no. If set to yes truncate removes any file matching the regex except the latest and truncates the file to an empty file
  • log
    • dir - This is the directory where the logs are located
    • regex - This is the regex we are checking in the above directory
  • time - Time in seconds. Can only be used with timefs object. This says clean all files in the directory that exceeds x seconds
  • threshold - % that filesystem must exceed in order to trigger cleaning. This says clean all files in the directory if the directory is x% full or more
  • script - Script to be executed if trigger conitions are met

for example config.yaml with following content:

---
  timefs :
    - mountpoint: '/'
    log: 
        dir: '/.dev/log/'
        regex: 'test*.log'
    time: 10800
    truncate: no
     - mountpoint: '/'
     log: 
        dir: '/.dev/log/'
        regex: 'process*.log'
    time: 26280
    truncate: no
    - mountpoint: '/'
    log: 
        dir: '/.dev/log/'
        regex: 'somelog*.log'
    time: 10
    truncate: yes
  thresholdfs:
    - mountpoint: '/'
    log:
        dir: '/.dev/log/'
        regex: 'another*.log'
    threshold: 10
    truncate: yes
    - mountpoint: '/'
    log:
        dir: '/.dev/log/'
        regex: 'process*.log'
    threshold: 50
    truncate: no 
    script: '/.dev/scripts/clean.sh'

Setting Enviroment

The config file location should be set to GOFSMONCONF in the enviroment

either export log location to your current enviroment

$ export GOFSMONCONF=~/.go/src/github.com/rafael-azevedo/gofsmon/config.yaml

or set GOFSMONCONF in your path

Installation

The build script can be found at ~/.go/src/github.com/rafael-azevedo/gofsmon/scripts/build_gofsmon.sh

$ cd github.com/rafael-azevedo/gofsmon/scripts 
$ ./build_gofsmon.sh
2016-10-18 16:03:14 UTC [info] project path: ~/.go/src/github.com/rafael-azevedo/gofsmon
2016-10-18 16:03:14 UTC [info] Building gofsmon to ~/.go/src/github.com/rafael-azevedo/gofsmon/bin/

Running Gofsmon

$ cd github.com/rafael-azevedo/gofsmon/bin
$ ./gofsmon

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.