Giter Club home page Giter Club logo

server-patrol's Introduction

Server Patrol

Simple HTTP-based server status check tool with email/SMS alerts.

Features

  • Manage multiple monitorings (URLs to check)
  • Check the network connection as well as 4XX and 5XX HTTP errors
  • Simple visualization of each monitorings status (down, up, unknown) with their respective down reason
  • RSS feed of the monitorings status (public monitorings only)
  • Responsive (can be used on mobile devices)
  • Ability to configure, for each monitorings:
    • HTTP method to use, connection timeout and if the HTTPS certificate have to be verified
    • Availability (enabled or disabled)
    • Public visibility
    • Check interval
    • (Optional) Email recipients and/or mobile phone numbers who will receive the status alerts
    • (Optional) A Python Regex to perform a HTTP response body-based check
    • (Optional) Custom HTTP headers to send
  • Internationalized & localized in 2 languages:
    • English (en)
    • French (fr)

Prerequisites

  • Should work on any Python 3.x version. Feel free to test with another Python version and give me feedback
  • A uWSGI-capable web server (optional, but recommended)
  • (Optional) A SMTP server to send email alerts
  • (Optional) A Twilio account to send SMS alerts

Installation

  1. Clone this repo somewhere
  2. pip install -r requirements.txt
  3. pybabel compile -d translations
  4. export FLASK_APP=serverpatrol.py (Windows users: set FLASK_APP=serverpatrol.py)
  5. flask create_database (WARNING: don't re-run this command unless you want to start from scratch, it will wipe out all the Server Patrol's data)
  6. Create the scheduled task that will run the script who will perform the checks every minutes (only for active monitorings that are due):

On a Linux-based OS, create this Cron entry:

* * * * * cd /path/to/server-patrol && export FLASK_APP=serverpatrol.py && flask check >/dev/null 2>&1

On Windows, create this scheduled task using the command line:

schtasks /create /tn "Server Patrol" /tr "cd C:\path\to\server-patrol && set FLASK_APP=serverpatrol.py && flask check" /sc MINUTE

Don't forget to add a command to activate your virtualenv if you're using one.

Configuration

Copy the config.example.py file to config.py and fill in the configuration parameters.

Available configuration parameters are:

  • SECRET_KEY Set this to a complex random value

More informations about Flask config values can be found here.

  • TITLE If set to a string, will be used to replace the default app title (which is "Server Patrol")
  • USERS The credentials required to access the app. You can specify multiple ones. It is highly recommended to serve Server Patrol through HTTPS because it uses HTTP basic auth
  • SERVER_NAME The IP or hostname where Server Patrol will be available
  • FORCE_LANGUAGE Force the lang to be one of the supported ones (defaults to None: auto-detection from the Accept-Language HTTP header). See in the features section above for a list of available lang keys
  • DEFAULT_LANGUAGE Default language if it cannot be determined automatically. Not taken into account if FORCE_LANGUAGE is defined. See in the features section above for a list of available lang keys

SMTP-related parameters to send email alerts:

  • ENABLE_EMAIL_ALERTS Wheter to enable the email feature or not. If True, fill in the configuration parameters below
  • MAIL_SERVER The SMTP server name / IP to use to send email alerts
  • MAIL_PORT The SMTP server port
  • MAIL_USE_TLS Use TLS when connecting to the SMTP server?
  • MAIL_USE_SSL Use SSL when connecting to the SMTP server?
  • MAIL_USERNAME Username to use to connect to the SMTP server
  • MAIL_PASSWORD Password to use to connect to the SMTP server
  • MAIL_DEFAULT_SENDER A Python tuple to define the identity of the Server Patrol's mail sender

More configuration parameters can be added about SMTP configuration, see here.

Twilio-related parameters to send SMS alerts:

  • ENABLE_SMS_ALERTS Wheter to enable the SMS feature or not. If True, fill in the configuration parameters below
  • TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN are your Twilio credentials
  • TWILIO_SENDER_PHONE_NUMBER The Twilio phone number that will send the SMS

I'll let you search yourself about how to configure a web server along uWSGI.

Usage

As you can see, Server Patrol is split in two pieces:

  • A Flask command (flask check) to run the checks (run flask check --help for the full list of arguments)
  • A Flask web app (the Server Patrol GUI) itself

You can run the web app:

  • Standalone

Run the internal web server, which will be accessible at http://localhost:8080:

python local.py

Edit this file and change the interface/port as needed.

  • uWSGI

The uWSGI file you'll have to set in your uWSGI configuration is uwsgi.py. The callable is app.

  • Others

You'll probably have to hack with this application to make it work with one of the solutions described here. Send me a pull request if you make it work.

How it works

This project is built on Flask (Python) for the backend which is using a small SQLite database to persist data. HTTP requests are used to check the configured monitorings via the flask check command.

End words

If you have questions or problems, you can submit an issue.

You can also submit pull requests. It's open-source man!

server-patrol's People

Contributors

epocdotfr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

server-patrol's Issues

Reports

Add charts of past requests duration for each monitorings with filtering capabilities. Also display stats (like percentage of overall availability and average request duration).

  • Create a new table to store this data (monitoring_checks)
  • Create a new menu entry: Reports
  • Create the chart
  • Add controls to the chart (last day / week / month and timespan selection)
  • Update the readme
  • Update the screenshot

Enhance the HTTP headers, emails and phone numbers inputs

By using Vue.js, and storing them in JSON in the database (no more custom parsing process, just JSON encode/decode them).

More user-friendly, and prevent the user to enter invalid data format (although there's no validation server-side, it's better than nothing like actually).

  • Emails
  • HTTP headers
  • Phones
  • Update translations

Ability to set error HTTP statuses (!= 2xx) as "it's ok"

Actually, only 2xx HTTP status codes are used to determine that an URL is OK (the white list).

Add a feature to define that, for each monitoring, HTTP status codes other than 2xx are also "OK" (i.e reachable) as the server responded anyway.

Use case: monitoring a website that is protected by HTTP authentication. A request to this kind of resource will return a 401. That is okay because the server response even if it's an error. Also I don't want Server Patrol to be able to store credentials for security reasons.

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.