-
Notifications
You must be signed in to change notification settings - Fork 17
/
jmx.js
60 lines (50 loc) · 1.53 KB
/
jmx.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
49
50
51
52
53
54
55
56
57
58
59
60
'use strict'
let cli = require('heroku-cli-util')
let co = require('co')
let parseBool = require('../lib/shared').parseBool
let withCluster = require('../lib/clusters').withCluster
let request = require('../lib/clusters').request
const VERSION = 'v0'
function * jmx (context, heroku) {
let enabled = parseBool(context.args.VALUE)
if (enabled === undefined) {
cli.exit(1, `Unknown value '${context.args.VALUE}': must be 'on' or 'enable' to enable, or 'off' or 'disable' to disable`)
}
let msg = `${enabled ? 'Enabling' : 'Disabling'} JMX access`
if (context.args.CLUSTER) {
msg += ` on ${context.args.CLUSTER}`
}
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.action(msg, co(function * () {
return yield request(heroku, {
method: 'POST',
body: {
enabled: enabled
},
path: `/data/kafka/${VERSION}/clusters/${addon.id}/jmx`
})
}))
})
}
module.exports = {
hidden: true,
topic: 'kafka',
command: 'jmx',
description: 'enable or disable JMX access to your Kafka cluster',
args: [
{ name: 'VALUE' },
{ name: 'CLUSTER', optional: true }
],
help: `
Enables or disables JMX access to your Kafka cluster. Note that
the JMX access available is read-only.
Examples:
$ heroku kafka:jmx on
$ heroku kafka:jmx HEROKU_KAFKA_BROWN_URL off
To check the JMX status of the cluster, see
$ heroku kafka:info
`,
needsApp: true,
needsAuth: true,
run: cli.command({preauth: true}, co.wrap(jmx))
}