Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit a1d9c2c

Browse files
committed
Make port configurable to allow integrations
1 parent 9b9a5f4 commit a1d9c2c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

json2graphite.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def influx_metrics(data, timestamp, parent_key = nil)
294294
OptionParser.new do |opt|
295295
opt.on('--pattern PATTERN') { |o| $options[:pattern] = o }
296296
opt.on('--netcat HOST') { |o| $options[:host] = o }
297+
opt.on('--port PORT') { |p| $options[:port] = p }
297298
opt.on('--convert-to FORMAT') { |o| $options[:output_format] = o }
298299
opt.on('--server-tag SERVER_NAME') { |o| $options[:server_tag] = o }
299300

@@ -305,9 +306,11 @@ def influx_metrics(data, timestamp, parent_key = nil)
305306
url = case $options[:output_format]
306307
when 'influxdb'
307308
raise ArgumentError, "--influx-db must be passsed along with --netcat" unless $options[:influx_db]
308-
"http://#{$options[:host]}:8086/write?db=#{$options[:influx_db]}&precision=s"
309+
port = $options[:port] || "8086"
310+
"http://#{$options[:host]}:#{port}/write?db=#{$options[:influx_db]}&precision=s"
309311
else
310-
"tcp://#{$options[:host]}:2003"
312+
port = $options[:port] || "2003"
313+
"tcp://#{$options[:host]}:#{port}"
311314
end
312315

313316
$net_output = NetworkOutput.new(url)

0 commit comments

Comments
 (0)