Code Monkey home page Code Monkey logo

watchmon's Introduction

      ___           ___                       ___           ___           ___           ___           ___     
     /__/\         /  /\          ___        /  /\         /__/\         /__/\         /  /\         /__/\    
    _\_ \:\       /  /::\        /  /\      /  /:/         \  \:\       |  |::\       /  /::\        \  \:\   
   /__/\ \:\     /  /:/\:\      /  /:/     /  /:/           \__\:\      |  |:|:\     /  /:/\:\        \  \:\  
  _\_ \:\ \:\   /  /:/~/::\    /  /:/     /  /:/  ___   ___ /  /::\   __|__|:|\:\   /  /:/  \:\   _____\__\:\ 
 /__/\ \:\ \:\ /__/:/ /:/\:\  /  /::\    /__/:/  /  /\ /__/\  /:/\:\ /__/::::| \:\ /__/:/ \__\:\ /__/::::::::\
 \  \:\ \:\/:/ \  \:\/:/__\/ /__/:/\:\   \  \:\ /  /:/ \  \:\/:/__\/ \  \:\~~\__\/ \  \:\ /  /:/ \  \:\~~\~~\/
  \  \:\ \::/   \  \::/      \__\/  \:\   \  \:\  /:/   \  \::/       \  \:\        \  \:\  /:/   \  \:\  ~~~ 
   \  \:\/:/     \  \:\           \  \:\   \  \:\/:/     \  \:\        \  \:\        \  \:\/:/     \  \:\     
    \  \::/       \  \:\           \__\/    \  \::/       \  \:\        \  \:\        \  \::/       \  \:\    
     \__\/         \__\/                     \__\/         \__\/         \__\/         \__\/         \__\/    

A command-line utility to link to cron that monitors the machine's disk and RAM usage based on threshold and reports it to the mentioned emails.

!Important: The machine should have email access with SMTP configurations set. Installation of this package will install mutt to be used as an email client.

usage: watchmon [options]
  options:
                -t=, --threshold=    Threshold percentage of the Memory & Disk
                -e=, --emails=       Email or Multiple Emails separated by commas

Example

> bash watchmon.sh -t=90 [email protected]

Setup

  • Cron & Mutt

Run the script in the root of the project as:

> git clone https://github.com/datawrangl3r/watchmon
> cd watchmon
> bash setup.sh

The script will start the cron process, install mutt and creates a directory in the home as: /home/user/mutt/mutt.rc. Edit this file based on your needs by replacing your email address and passwords locally.

set ssl_starttls=yes
set ssl_force_tls=yes

set imap_user = "[email protected]"
set imap_pass = "PASSWORD"

set from="[email protected]"
set realname="Your Name"

set folder = "imaps://imap.gmail.com/"
set spoolfile = "imaps://imap.gmail.com/INBOX"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"

set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"

set smtp_url = "smtps://[email protected]:[email protected]:465/"

set move = no
set imap_keepalive = 900
  • GMail Permissions

Oh, And one more thing! If your SMTP server happens to be google: Google restricts the usage of its services from less secure apps. We need to enable access for the email account to be used in the SMTP settings.

Visit https://myaccount.google.com/security and toggle the less secure app access to ON.

App access

  • Setting up Crontab
  1. Open Crontab:
> crontab -e
  1. Enter the Cron expression & Command

In the following example, the command is set to be run every minute. Hence, if the threshold that you have set, is crossed the inbox will be flooded with email alerts.

* * * * * /mnt/c/Users/sathy/Documents/datawrangler/watchmon/watchmon.sh -t=40 [email protected]

App access

watchmon's People

Contributors

datawrangl3r avatar

Watchers

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