uri-monitor

Monitor a URI's connectivity

uri-monitor

Monitor a URI's connectivity

npm install uri-monitor
URI_Monitor :: String URI, Int check_interval_ms -> uri_monitor
  • uri The URI to monitor. Plain GET requests willbe made against this.
  • interval_ms The time between checks

uri_monitor is an instance of EventEmitter2.

start :: -> uri_monitor

Begin the monitor; Boots a setInterval.
stop :: -> uri_monitor

Stop the monitor:

check :: -> uri_monitor

Force a manual check. This is a totally independent check. It does not affect the start/stop system in any way. It does not affect the setInterval being run.

on :: String event_name, (* -> void) -> uri_monitor

Listen for events.

event namecallback argumentsdescription
'check'is_connected :: Boolean, response :: Check_ResultA check result
'change'is_connected :: Boolean, response :: Check_ResultA check result, and it is different than the last check
'pong'response :: Check_ResultA check result that is a success
'drop'response :: Check_ResultA check result that is a failure
'connection'response :: Check_ResultA check result that is a success, and it is different than the last check
'disconnection'response :: Check_ResultA check result that is a failure, and it is different than the last check

superagent has two types of request errors: general IO and response errors in the 400 or 500 range. URI Monitor treats both as a check failure. Result can be one of three things:

  1. If a successful request then the superagent response object.
  2. If a failed request due to IO, then the err as returned by superagent.
  3. If a failed request due to 4xx/5xx range response, then the response.error as provided by superagent.
  • Enable debug mode with label uri-monitor using debug