Code Monkey home page Code Monkey logo

uptime's Introduction

uptime

A remote monitoring application using Node.js, MongoDB, and Twitter Bootstrap.

You can watch a demo screencast on Vimeo.

Warning: This application isn't actively maintained anymore. You can find many alternatives, from completely free to very cheap, in this list of website monitoring services.

Features

  • Monitor thousands of websites (powered by Node.js asynchronous programming)
  • Tweak frequency of monitoring on a per-check basis, up to the second
  • Check the presence of a pattern in the response body
  • Receive notifications whenever a check goes down
    • On screen (powered by socket.io)
    • By email
    • On the console
  • Record availability statistics for further reporting (powered by MongoDB)
  • Detailed uptime reports with animated charts (powered by Flotr2)
  • Monitor availability, responsiveness, average response time, and total uptime/downtime
  • Get details about failed checks (HTTP error code, etc.)
  • Group checks by tags and get reports by tag
  • Familiar web interface (powered by Twitter Bootstrap 2.0)
  • Complete API for integration with third-party monitoring services
  • Powerful plugin system to ease extension and customization
  • Easy installation and zero administration

Installing Uptime

Uptime 3.2 requires Node.js 0.10 and MongoDB 2.1. Older versions provide compatibility with Node 0.8 (Uptime v3.1) and 0.6 (Uptime v1.4).

To install from GitHub, clone the repository and install dependencies using npm:

$ git clone git://github.com/fzaninotto/uptime.git
$ cd uptime
$ npm install

Lastly, start the application with:

$ node app

If you want a production environment:

$ NODE_ENV=production node app

Upgrading From a 2.0 Install

If you have been using uptime 1.0 or 2.0, you have to execute the migration script before using the new release.

$ node models/migrations/upgrade2to3

Adding Checks

By default, the web UI runs on port 8082, so just browse to

http://localhost:8082/

And you're ready to begin. Create your first check by entering an URL, wait for the first ping, and you'll soon see data flowing through your charts!

Configuring

Uptime uses node-config to allow YAML configuration and environment support. Here is the default configuration, taken from config/default.yaml:

url:        'http://localhost:8082'

mongodb:
  server:   localhost
  database: uptime
  user:     root 
  password:
  connectionString:       # alternative to setting server, database, user and password separately

monitor:
  name:                   origin
  apiUrl:                 'http://localhost:8082/api' # must be accessible without a proxy
  pollingInterval:        10000      # ten seconds
  timeout:                5000       # five seconds
  userAgent:              NodeUptime/2.0 (https://github.com/fzaninotto/uptime)

analyzer:
  updateInterval:         60000      # one minute
  qosAggregationInterval: 600000     # ten minutes
  pingHistory:            8035200000 # three months

autoStartMonitor: true

plugins:
  - ./plugins/console
  - ./plugins/patternMatcher
  - ./plugins/httpOptions
  # - ./plugins/email

To modify this configuration, create a development.yaml or a production.yaml file in the same directory, and override just the settings you need. For instance, to run Uptime on port 80 in production, create a production.yaml file as follows:

url: 'http://myDomain.com'

Node that Uptime works great behind a proxy - it uses the http_proxy environment variable transparently.

Architecture

Uptime is composed of two services: a webapp (in app.js), and a polling monitor (in monitor.js). For your convenience, the two services start together when you call node app.

However, heavily browsing the webapp may slow down the whole server - including the polling monitor. In other terms, using the application can influence the uptime measurements. To avoid this effect, it is recommended to run the polling monitor in a separate process.

To that extent, set the autoStartMonitor setting to false in the production.yaml, and launch the monitor by hand:

$ node monitor &
$ node app

Don't forget to set NODE_ENV=production if you want to run the app in production environment.

You can also run the monitor in a different server. This second server must be able to reach the API of the webapp server: set the monitor.apiUrl setting accordingly in the production.yaml file of the monitor server.

Monitoring From Various Locations

You can even run several monitor servers in several datacenters to get average response time. In that case, make sure you set a different monitor.name setting for all monitor servers to be able to tell which server make a particular ping.

Using Plugins

Plugins can add more notification types, more poller types, new routes to the webapp, etc. Uptime currently bundles three plugins:

  • console: log pings and events in the console in real time
  • email: notify events (up, down pause) by email
  • patternMatcher: allow HTTP & HTTPS pollers to test the response body against a pattern
  • httpOptions: add custom HTTP options and headers to HTTP and HTTPS checks (e.g. to allow self-signed certificate on HTTPS, custom headers, custom HTTP methods, ...)
  • basicAuth: add HTTP Basic Access Authentication to the dashboard and API applications

To enable plugins, just add a line to the plugins: section of the configuration file. Three of the bundled plugins are already enabled by default:

# in config/default.yaml
plugins:
  - ./plugins/console
  - ./plugins/patternMatcher
  - ./plugins/httpOptions
  # - ./plugins/email
  # - ./plugins/basicAuth

You can override these settings in your environment configuration, for instance:

# in config/production.yaml
# disable the console plugin and enable the email plugin
plugins:
  # - ./plugins/console
  - ./plugins/patternMatcher
  - ./plugins/httpOptions
  - ./plugins/email
  # - ./plugins/basicAuth

Third-party plugins:

  • webhooks: notify events to an URL by sending an HTTP POST request
  • campfire: notify events to Campfire
  • pushover: Notify events to mobile devices

Writing Plugins

A plugin is a simple Node.js module which hooks into predefined extension points. Uptime automatically requires plugin modules when starting the webapp and the monitor, and tries to call the two following functions:

  • initWebApp(options) when starting the webapp
  • initMonitor(options) when starting the monitor

Check the app.js and monitor.js to see a detail of the options passed to each hook. Also, check the code of existing plugins to understand how they can add new pollers, new notification types, etc.

For instance, if you had to recreate a simple version of the console plugin, you could write it as follows:

// in plugins/console/index.js
var CheckEvent = require('../../models/checkEvent');
exports.initWebapp = function() {
  CheckEvent.on('afterInsert', function(checkEvent) {
    checkEvent.findCheck(function(err, check) {
      console.log(new Date() + check.name + checkEvent.isGoDown ? ' goes down' : ' goes back up');
    });
  });
}

All Uptime entities emit lifecycle events that you can listen to on the Model class. These events are beforeInsert, afterInsert, beforeUpdate, afterUpdate, beforeSave (called for both inserts and updates), afterSave (called for both inserts and updates), beforeRemove, and afterRemove. For more information about these events, check the mongoose-lifecycle plugin.

API

All API requests should be prefixed with api. The API response always uses the application/json mimetype. API requests do not require authentication.

Example of a valid API request:

GET http://example.com/api/checks

Example for a valid API request using curl :

curl -i -H "Accept: application/json" -X PUT -d "name=example" -d "url=http://mysite.com" -d "interval=120" http://example.com/api/checks

Status codes

The API is designed to return different status codes :

  • 200 Ok : The request was successful, the resource(s) itself is returned as JSON
  • 400 Bad Request : An attribute of the API request is invalid or missing (e.g. the url of a check is missing)
  • 404 Not Found : A resource could not be accessed (e.g. a check ID could not be found)
  • 500 Server Error : Something went wrong on the server side (e.g. a check could not be saved in database)

CRUD routes

GET /checks

Return a list of all checks

GET /checks/needingPoll

Return a list of checks that need a poll (i.e. not paused, plus new or last tested > interval set between tests)

GET /checks/:id

Return a single check

Parameter :

  • id : (required) Id of the check

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004

GET /checks/:id/pause

Toggle the status (isPaused) of a check

Parameter :

  • id : (required) Id of the check

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004/pause

PUT /check/:id/test

Updates the last checked date for a check. Used to avoid double check when a target is slow. Return the number of affected records in the database (1 or 0).

Parameter :

  • id : (required) Id of the check

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004/test

GET /pings

Return a list of all pings

Parameters :

  • ?page=1 : (optional) Paginate results by 50
  • ?check=:id : (optional) Return only the pings for a given check

Ex: http://localhost:8082/api/pings?check=527a25bdc9de6e0000000004

GET /pings/events

Return a list of events (CheckEvent) aggregated by day, limited to the latest week, and to 100 results

POST /pings

Create a ping for a check, if the check exists and is not already polled

Parameters :

  • checkId : (required) Id of the check
  • status : (required) Status
  • timestamp : (optional) Date of polling
  • time : (required) Response time
  • name : (optional) Monitor name
  • error : (optional)
  • details : (optional)

GET /tags

Return list of all tags

GET /tags/:name

Return a single tag

Parameter :

  • name : (required) name of the tag

Ex: http://localhost:8082/tags/good

PUT /checks

Create a new check and return it

Parameters :

  • url : (required) Url of the check
  • name : (optional) Name of the check - if empty, url will be set as check name
  • interval : (optional) Interval of polling
  • maxTime : (optional) Slow threshold
  • isPaused : (optional) Status of polling
  • alertTreshold : (optional) set the threshold of failed pings that will create an alert
  • tags : (optional) list of tags (comma-separated values)
  • type : (optional) type of check (auto|http|https|udp)

POST /checks/:id

Update a check and return it

Parameters :

  • id : (required) Id of the check
  • url : (optional) Url of the check
  • name : (optional) Name of the check - if empty, url will be set as check name
  • interval : (optional) Interval of polling
  • maxTime : (optional) Slow threshold
  • isPaused : (optional) Status of polling
  • alertTreshold : (optional) set the threshold of failed pings that will create an alert
  • tags : (optional) list of tags (comma-separated values)
  • type : (optional) type of check - values : auto|http|https|udp

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004

DELETE /checks/:id

Delete a check

Parameters :

  • id : (required) Id of the check

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004

Statistics routes

GET /checks/:id/stat/:period/:timestamp

Return check stats for a period

Parameters :

  • id : (required) Id of the check
  • period : (required) Period - values : hour|day|month|year
  • timestamp : (required) Start date (timestamp)

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004/stat/day/1383260400000

GET /checks/:id/stats/:type

Return check stats for a period

Parameters :

  • id : (required) Id of the check
  • type : (required) Period - values : hour|day|month|year
  • ?begin= : (required) Start date (timestamp)
  • ?end= : (required) End date (timestamp)

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004/stats/month?begin=1383260400000&end=1385852399999

GET /tags/:name/checks/:period/:timestamp

Return tag stats for a period, joined by checks

Parameters :

  • name : (required) Name of the tag
  • period : (required) Period - values : hour|day|month|year
  • timestamp : (required) Start date (timestamp)

Ex: http://localhost:8082/api/tags/good/checks/month/1384816432099

GET /tags/:name/stat/:period/:timestamp

Return tag stats for a period

Parameters :

  • name : (required) Name of the tag
  • period : (required) Period - values : hour|day|month|year
  • timestamp : (required) Start date (timestamp)

Ex: http://localhost:8082/api/tags/good/stat/month/1383260400000

GET /tags/:name/stats/:type

Return tag stats for a period

Parameters :

  • name : (required) Name of the tag
  • type : (required) Period - values : day|month|year
  • ?begin= : (required) Start date (timestamp)
  • ?end= : (required) End date (timestamp)

Ex: http://localhost:8082/api/tags/good/stats/month?begin=1383260400000&end=1385852399999

Event routes

GET /checks/:id/events

Return the list of all events for the check

Parameter :

  • id : (required) Id of the check

Ex: http://localhost:8082/api/checks/527a25bdc9de6e0000000004/events

GET /tags/:name/events

Return the list of all events associated to the tag

Parameter :

  • name : (required) Name of the tag
  • ?begin= : (optional) Start date (timestamp)
  • ?end= : (optional) End date (timestamp)

Ex: http://localhost:8082/api/tags/good/events?begin=1383260400000&end=1385852399999

Support and Discussion

Join the node-uptime Google Group to discuss features, bugs and use cases related to Uptime.

License

The Uptime code is free to use and distribute, under the MIT license.

Uptime uses third-party libraries:

If you like the software, please help improving it by contributing PRs on the GitHub project!

TODO

  • Account for scheduled maintenance (and provide two QoS calculations: with and without scheduled maintenance)
  • Allow for JavaScript execution in the monitored resources by using a headless browser (probably zombie.js)
  • Unit tests

uptime's People

Contributors

bolgovr avatar brice-t avatar brikou avatar brookemckim avatar c33s avatar coderunr avatar davidrautert avatar fzaninotto avatar greggythefly avatar gregoire-m avatar hamstar avatar ianneub avatar jonjonsonjr avatar joshisa avatar loicmahieu avatar mathrobin avatar mintbridge avatar outatime avatar papoms avatar pborreli avatar popdaph avatar robinbressan avatar soullivaneuh avatar trullock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uptime's Issues

TypeError: Cannot read property 'length' of undefined

I get a strange error after a few seconds.
Using Node v0.8.14, uptime v3 branch interval

Mongoose: pings.aggregate({ '$match': { timestamp: { '$lte': new Date("Fri, 16 Nov 2012 20:40:54 GMT"), '$gte': new Date("Thu, 15 Nov 2012 20:40:54 GMT") } } }) { '$project': { check: 1, responsive: { '$cond': [ { '$and': [ '$isResponsive' ] }, 1, '\u001b[33m0\u001b[39m' ] }, time: 1, tags: 1 } } { '$group': { _id: '$check', count: { '$sum': 1 }, responsiveness: { '$avg': '$responsive' }, responseTime: { '$avg': '$time' }, tags: { '$first': '$tags' }, start: { '$first': 1353012054480 }, end: { '$first': 1353098454480 } } }
Mongoose: pings.aggregate({ '$match': { timestamp: { '$lte': new Date("Fri, 16 Nov 2012 20:40:54 GMT"), '$gte': new Date("Thu, 15 Nov 2012 20:40:54 GMT") } } }) { '$project': { check: 1, responsive: { '$cond': [ { '$and': [ '$isResponsive' ] }, 1, '\u001b[33m0\u001b[39m' ] }, time: 1, tags: 1 } } { '$unwind': '$tags' } { '$group': { _id: '$tags', count: { '$sum': 1 }, responsiveness: { '$avg': '$responsive' }, responseTime: { '$avg': '$time' }, start: { '$first': 1353012054480 }, end: { '$first': 1353098454480 } } }
Mongoose: pings.aggregate({ '$match': { timestamp: { '$lte': new Date("Fri, 16 Nov 2012 20:59:59 GMT"), '$gte': new Date("Fri, 16 Nov 2012 20:00:00 GMT") } } }) { '$project': { check: 1, responsive: { '$cond': [ { '$and': [ '$isResponsive' ] }, 1, '\u001b[33m0\u001b[39m' ] }, time: 1, tags: 1 } } { '$group': { _id: '$check', count: { '$sum': 1 }, responsiveness: { '$avg': '$responsive' }, responseTime: { '$avg': '$time' }, tags: { '$first': '$tags' }, start: { '$first': 1353096000000 }, end: { '$first': 1353099599999 } } }
Mongoose: pings.aggregate({ '$match': { timestamp: { '$lte': new Date("Fri, 16 Nov 2012 20:59:59 GMT"), '$gte': new Date("Fri, 16 Nov 2012 20:00:00 GMT") } } }) { '$project': { check: 1, responsive: { '$cond': [ { '$and': [ '$isResponsive' ] }, 1, '\u001b[33m0\u001b[39m' ] }, time: 1, tags: 1 } } { '$unwind': '$tags' } { '$group': { _id: '$tags', count: { '$sum': 1 }, responsiveness: { '$avg': '$responsive' }, responseTime: { '$avg': '$time' }, start: { '$first': 1353096000000 }, end: { '$first': 1353099599999 } } }

/var/uptime/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:437
throw err;
^
TypeError: Cannot read property 'length' of undefined
at Object.async.forEach (/var/uptime/node_modules/async/lib/async.js:81:17)
at QosAggregator.updateHourlyCheckQos (/var/uptime/lib/qosAggregator.js:40:11)
at async.waterfall.wrapIterator (/var/uptime/node_modules/async/lib/async.js:428:21)
at Collection.aggregate (/var/uptime/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:1568:7)
at Cursor.nextObject (/var/uptime/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:540:5)
at Cursor.nextObject.commandHandler (/var/uptime/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:522:14)
at g (events.js:192:14)
at EventEmitter.emit (events.js:126:20)
at Db._callHandler (/var/uptime/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1473:25)
at Server.connect.connectionPool.on.server._serverState (/var/uptime/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:430:30)

Add a double check to reduce the amount of notifications

I was curious if there is a way to add a double check before sending an alert that a domain is down. This way it will cut back on the amount of false alerts due to temporary problems. I have used pingdom.com in the past and they way it works is if the domain is not responding to a ping then it will check it again in 15 seconds. If the domain is still not responding the second time then it will send me an alert.

How to disable Mongoose logging.

We are deploying Uptime to a cloud environment, and anything that gets logged to the console is getting saved to a file, and eventually our environment fills up completely and we have to redeploy to removed the log file. Is there a way to disable logging every single Mongoose call?

Fails to run with process.nextTick error

Did a normal install on Ubuntu 12.04 via git, and via the tarball

git clone git://github.com/fzaninotto/uptime.git
cd uptime/
npm install

but had the same result - nextTick error on start

node app.js 

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'express'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object. (/opt/uptime/app.js:6:18)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:32)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)

Add checks using the API

It would be useful to be able to add, update, and remove checks from uptime using the RESTful API.

api inaccesible

all requests to the api just wait forever and the console shows the following:

[Error: http://localhost:8000/api/check/needingPollCheck resource not available: socket hang up]

rename timestamp field to ts

it is recommended to have short names for fields in documents wherever possible, specially in those collections that will have lots of documents. This applies for checkevents and pings.

Having shorter names saves considerable space in mongodb.

Adding Plugins Not Explicitly clear:

Hello! I'm trying to integrate this badass tool with our own internal monitoring via plugins and I'm having a bit of a problem grasping how the plugin model works.

Do I create an index.js in both the root plugins directory as well as an index.js in the directory of the plugin? I've been trying to enable the example console plugin and haven't been able to do it.

uptime install script

The project takes long time to install on a stock ubuntu 12.04 machine since packaged version of node is quite old (0.6.2) as for MongoDB (r2.0.4) so you have to add others ppa or compile the binaries yourself.

I wrote some chef cookbooks to help with that, which is nice to use with vagrant.
Hope it will help to spread this great project.

https://github.com/t0k4rt/nodejs-cookbook

https://github.com/t0k4rt/mongodb-cookbook

[email protected]:t0k4rt/uptime-cookbook.git

url without http:// breaks

When adding a check, one is forced to always add http://

Would be nice to add http:// if not present.

bug with report of tag

when I click the report of tag, the app.js process throw error messages:

/node_modules/node-uptime/node_modules/mongoose/lib/utils.js:437
throw err;
^
TypeError: Invalid select() argument. Must be a string or object.
at Query.select (/node_modules/node-uptime/node_modules/mongoose/lib/query.js
:1075:11)
at Function.findOne (/node_modules/node-uptime/node_modules/mongoose/lib/mode
l.js:970:46)
at model.populate [as _populate](/node_modules/node-uptime/node_modules/mong
oose/lib/model.js:139:6)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:265:14)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:228:57)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:228:57)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:228:57)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:228:57)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:228:57)
at next (/node_modules/node-uptime/node_modules/mongoose/lib/model.js:228:57)

Adding https Check with custom port breaks functionality

Adding a check using the url format (https://some.domain.com:2087) causes the system to break. Attempts to restart it produce the following error:

node app.js
Monitor origin started
info - socket.io started
Express server listening on port 8082 in development mode

http.js:1382
throw new Error('Protocol:' + options.protocol + ' not supported.');
^
Error: Protocol:https: not supported.
at Object.request (http.js:1382:11)
at Object.get (http.js:1394:21)
at HttpPoller.poll (/root/uptime/lib/pollers/http.js:40:23)
at HttpPoller.onResponseCallback (/root/uptime/lib/pollers/http.js:59:17)
at ClientRequest. (native)
at ClientRequest.g (events.js:156:14)
at ClientRequest.emit (events.js:67:17)
at HTTPParser.onIncoming (http.js:1294:11)
at HTTPParser.parserOnHeadersComplete as onHeadersComplete
at Socket.ondata (http.js:1176:24)

tags not working

tags are not managable for me, i can add them upon the first creation of a 4check, then they land correclty in the database. but regardless if i have tags or not, the tags section /dashboard/tags is completly emtpy for me (just having the table headers)

editing a check don't show any tags, the whole textarea look a little bit small. see screenshot.
Screenshot

the app says the saving was successful but the textarea after the save stays empty. also the database doesn't have new tags in it.

"Error: Can't set headers after they are sent." on startup

I installed MongoDB, node.js (from latest source) and uptime (from latest source) on a Debian system.
I receive the following output after executing node app.js:

Monitor origin started
   info  - socket.io started
Express server listening on port 8082 in development mode
[Error: http://localhost:8082/api/checks/needingPoll resource responded with error code: 404]
Mongoose: pings.ensureIndex({ timestamp: -1 }) { safe: true, background: true }
Mongoose: pings.ensureIndex({ check: 1 }) { safe: true, background: true }
Mongoose: checkevents.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true }
Mongoose: checkhourlystats.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true, unique: true }
Mongoose: checkdailystats.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true, unique: true }
Mongoose: checkmonthlystats.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true, unique: true }
Mongoose: checks.find({ '$where': 'function () {\n if (this.isPaused) return false;\n if (!this.firstTested) return true;\n var delay = (this.lastTested.getTime() - this.firstTested.getTime()) % this.interval;\n return (Date.now() - this.lastTested.getTime() + delay) >= (this.interval || 60000);\n}' }) { fields: { qos: 0 }, safe: true, batchSize: 1000 }
Mongoose: taghourlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: true, background: true, unique: true }
Mongoose: tagdailystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: true, background: true, unique: true }
Mongoose: tagmonthlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: true, background: true, unique: true }
Mongoose: tags.ensureIndex({ name: 1 }) { safe: true, background: true, unique: true }

/home/oliver/uptime/node_modules/mongoose/lib/utils.js:437
        throw err;
              ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:650:11)
    at ServerResponse.res.setHeader (/home/oliver/uptime/node_modules/express/node_modules/connect/lib/patch.js:59:22)
    at ServerResponse.res.set.res.header (/home/oliver/uptime/node_modules/express/lib/response.js:475:10)
    at ServerResponse.res.json (/home/oliver/uptime/node_modules/express/lib/response.js:194:8)
    at Promise. (/home/oliver/uptime/app/api/routes/check.js:36:11)
    at Promise. (/home/oliver/uptime/node_modules/mongoose/lib/promise.js:128:8)
    at Promise.EventEmitter.emit (events.js:93:17)
    at Promise.emit (/home/oliver/uptime/node_modules/mongoose/lib/promise.js:66:38)
    at Promise.complete (/home/oliver/uptime/node_modules/mongoose/lib/promise.js:77:20)
    at Promise.resolve (/home/oliver/uptime/node_modules/mongoose/lib/promise.js:144:15)

clear data

Hello,

im testing uptime, can i clear the data and starts from null?

greats

cannot run behind reverse proxy

in attempting to add my own simple layer of authentication i tried to put node-uptime behind a reverse proxy. this filed. i tried pointing :80/uptime -> :8082/ and got an error about GETting /uptime. after looking at code i realized that the paths are hard coded. being sneaky i used this reverse proxy:
:80/dashboard -> :8082/
so that i could at least navigate to :80/dashboard/events and while that DID work in allowing me to access the app behind a reverse proxy i had not checks!!! it looks like the checks are dependent upon on url that is used to access the app ???? odd decision there. so i opened up :8082 right now and activated my own BASIC authentication layer but it goes against the pattern of every other single web app i run on my server

any thoughts on this? ideas? possible plans to implement? arguments?

Run uptime in background

I don't know if i'm doing something wrong but I can't run uptime in background. I lunch it via putty and the command node app.js but when I exit the shell I can no longer access uptime, and the checks stoped.

Redirections use absolute URL instead of relative

After creating a new tag, user gets redirect to http://localhost:8082/dashboard/checks/id?type=hour&date=date instead of /dashboard/checks/id?type=hour&date=date

This creates a broken link when connecting to Uptime via Apache proxypass:
ProxyPass / http://localhost:8082/

Same issue with "/" redirecting to http://localhost:8082/dashboard/events, but that one could be easily corrected with a rewriterule:
RewriteRule ^/$ http://mydomain/dashboard/events [R]

some question, not bug

hi, fzaninotto
glad to see version 3 is come out.
I have some question about usage.

  • where can we discuss usage problem other than here?
  • I have a lot of websites to add to uptime, is there any quick and dirty way to do that?may be I could import the sites directly into the mongodb, but I haven't touch mongodb until I met uptime. could you give me an example?
  • I know which version I am using through the source code, is there any way the other user could figure out which version from the dashboard intuitive?

Error displaying tag page

When opening a tag page (e.g. http://localhost:8082/dashboard/tags/kwrd ) I get this error.

(Uptime v3 commit 7ed11c4, Ubuntu 11.10 amd64, Node v0.8.14, Mongo DB 2.2.1)

Mongoose: tags.findOne({ name: 'kwrd' }) { fields: undefined, safe: true }
TypeError: /var/uptime/app/dashboard/views/tag.ejs:73
71| '<%= req.query.type || 'month' %>',
72| <%= req.query.date || Date.now() %>,

73| <%= tag.firstTested.valueOf() %>,
74| '/api/tags/<%= tag.name %>/'
75| );
76| jQuery(document).ready(function($) {

Cannot call method 'valueOf' of undefined
at eval (eval at (/var/uptime/node_modules/ejs/lib/ejs.js:223:12))
at exports.compile (/var/uptime/node_modules/ejs/lib/ejs.js:225:15)
at Object.exports.render (/var/uptime/node_modules/ejs/lib/ejs.js:263:13)
at View.exports.renderFile as engine
at View.render (/var/uptime/node_modules/express/lib/view.js:75:8)
at Function.app.render (/var/uptime/node_modules/express/lib/application.js:504:10)
at ServerResponse.res.render as partial
at ServerResponse.module.exports.res.render (/var/uptime/node_modules/express-partials/index.js:55:9)
at Promise. (/var/uptime/app/dashboard/app.js:139:9)
at Promise.addBack (/var/uptime/node_modules/mongoose/lib/promise.js:128:8)

Cannot add any website

No matter what website I add, after some seconds the server stops with:

http.js:1604
    throw new Error('Protocol:' + options.protocol + ' not supported.');
          ^
Error: Protocol:https: not supported.

Strangely this happens with all websites I add no matter if it uses SSL or not.

Email "up" template

I've found a small issue on the email "up" alert, due to the "if then else" that add carriage return, so the subject of the email is empty.
I've fixed it in my fork of the project https://github.com/greggythefly/uptime but I am new to GitHut and don't know how to propose my contribution.

Thanks in advance,

Greg

Addition too README - config.monitor.apiUrl

The README.md file should mention that the URL specified as config.monitor.apiUrl needs to be locally accessible without a proxy as the lib/monitor.js is calling this url without the proxy monkey-patch parsed upfront.

It costed me some hours of figuring out why my all my checks are marked as down.
Especially in cases where you run the app behind a reverse proxy - people might put in the proxies hostname info the 'apiUrl' but that might not necessarily be available locally without a proxy.

Will raise a pull request for that soon.

Mongoose 2.5.12 required for installation on Windows

There was a bug in mongoose 2.5.11 and below that causes an error when installing on Windows. The uptime package references 2.5.11 directly instead of >=. Changing the mongoose version to 2.5.12 or later resolves the issue (I used 2.6.5, the latest label at time of writing). I know this is not your problem, per se - I just wanted to note the issue here in case anyone else ran into this.

Lastly, thank you for the time and effort you've spent writing this app. It's wonderful, and is immediately useful for an internal project I am running. Thanks!

Uptime run at Heroku.com

I try run heroku.

I updated package.json with engines:

"engines": {
    "node": "0.6.x",
    "npm":  "1.0.x"
},

add start:

"scripts": {
    "start": "node app.js"
}

Compilation is ok.

Application throw 503 and this error at: heroku logs:

2012-08-13T17:09:29+00:00 heroku[router]: Error H14 (No web processes running) -> GET shrouded-basin-6069.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=

Error when using MongoDB with auth=true

I am using interval branch.

Uptime works when using MongoDB with noauth.

When I set auth=true in MongoDB conf and add users I get following error:
Error: Uptime requires MongoDB v2.1 minimum. The current MongoDB server uses only undefined

MongoDB version in server is 2.2.2.

Full debug output and mongod.log can be found here: https://gist.github.com/4202402

Users for uptime and admin databases:

[pvaarala@server ~]$ mongo uptime -u pvaarala -p password
MongoDB shell version: 2.2.2
connecting to: uptime
> show users
{
        "_id" : ObjectId("50bdc5637afe20fc69cf350d"),
        "user" : "pvaarala",
        "readOnly" : false,
        "pwd" : "REMOVED FOR PRIVACY"
}

I am not very familiar with MongoDB so this could also be somekind of configuration problem.

Check interval isn't always satisifed

The checks don't seem to be respecting the intervals set when the check is created.

It seems to be drifting from 60 seconds to more and less all the time. Sometimes, more than a whole minute passes until a check is executed.
This happens with the monitor in standalone mode and with it run from app.js.

Ideally, the checks would be scheduled to run at fixed whole minute intervals (:10, :11, :12) and they would run every minute.

Here's an example of what running a check with previous versions and the latest revision of the code (simplified) displays on the 1 hour check page:
10:58:28
10:57:19
10:56:08
10:54:58
10:53:48
10:52:38
10:51:28
10:50:18
10:49:08
10:47:58
10:46:48
10:45:38
10:44:28
10:43:18
10:42:08
10:40:58
10:39:48

update: I've started looking into this issue when some pings were overlapping for some reason and the graph was looking strange.

Tag aggregations are false

To calculate the downtime of a tag, uptime sums the downtime of all the checks of the tag. That's not only naive, it brings back results that don't mean anything, e.g. a downtime of 4 days during a single day for a tag with 4 checks.

A better calculation of tag stats should not sum ups and downs and downtime, but rather determine periods during which everything is up, and periods during which at least one check is down. The tag uptime would be the worst possible uptime.

bulk add checks

a bulk add checks feature would be nice

having a large textarea where i just can paste in urls.
per url a check should be generated with the name of the url without protocol

Error: Protocol:https: not supported.

I was able to add https links to the ui, however the server then bombs out:

Error: Protocol:https: not supported.
at Object.exports.request (http.js:1582:11)
at Object.exports.get (http.js:1589:21)
at HttpPoller.poll (C:\Users\jhribar\node_modules\node-uptime\lib\pollers\http.js:40:23)
at HttpPoller.onResponseCallback (C:\Users\jhribar\node_modules\node-uptime\lib\pollers\http.js:59:17)
at ClientRequest.g (events.js:185:14)
at ClientRequest.EventEmitter.emit (events.js:88:17)
at HTTPParser.parserOnIncomingClient as onIncoming
at HTTPParser.parserOnHeadersComplete as onHeadersComplete
at Socket.socketOnData as ondata
at TCP.onread (net.js:404:27)

blank name results in inaccessible check

creating a check without a name results in an inaccessible check because the link is not clickable in the checklisting.

should fallback to url if name is blank

Error: Can't set headers after they are sent

Hey,

I installed it node, npm and mongo on a fresh Ubuntu Server on Rackspace and after executing node app.js I am getting the following output and error:

root@monitoring:~/uptime# node app.js 
Monitor origin started
   info  - socket.io started
Express server listening on port 8082 in development mode
[Error: http://localhost:8082/api/checks/needingPoll resource responded with error code: 404]
Mongoose: pings.ensureIndex({ timestamp: -1 }) { safe: true, background: true }  
Mongoose: pings.ensureIndex({ check: 1 }) { safe: true, background: true }  
Mongoose: checkevents.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true }  
Mongoose: checkhourlystats.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true, unique: true }  
Mongoose: checkdailystats.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true, unique: true }  
Mongoose: checkmonthlystats.ensureIndex({ timestamp: -1, check: 1 }) { safe: true, background: true, unique: true }  
Mongoose: checks.find({ '$where': 'function () {\n if (this.isPaused) return false;\n if (!this.firstTested) return true;\n var delay = (this.lastTested.getTime() - this.firstTested.getTime()) % this.interval;\n return (Date.now() - this.lastTested.getTime() + delay) >= (this.interval || 60000);\n}' }) { fields: { qos: 0 }, safe: true, batchSize: 1000 }  
Mongoose: taghourlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: true, background: true, unique: true }  
Mongoose: tagdailystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: true, background: true, unique: true }  
Mongoose: tagmonthlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: true, background: true, unique: true }  
Mongoose: tags.ensureIndex({ name: 1 }) { safe: true, background: true, unique: true }  

/root/uptime/node_modules/mongoose/lib/utils.js:437
        throw err;
              ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:650:11)
    at ServerResponse.res.setHeader (/root/uptime/node_modules/express/node_modules/connect/lib/patch.js:59:22)
    at ServerResponse.res.set.res.header (/root/uptime/node_modules/express/lib/response.js:475:10)
    at ServerResponse.res.json (/root/uptime/node_modules/express/lib/response.js:194:8)
    at Promise.<anonymous> (/root/uptime/app/api/routes/check.js:36:11)
    at Promise.<anonymous> (/root/uptime/node_modules/mongoose/lib/promise.js:128:8)
    at Promise.EventEmitter.emit (events.js:93:17)
    at Promise.emit (/root/uptime/node_modules/mongoose/lib/promise.js:66:38)
    at Promise.complete (/root/uptime/node_modules/mongoose/lib/promise.js:77:20)
    at Promise.resolve (/root/uptime/node_modules/mongoose/lib/promise.js:144:15)```

Any idea what the problem is?

Stopped MongoDB appears as site is down in reports

For maintenance purposes, I needed to stop MongoDB while Uptime was running. Now in my reports, the few minutes while Mongo was out of order appear as sites where down, with a timeout (those sites are on other servers and do not use Mongo, FYI ;) ).
I propose that a "service outage" value may a better value for those moments.

password protect

Hello,

How can I password protect uptime?
After installation, the software is available to everyone.
Can I use an htaccess authentication here or something?

Greats Leibnitz

Question - A check that looks for content in response

Francois,

I am interested in adding the ability for a check to check if the response contains a specified string. I've been able to accomplish this by modifying the check object / schema, and the pollers. However, I'm unsure if I did this the best way.

Basically, I created a new poller, and I have the new poller (called ContentPoller) inherit from the base poller, and the http and https pollers inherit from the content poller.

My question is, if you were to add this functionality to the pollers, would you have done it this way? Would you have added the content polling option to the base poller instead of creating a new poller that the http and https poller inherit? Basically, how you would have done this?

Thanks in advance,

Chris

Just A Question - Not An Issue

When you have time, could you please provide an example of running the monitor on one server and the web app on a separate server? Primarily an example of the yaml config files as they would look on each server. Assume that both servers are in the same domain and thus can see each other. Also assume that the mongodb is running on one of the servers, say, the monitor server. I'm seeing weird behavior when I run the monitor on one server and the web app on a different server, and I want to ensure that I've configured everything correctly.

Thanks in advance!

email notification issue

Hi,
I got this error when trying to send email notification

var/www/uptime/node_modules/mongoose/lib/utils.js:410
        throw err;
              ^
TypeError: /var/www/uptime/plugins/email/views/up.ejs:3
    1| [Up] Check "<%= check.name %>" went back up
    2| On <%= moment(checkEvent.timestamp).format('LLLL') %>,
 >> 3| and after <%= moment.duration(checkEvent.downtime).humanize() %> of downtime,
    4| a test on URL "<%= check.url %>" responded correctly.
    5| 
    6| <% include details %>

Cannot read property 'years' of undefined
    at Object.Duration (/var/www/uptime/node_modules/moment/moment.js:229:29)
    at Function.moment.duration (/var/www/uptime/node_modules/moment/moment.js:800:15)
    at eval (eval at <anonymous> (/var/www/uptime/node_modules/ejs/lib/ejs.js:223:12))
    at exports.compile (/var/www/uptime/node_modules/ejs/lib/ejs.js:225:15)
    at Object.exports.render (/var/www/uptime/node_modules/ejs/lib/ejs.js:263:13)
    at Promise.exports.init (/var/www/uptime/plugins/email/index.js:51:23)
    at Promise.addBack (/var/www/uptime/node_modules/mongoose/lib/promise.js:128:8)
    at Promise.EventEmitter.emit (events.js:96:17)
    at Promise.emit (/var/www/uptime/node_modules/mongoose/lib/promise.js:66:38)
    at Promise.complete (/var/www/uptime/node_modules/mongoose/lib/promise.js:77:20)
vagrant@precise64:/var/www/uptime$ node app.js

I haven't tried to debug yet (I'm very bad with node :-/), I'll tried to take a look as soon as I can.
Thanks a lots for this product !

UDP check not working

udp://google.com does not seems to be valid udp url

/root/uptime/uptime/lib/pollers/udp.js:42
'address': host[1],
^
TypeError: Cannot read property '1' of null
at UdpPoller.initialize (/root/uptime/uptime/lib/pollers/udp.js:42:20)
at UdpPoller.BasePoller (/root/uptime/uptime/lib/pollers/base.js:19:8)
at new UdpPoller (/root/uptime/uptime/lib/pollers/udp.js:29:20)
at Monitor.pollCheck (/root/uptime/uptime/lib/monitor.js:105:7)
at Monitor.pollChecksNeedingPoll (/root/uptime/uptime/lib/monitor.js:69:12)
at Array.forEach (native)
at Monitor.pollChecksNeedingPoll (/root/uptime/uptime/lib/monitor.js:68:12)
at IncomingMessage.Monitor.findChecksNeedingPoll (/root/uptime/uptime/lib/monitor.js:88:7)
at IncomingMessage.EventEmitter.emit (events.js:115:20)
at IncomingMessage._emitEnd (http.js:366:10)

Am I missing something obvious here?

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.