1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-08-06 22:23:21 +00:00

Ruby plugins: apply code changes as suggested by "rubocop --auto-correct"

This commit is contained in:
Lars Kruse 2020-08-25 17:06:15 +02:00
parent b0b39b018e
commit 809639ab65
33 changed files with 904 additions and 910 deletions

View file

@ -1,42 +1,40 @@
#!/usr/bin/env ruby
if $0 =~ /^(?:|.*\/)http_([^_]+)_/
host = $1
end
host = Regexp.last_match(1) if $0 =~ %r{^(?:|.*/)http_([^_]+)_}
abort "# Error: couldn't understand what I'm supposed to monitor." unless host
user = ENV['user'] || 'user'
password = ENV['password'] || 'user'
if (ARGV[0] == 'config')
if ARGV[0] == 'config'
puts "host_name #{host}" unless host == 'localhost'
puts "multigraph dsl_rate"
puts "graph_title DSL line speed"
puts "graph_args --base 1000 -l 0"
puts "graph_vlabel bps"
puts "graph_category network"
puts "downstream.label downstream"
puts "downstream.type GAUGE"
puts "downstream.min 0"
puts "downstream.cdef downstream,1000,*"
puts "upstream.label upstream"
puts "upstream.type GAUGE"
puts "upstream.min 0"
puts "upstream.cdef upstream,1000,*"
puts 'multigraph dsl_rate'
puts 'graph_title DSL line speed'
puts 'graph_args --base 1000 -l 0'
puts 'graph_vlabel bps'
puts 'graph_category network'
puts 'downstream.label downstream'
puts 'downstream.type GAUGE'
puts 'downstream.min 0'
puts 'downstream.cdef downstream,1000,*'
puts 'upstream.label upstream'
puts 'upstream.type GAUGE'
puts 'upstream.min 0'
puts 'upstream.cdef upstream,1000,*'
puts "multigraph dsl_snr"
puts "graph_title DSL SNR"
puts "graph_args --base 1000 -l 0"
puts "graph_vlabel dB"
puts "graph_scale no"
puts "graph_category network"
puts "downstream.label downstream"
puts "downstream.type GAUGE"
puts "downstream.min 0"
puts "upstream.label upstream"
puts "upstream.type GAUGE"
puts "upstream.min 0"
puts 'multigraph dsl_snr'
puts 'graph_title DSL SNR'
puts 'graph_args --base 1000 -l 0'
puts 'graph_vlabel dB'
puts 'graph_scale no'
puts 'graph_category network'
puts 'downstream.label downstream'
puts 'downstream.type GAUGE'
puts 'downstream.min 0'
puts 'upstream.label upstream'
puts 'upstream.type GAUGE'
puts 'upstream.min 0'
exit 0
end
@ -56,21 +54,21 @@ class TPAdslStats
def field_values(label)
if @html =~ />#{label}.*?<td>([0-9.]+).*?([0-9.]+)/m
[$1, $2]
[Regexp.last_match(1), Regexp.last_match(2)]
else
['U', 'U']
%w[U U]
end
end
end
stats = TPAdslStats.new(host, user, password)
puts "multigraph dsl_rate"
puts 'multigraph dsl_rate'
rate = stats.field_values('Rate')
puts "downstream.value #{rate[0]}"
puts "upstream.value #{rate[1]}"
puts "multigraph dsl_snr"
puts 'multigraph dsl_snr'
snr = stats.field_values('SNR')
puts "downstream.value #{snr[0]}"
puts "upstream.value #{snr[1]}"