Code Monkey home page Code Monkey logo

watch-sites's Introduction

watch-sites

Make a head request to a list of HTTPS domains and write a log of the status.

Send an email (via SMTP) if status is not 200.

Dependencies: nodemailer, dotenv


Usage

  1. npm install

  2. Create a .env file and add the following values:

DOMAINS:           A CSV list of HTTPS domains to check
SMTP_HOST:         Email SMTP Host
SMTP_PORT:         Email SMTP Port
SMTP_SECURE:       Nodemailer securee. Us 0 for port 25 or 587
  ^ 0 = false, 1 = true
EMAIL_USER:        Email address that will send the message
EMAIL_PASSWORD:    Password for sending email address
EMAIL_TO:          Email recipient 
SEND_GROUPED_MAIL: Send one email with each failed domain in the body, or send an email for each failed domain. 
  ^ 0 = false, 1 = true
example .env

DOMAINS=https://cloudflare.com,https://letsencrypt.org,https://developer.mozilla.org
SMTP_HOST=smtp.email.com
SMTP_PORT=587
SMTP_SECURE=0
[email protected]
EMAIL_PASSWORD=emailPass123
[email protected]
SEND_GROUPED_MAIL=1
  1. Run with node index
  2. PM2 (optional)
    1. We can use the following command from the same directory as the log will be, to make PM2 not watch the log file but watch the rest:
      pm2 start watch-sites --watch --ignore-watch="watch-sites.log"

About

I wanted a tool to monitor some of the sites I host on my VPS.

I wanted it to not rely on 3rd party packages. This included another attempt at getting my VPS working as a mailserver. While unsuccessful, I was able to get mail to send, just not trusted by Google. I think Ijust need to fix the rDNS/PTR records, it was able to send successfully to a throw away email service, which was pretty neat.

Initially had code to give a more interactive feedback to the console (time remaining would print over the last line instead of making a new one) but those didn't play nice with PM2, so its commented out for now. Might add back with some optional flag.


todo

  • zip/archive/rotate the log based on time or size intervals
    • One logfile per day may work well, with options to change
  • A header line in each log file with details about the log file itself?
    • Like time frame the log covers, number of entries, list of domains, but these things might be better for a log parser. Lets just make a header line with just the date period the log encompasses instead.
  • Log parser to query and display the data
  • How do we want to handle http request errors? Line 217
did
  • Batch emails for non-200 warnings, so one email with a list of each domain and the status in the body. We could put the number of domains that failed in the subject line. โœ“ Done

watch-sites's People

Contributors

paulb-h 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.