Giter Club home page Giter Club logo

diskspace-notify's Introduction

Diskspace-notifier

Checks periodically for free disk space and alerts user via email when there is not enough free space (threshold set in config).

It does not aim to replace any large monitoring tools, it is an excercise to learn Go and maybe create something useful.

Features

  • Super simple and lightweight.
  • Configurable plaintext email messages.
  • Check free disk space each X seconds (configurable).
  • Send email via Gmail or local SMTP server.
  • When free disk space crosses threshold (configurable in %), send notification.
  • Asynchronous free space checking.
  • Sends email only after all mountpoints are checked.
  • Sends email only once in X seconds (configurable).
  • Can log to stdout or to logfile.

Usage

# create config (and edit it with your information)
./diskspace-notify -defaultconfig > /path/to.conf

# normal
./diskspace-notify -config /path/to.conf

# with logging
./diskspace-notify -config /path/to.conf -log /path/to.log

Note: It cannot daemonize itself, you should use some startup manager (init.d or supervisor).

If you want to see how the email looks like, you can set threshold value in your config to 99 to make the program send you an email.

Run as a daemon

The program itself cannot be daemonized, but this can be achieved with system tools. For debian-like linux machines, simply copy the binary somewhere (/www/diskspace-notify for example).

Then continue as stated above - generate config, edit it to your specifications, and test-run the program itself. After you've finished these steps, you can copy diskspace-notify.etc to /etc/init.d/diskspace-notify. Edit the file with the correct paths to binary, config and log.

Then you can add

/etc/init.d/diskspace-notify start

to your /etc/rc.local (before the exit 0 statement).

Ideas are welcome!

Get the code

go get github.com/lunemec/diskspace-notify/diskspace-notify

or

git clone [email protected]:lunemec/diskspace-notify.git

Build

Install godep:

go get github.com/tools/godep

Restore saved dependencies.

godep restore

Build.

godep go build

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.