1 | #!/usr/bin/env node
|
2 | require('date-utils');
|
3 |
|
4 | var pingdom = require('./lib/pingdom');
|
5 | var config = require('./config');
|
6 |
|
7 | main();
|
8 |
|
9 | function main() {
|
10 | var api = pingdom(config);
|
11 |
|
12 | api.checks(function(err, checks) {
|
13 | var id;
|
14 |
|
15 | if(err) return console.error(err);
|
16 |
|
17 | id = checks[0].id;
|
18 |
|
19 | getResults(api, id)
|
20 | getPerformanceSummary(api, id);
|
21 | });
|
22 | }
|
23 |
|
24 | function getResults(api, check) {
|
25 | api.results(function(err, data, res) {
|
26 | if(err) return console.error(err);
|
27 |
|
28 | console.log('results', data, res.headers);
|
29 | }, {
|
30 | target: check,
|
31 | qs: {
|
32 | limit: 10
|
33 | }
|
34 | })
|
35 | }
|
36 |
|
37 | function getPerformanceSummary(api, check) {
|
38 | var now = Date.today();
|
39 | var weekAgo = now.clone().addWeeks(-1);
|
40 |
|
41 | api['summary.performance'](function(err, data, res) {
|
42 | if(err) return console.error(err);
|
43 |
|
44 | console.log('performance summary', data, res.headers);
|
45 | }, {
|
46 | target: check,
|
47 | qs: {
|
48 | from: weekAgo,
|
49 | to: now,
|
50 | resolution: 'day',
|
51 | includeuptime: true
|
52 | }
|
53 | });
|
54 | }
|