Giter VIP home page Giter VIP logo

diskpatrol's Introduction

Disk Patrol

This is a program to check disk space and alert if the used space is above the configured threshold.

Here are the alert transports.

  • Wall transport: send alert message to the logged-in users.
  • Email transport: send alert message to the mail recipients.
  • Telegram transport: send alert message to the telegram chat id.
  • Slack transport: send alert message to the slack chaneel.

Build (Optional)

If you want to build rpm package, install docker and run run.sh script.:

$ ./run.sh -h
USAGE: run.sh [-h] [-b] [-r] [debian|rocky|centos7]

 -h                             Display this help message.
 -b [debian|rocky|centos7]      Build diskpatrol.
 -r [debian|rocky|centos7]      Run into diskpatrol build env.

To build rpm package for rocky linux:

$ ./run.sh -b rocky

Install

For RHEL-based distro

Install diskpatrol rpm package from the internal genesis file server.:

$ sudo dnf -y install \
    http://192.168.151.110:8000/burrito/diskpatrol-0.2.0-1.el8.x86_64.rpm

Optionally, Install postfix rpm package from the internal genesis file server if you want to use email transport.:

$ sudo dnf -y install \
    http://192.168.151.110:8000/burrito/postfix-3.5.8-4.el8.x86_64.rpm

For Debian-based distro

Install diskpatrol debian package from the internal genesis file server.:

$ curl -LO http://192.168.151.110:8000/burrito/diskpatrol_0.2.0-1_amd64.deb
$ sudo dpkg -i diskpatrol_0.2.0-1_amd64.deb

Optionally, Install postfix rpm package if you want to use email transport.:

$ sudo apt update && sudo apt install postfix

Choose 'No configuration' when it asks the mail server configuration type.

Configure

If there is /etc/postfix/main.cf, back it up to /etc/postfix/main.cf.bak.:

$ sudo mv /etc/postfix/main.cf /etc/postfix/main.cf.bak

Edit /etc/postfix/main.cf.:

$ sudo vi /etc/postfix/main.cf
inet_interfaces = loopback-only
myorigin = <host_fqdn>
mydestination =
local_transport = error: local delivery disabled
mynetworks = 127.0.0.0/8,[::1]/128
smtpd_relay_restrictions = permit_mynetworks,reject

Restart postfix service.:

$ sudo systemctl restart postfix.service

Edit /etc/diskpatrol.conf.

The configuration is self-explanatory. Read the comment and set the configuration variables for your environment.

Restart diskpatrol service.:

$ sudo systemctl restart diskpatrol.service

Operations

Check diskpatrol service is running.:

$ sudo systemctl status diskpatrol.service

The diskpatrol log file is /var/log/diskpatrol.log Check the diskpatrol log file.:

$ tail -f /var/log/diskpatrol.log
2023-08-30 21:29:53,956 INFO:The used space of / (33%) is below warning level (60%)
2023-08-30 21:30:54,026 INFO:The used space of / (33%) is below warning level (60%)
2023-08-30 21:31:54,060 INFO:The used space of / (33%) is below warning level (60%)
2023-08-30 21:32:54,122 INFO:The used space of / (33%) is below warning level (60%)

If the used space is above one of thresholds, it will alert like this.

  • Wall alert:

    DiskPatrol: / is above warning level.
    
    The used space of / is above warning level (30%).
    used/total: 32.6GiB/100.0GiB (33% used)
    
    Please delete some files in /.
    
  • Email alert:

    Date: Thu, 31 Aug 2023 16:37:35
    From: [email protected]
    Subject: DiskPatrol: / is above warning level.
    
    The used space of / is above warning level (30%).
    used/total: 32.6GiB/100.0GiB (33% used)
    
    Please delete some files in /.
    
  • Telegram alert:

    diskpatrol@bbeta-controller
    DiskPatrol: / is in warning level.
    
    The used space of / is above warning level (30%).
    used/total: 32.6GiB/100.0GiB (33% used)
    
    Please delete some files in /.
    

To add telegram alert, create a telegram bot. Here is the guide how to create a telegram bot.

https://core.telegram.org/bots/features#botfather

You need to set APITOKEN and CHATID in /etc/diskpatrol.conf to send telegram message.

diskpatrol's People

Contributors

jijisa 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.