Skip to content

danionescu0/Website-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Website-checker

This is a website down checker which supports running check requests in paralel and can be installed on a development board.

Main features:

  • Running requests in parallel
  • Each webpage from the checklist has a max timeout and a optionally regex list to check
  • Supports sending failed data to https://thingspeak.com
  • Has text to speech capabilities to verbally report the problem (optionally)
  • Supports raspberry pi and C.H.I.P. development board integration having the ability to toggle a pin on and off. This can be usefull if you want to implement a physical alarm like a strobe light or a horn
  • Email alerts with the report

What do you need

Usage

  1. Cofiguration (optional), In application.properties you can configure:
  • The thingspeak api key. You can make a free account here and find out more.
    command: thingspeak.api.key=the_key_provided_by_thingspeak

  • How much time will the GPIO pin be active command: gpio.pinHoldTime=nr_of_seconds_to_hold_gpio_active

  • mail.username, mail.password represending credential for email authentification on gmail

  • mail.notifiedAddress representing the email address that will receive the alers

  1. Build the project:
gradle build
  1. Run it:
java -jar -f /path_to_cloned_repo/build/libs/websitechecker-0.0.1-SNAPSHOT.jar /path/to/website-list.txt [--gpio-chip CSID0] [-va] [--gpio-pi pin_nr_on_pi] [--email-alert]

where:

  • "/path/to/website-list.txt" is a path to a simple text file containing website check rules
  • website check rules consists in a enumeration of websites each on a new line along with the milliseconds to wait for the site response. The separator is space
  • "--gpio-chip" enable triggering gpio pin on C.H.I.P. development board on pin "CDID0"
  • "-va" enable voice alert
  • "--email-alert" enable email alert, the email configuration must be set in application.properties

website check rules from the "/path/to/website-list.txt"

  • each line contains one rule
  • first argument is the webpage
  • second argument is the timeout in milliseconds
  • the next arguments are regex rules to check if they are matched in the webpage content, if they aren't matched the url is considered as "down"

example:

https://github.com/ 1500 .*Learn.* .*Git.*
http://www.imdb.com 5050

The example above checks if github.com responds under 1500 ms and does contains the words "Learn" and "Git" and the website imdb.com responds in 5050 ms.

  1. [optional] set it to run as a cron job using crontab

The example below sets the checker to run every minute and to log output on "/path_to_log_file":

crontab -e

# now write in crontab
* * * * * java -jar /path_to_cloned_repo/build/libs/websitechecker-0.0.1-SNAPSHOT.jar -f /path/to/website-list.txt [--gpio-chip CSID0] [-va] [--gpio-pi pin_nr_on_pi] [--email-alert] /path_to_log_file

Extending the code

Using event listeners.

The event is called "com.danionescu.event.FinishedCheckingEvent" and it's launched after all the website list has been crawled. It contains information about the failure / succes of each website to provide a 200 OK status.

By making a listener to this event for example: com.danionescu.listener.FooListener you will receive the event your method that is marked with "@EventListener"

Code example:

    @EventListener
    public void onFinishedChecking(FinishedCheckingEvent finishedCheckingEvent) {

        //your code here
    }

Currently we have the following event listeners:

  • Submitting the check status to thingspeak (succes/failure)
  • Speak a verbal alert (with voice)
  • Trigger a pin for C.H.I.P. development board if configured
  • Trigger a pin for raspberry pi development board if configured
  • Send an email alert

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages