0.1.1 • Published 8 years ago

node-ping-extended v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

node-ping-extended

A tool for monitoring the up time and response time of websites.

Installation

npm install node-ping-extended

How to use

var Monitor = require('node-ping-extended')

var website = new Monitor(options)

website.on(event, callback(response){
  // Actions on response
})

Options

  • website (* required) - The full url of the website to be monitored.
  • interval (defaults to 15) - Time interval (minutes) for checking website availability.

Emitted Events

  • up - Website operating as expected.
  • down - Website is down.
  • stop - Fired when the monitor has stopped.

Response Sample

response = {
  website: 'http://localhost:3000',
  time: 1459301741422,
  responseTime: 2.2753,
  statusCode: 200,
  statusMessage: 'OK
}
  • response.website - website url being monitored.
  • response.time - Timestamp of request made.
  • response.responseTime - Response time in milliseconds.
  • response.statusCode - http response status code.
  • response.statusMessage - http response status code message.

Example

var Monitor = require('node-ping-extended')

options = {
  website: 'https://stiffupperlip.io',
  interval: 5
}

var website = new Monitor(options)

website.on('up', function(response){
  console.log(response)
})

website.on('down', function(response){
  console.log(response)
})

website.on('stop', function(response){
  console.log(response.website+' monitor has stopped!')
})

API

var Monitor = require('node-ping-extended')

options = {
  website: 'https://stiffupperlip.io',
  interval: 5
}

var website = new Monitor(options)

website.start()

website.stop()

License

The MIT License (MIT)

Copyright (c) 2016 Stiff Upper Lip LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.