mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add open socket monitoring
This commit is contained in:
parent
86f220a2d2
commit
00c0036ca5
3 changed files with 21 additions and 1 deletions
|
@ -33,4 +33,5 @@ module.exports =
|
|||
|
||||
mongodb: require "./mongodb"
|
||||
http: require "./http"
|
||||
open_sockets: require "./open_sockets"
|
||||
|
||||
|
|
19
libraries/metrics/open_sockets.coffee
Normal file
19
libraries/metrics/open_sockets.coffee
Normal file
|
@ -0,0 +1,19 @@
|
|||
URL = require "url"
|
||||
seconds = 1000
|
||||
|
||||
module.exports = OpenSocketsMonitor =
|
||||
monitor: (logger) ->
|
||||
setInterval () ->
|
||||
OpenSocketsMonitor.gaugeOpenSockets()
|
||||
, 5 * seconds
|
||||
|
||||
gaugeOpenSockets: () ->
|
||||
Metrics = require "./metrics"
|
||||
for url, agents of require('http').globalAgent.sockets
|
||||
url = URL.parse("http://#{url}")
|
||||
hostname = url.hostname?.replace(/\./g, "_")
|
||||
Metrics.gauge "open_connections.http.#{hostname}", agents.length
|
||||
for url, agents of require('https').globalAgent.sockets
|
||||
url = URL.parse("https://#{url}")
|
||||
hostname = url.hostname?.replace(/\./g, "_")
|
||||
Metrics.gauge "open_connections.https.#{hostname}", agents.length
|
|
@ -4,7 +4,7 @@
|
|||
"description": "A drop-in metrics and monitoring module for node.js apps",
|
||||
"dependencies": {
|
||||
"lynx": "~0.1.1",
|
||||
"coffee-script": "~1.7.1",
|
||||
"coffee-script": "1.6.0",
|
||||
"underscore": "~1.6.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue