Comparing version
@@ -15,49 +15,49 @@ 'use strict'; | ||
class Oppsy extends Events.EventEmitter { | ||
constructor(server, config) { | ||
constructor(server, config) { | ||
super(); | ||
config = config || {}; | ||
this._networkMonitor = new NetworkMonitor(server, config.httpAgents, config.httpsAgents); | ||
this._tasks = { | ||
osload: OsMonitor.loadavg, | ||
osmem: OsMonitor.mem, | ||
osup: OsMonitor.uptime, | ||
psup: ProcessMonitor.uptime, | ||
psmem: ProcessMonitor.memoryUsage, | ||
psdelay: ProcessMonitor.delay, | ||
requests: this._networkMonitor.requests, | ||
concurrents: this._networkMonitor.concurrents, | ||
responseTimes: this._networkMonitor.responseTimes, | ||
sockets: this._networkMonitor.sockets | ||
}; | ||
} | ||
super(); | ||
config = config || {}; | ||
this._networkMonitor = new NetworkMonitor(server, config.httpAgents, config.httpsAgents); | ||
this._tasks = { | ||
osload: OsMonitor.loadavg, | ||
osmem: OsMonitor.mem, | ||
osup: OsMonitor.uptime, | ||
psup: ProcessMonitor.uptime, | ||
psmem: ProcessMonitor.memoryUsage, | ||
psdelay: ProcessMonitor.delay, | ||
requests: this._networkMonitor.requests, | ||
concurrents: this._networkMonitor.concurrents, | ||
responseTimes: this._networkMonitor.responseTimes, | ||
sockets: this._networkMonitor.sockets | ||
}; | ||
} | ||
start(interval) { | ||
start(interval) { | ||
Hoek.assert(interval <= 2147483647, 'interval must be less than 2147483648'); | ||
const host = Os.hostname(); | ||
this._interval = setInterval(() => { | ||
Hoek.assert(interval <= 2147483647, 'interval must be less than 2147483648'); | ||
const host = Os.hostname(); | ||
this._interval = setInterval(() => { | ||
Items.parallel.execute(this._tasks, (error, results) => { | ||
Items.parallel.execute(this._tasks, (error, results) => { | ||
if (error) { | ||
this.emit('error', error); | ||
} | ||
else { | ||
results.host = host; | ||
this.emit('ops', results); | ||
} | ||
this._networkMonitor.reset(); | ||
}); | ||
}, interval); | ||
} | ||
if (error) { | ||
this.emit('error', error); | ||
} | ||
else { | ||
results.host = host; | ||
this.emit('ops', results); | ||
} | ||
this._networkMonitor.reset(); | ||
}); | ||
}, interval); | ||
} | ||
stop() { | ||
stop() { | ||
clearInterval(this._interval); | ||
this._networkMonitor.reset(); | ||
this.emit('stop'); | ||
} | ||
clearInterval(this._interval); | ||
this._networkMonitor.reset(); | ||
this.emit('stop'); | ||
} | ||
} | ||
module.exports = Oppsy; |
{ | ||
"name": "oppsy", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"repository": "git://github.com/hapijs/oppsy", | ||
@@ -21,9 +21,9 @@ "description": "An EventEmitter useful for collecting hapi server ops information", | ||
"code": "2.x.x", | ||
"hapi": "11.x.x", | ||
"lab": "7.x.x" | ||
"hapi": "13.x.x", | ||
"lab": "10.x.x" | ||
}, | ||
"dependencies": { | ||
"hoek": "3.x.x", | ||
"hoek": "4.x.x", | ||
"items": "2.x.x" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
31326
0.23%+ Added
- Removed
Updated