forked from jeffsu/upbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/dashboard' of github.com:jeffsu/upbeat into fea…
…ture/dashboard
- Loading branch information
Showing
8 changed files
with
198 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,107 @@ | ||
# Upbeat is a high performance healthcheck/dashboard based in node | ||
# Upbeat | ||
|
||
Upbeat is a high performance node-based healthcheck/dashboard. Upbeat allows you to run health checks and provides a dashboard to chart the performance. It also allows you to proxy and cache these health checks so they don't tax your system. You can now reduces the number of health checks to a service from O(N) to O(1). | ||
|
||
## Installation | ||
|
||
As executable | ||
```bash | ||
npm install -g upbeat | ||
``` | ||
|
||
Run upbeat | ||
```bash | ||
upbeat config.yml | ||
``` | ||
|
||
As library | ||
```bash | ||
npm install upbeat | ||
``` | ||
|
||
```js | ||
var upbeat = require('upbeat'); | ||
var server = new upbeat.Server(configObject); | ||
server.run(); | ||
``` | ||
|
||
## Configuration | ||
|
||
Quickstart config: | ||
|
||
```yml | ||
dashboard: | ||
port: 2468 | ||
|
||
sync: | ||
redis: | ||
port: 6379 | ||
host: localhost | ||
|
||
services: | ||
google: | ||
www: | ||
strategy: http | ||
url: https://www.google.com | ||
connection: | ||
strategy: tcp | ||
host: google.com | ||
port: 80 | ||
``` | ||
### Services | ||
<<<<<<< Updated upstream | ||
Services are a way of grouping several sensor checks together. In the example above, we have a "google" service w | ||
hich we check by making a get request to "https://www.google.com" and also seeing if we have a connection to port 8 | ||
0 on the "google.com" host. In the yaml config, a service is a "hash" of sensors where the keys are the names of | ||
the sensors and the values are the configuration. | ||
### Sensors | ||
Sensors are a way of describing a health check. Each sensor config MUST at least have a strategy. Common configuration | ||
options accross all strategies are: | ||
* timeout: number (milliseconds) to define how long it will allow a check before declaring it a failure | ||
* interval: number (milliseconds) of time to wait between health checks (called after the result of a check) | ||
* fall: number of fails to be considered down | ||
* rise: number of passes to be considered up | ||
Here are some | ||
examples of how you can use sensors and their strategies: | ||
*tcp* | ||
```yml | ||
strategy: tcp | ||
host: google.com | ||
port: 80 | ||
``` | ||
*http* | ||
```yml | ||
strategy: http | ||
url: https://www.google.com | ||
``` | ||
*pidfile* | ||
```yml | ||
strategy: pidfile | ||
pidfile: /var/pids/mysql.pid | ||
``` | ||
*redis* | ||
```yml | ||
strategy: redis | ||
host: localhost # defaults to localhost | ||
port: 6379 # defaults to 6379 | ||
command: [ 'exists', 'foo' ] | ||
``` | ||
*mysql* | ||
```yml | ||
strategy: mysql | ||
host: host # required | ||
user: user # required | ||
password: pass # required | ||
sql: "SELECT * FROM users LIMIT 1" # defaults to "SHOW TABLES" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,17 @@ | ||
var http = require('http'); | ||
var URL = require('url'); | ||
var request = require('request'); | ||
var URL = require('url'); | ||
|
||
module.exports = #(options) { | ||
var method = options.method || 'GET'; | ||
var url = URL.parse(options.url); | ||
|
||
var reqOptions = { | ||
host: url.hostname, | ||
method: method, | ||
port: url.port, | ||
path: url.path | ||
}; | ||
var newOpts = {}; | ||
newOpts.__proto__ = options; | ||
newOpts.url = URL.parse(options.url); | ||
|
||
return #(cb) { | ||
var req = http.request(reqOptions); | ||
|
||
req.on('response', #(res) { | ||
var code = res.statusCode; | ||
var data = ""; | ||
|
||
res.on('data', #(chunk) { data += chunk.toString(); }); | ||
res.on('end', #{ cb(code != 200, data) }); | ||
res.on('close', #(err) { cb(err) }); | ||
var req = request(newOpts, #(e, r, body) { | ||
if (e) return cb(e); | ||
var code = r.statusCode; | ||
if (parseInt(code) >= 400) return cb('error status code ' + code); | ||
cb(); | ||
}); | ||
|
||
req.on('error', #(err) { cb(err) }); | ||
req.end(); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module.exports = #(options) { | ||
var sql = options.query || "SHOW TABLES"; | ||
var mysql = require('mysql'); | ||
var conn = mysql.createConnection({ host: options.host, user: option.user, password: options.password }); | ||
conn.connect(); | ||
var conn = mysql.createClient(options); | ||
|
||
return #(cb) { | ||
conn.query(sql, #(err, rows, fields) { cb(err); }); | ||
conn.query(sql, #(err, rows, fields) { | ||
cb(err); | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters