1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"

This commit is contained in:
Lars Kruse 2020-08-25 16:52:39 +02:00
parent 26c29daa2b
commit b0b39b018e
30 changed files with 1447 additions and 1384 deletions

View file

@ -31,7 +31,6 @@ require 'mechanize'
require 'digest/md5'
require 'nokogiri'
def output
nics = Hash.new
nics["LAN"] = Hash.new
@ -80,7 +79,7 @@ def output
j = 0
doc = Nokogiri::XML(clients_xml.to_s)
doc.xpath('//assoc').each do |assoc|
j+=1
j += 1
end
puts "wifi_assoc.value " + j.to_s
@ -89,7 +88,7 @@ def output
j = 0
doc = Nokogiri::XML(clients_xml.to_s)
doc.xpath('//client').each do |client|
j+=1
j += 1
end
puts "dhcp_clients.value " + j.to_s
@ -98,31 +97,31 @@ def output
clients_xml = agent.get("#{router_path}/wan_connection_status.xml").body
doc = Nokogiri::XML(clients_xml.to_s)
uptime = doc.children.search('wan_interface_up_time_0')[0].text
puts "uptime.value " + sprintf( "%.2f", (Float(uptime)/86400) )
puts "uptime.value " + sprintf("%.2f", (Float(uptime) / 86400))
# graph overall interface packets transferred per interval
puts "multigraph if_packets"
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "#{i}_recv.value " + nics[i]["packets_received"]
puts "#{i}_send.value " + nics[i]["packets_sent"]
end
# graph overall interface dropped packets per interval
puts "multigraph if_drop"
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "#{i}_recv.value " + nics[i]["rx_dropped"]
puts "#{i}_send.value " + nics[i]["tx_dropped"]
end
# graph overall interface collisions & errors per interval
puts "multigraph if_collerr"
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "#{i}_coll.value " + nics[i]["tx_collisions"]
puts "#{i}_err.value " + nics[i]["rx_errors"]
end
# graph stats for each interface
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "multigraph if_packets.#{i}"
puts "send.value " + nics[i]["packets_sent"]
puts "recv.value " + nics[i]["packets_received"]
@ -135,7 +134,6 @@ def output
end
end
def config
# build the configuration for graphs
puts "multigraph if_packets"
@ -143,7 +141,7 @@ def config
puts 'graph_category network'
puts 'graph_order LAN_recv LAN_send WAN_recv WAN_send WLAN_recv WLAN_send'
puts 'graph_vlabel packets in (-) / out (+) per ${graph_period}'
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "#{i}_recv.type DERIVE"
puts "#{i}_recv.graph no"
puts "#{i}_recv.min 0"
@ -158,7 +156,7 @@ def config
puts 'graph_category network'
puts 'graph_order LAN_recv LAN_send WAN_recv WAN_send WLAN_recv WLAN_send'
puts 'graph_vlabel packets / ${graph_period}'
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "#{i}_recv.type DERIVE"
puts "#{i}_recv.graph no"
puts "#{i}_recv.min 0"
@ -173,7 +171,7 @@ def config
puts 'graph_category network'
puts 'graph_order LAN_coll LAN_err WAN_coll WAN_err WLAN_coll WLAN_coll'
puts 'graph_vlabel packets / ${graph_period}'
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "#{i}_coll.label #{i} collisions"
puts "#{i}_coll.type DERIVE"
puts "#{i}_coll.min 0"
@ -201,7 +199,7 @@ def config
puts 'uptime.label uptime'
puts 'uptime.draw AREA'
for i in [ "LAN", "WAN", "WLAN" ] do
for i in ["LAN", "WAN", "WLAN"] do
puts "multigraph if_packets.#{i}"
puts "graph_title D-Link DIR-655 #{i} traffic"
puts 'graph_category network'
@ -244,7 +242,6 @@ def config
end
end
# main
if ARGV.length == 1 and ARGV[0] == 'config'
config()