@@ -42,6 +42,15 @@ const gatherOsMetrics = (io, span) => {
42
42
timestamp : Date . now ( )
43
43
}
44
44
45
+ const sendMetrics = ( span ) => {
46
+ io . emit ( 'stats' , {
47
+ os : span . os [ span . os . length - 2 ] ,
48
+ responses : span . responses [ span . responses . length - 2 ] ,
49
+ interval : span . interval ,
50
+ retention : span . retention
51
+ } )
52
+ }
53
+
45
54
pidusage . stat ( process . pid , ( err , stat ) => {
46
55
stat . memory = stat . memory / 1024 / 1024 // Convert from B to MB
47
56
stat . load = os . loadavg ( )
@@ -57,20 +66,12 @@ const gatherOsMetrics = (io, span) => {
57
66
} )
58
67
}
59
68
60
- const sendMetrics = ( span ) => {
61
- io . emit ( 'stats' , {
62
- os : span . os [ span . os . length - 2 ] ,
63
- responses : span . responses [ span . responses . length - 2 ] ,
64
- interval : span . interval ,
65
- retention : span . retention
66
- } )
67
- }
68
-
69
69
const middlewareWrapper = ( app , config ) => {
70
70
io = require ( 'socket.io' ) ( app )
71
71
Object . assign ( defaultConfig , config )
72
72
config = defaultConfig
73
- const indexHtml = fs . readFileSync ( 'index.html' , { 'encoding' : 'utf8' } )
73
+ const statusHtmlPage = config . statusHtmlPage || 'node_modules/koa-monitor/index.html'
74
+ const indexHtml = fs . readFileSync ( statusHtmlPage , { 'encoding' : 'utf8' } )
74
75
const template = handlebars . compile ( indexHtml )
75
76
76
77
io . on ( 'connection' , ( socket ) => {
0 commit comments