-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
48 lines (41 loc) · 1.07 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict'
const io = require('@pm2/io')
const elasticsearch = require('elasticsearch')
const stats = require('./lib/stats')
const Actions = require('./lib/actions')
io.initModule({
widget: {
type: 'generic',
logo: 'https://www.elastic.co/static/img/logo-elastic.png',
theme: ['#39bdb1', '#1B2228', 'white', '#807C7C'],
el: {
probes: true,
actions: true
},
block: {
issues: true,
meta: true,
main_probes: ['Elastic status', 'Nodes', 'Shards', 'Indices', 'Documents', 'Store size']
}
}
}, function (err, conf) {
if (err) {
console.error(err)
return process.exit(1)
}
const ELASTICSEARCH_URI = conf.elasticsearchUri || process.env.PM2_ELASTICSEARCH_URI || 'localhost:9200'
const client = new elasticsearch.Client({
host: ELASTICSEARCH_URI,
log: 'error'
})
// init all probes
stats.init()
stats.update(client)
// start all workers
setInterval(function () {
return stats.update(client)
}, 1000)
// Register PMX actions
const actions = new Actions(client)
actions.register()
})