Projet

Général

Profil

Révision b0b39b01

IDb0b39b018e200cd0b771675fd0a6489f6ee9f045
Parent 26c29daa
Enfant 809639ab

Ajouté par Lars Kruse il y a plus de 5 ans

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

Voir les différences:

plugins/router/d-link-dir-655-router-statistics-plugin
31 31
require 'digest/md5'
32 32
require 'nokogiri'
33 33

  
34

  
35 34
def output
36 35
  nics = Hash.new
37 36
  nics["LAN"] = Hash.new
......
80 79
  j = 0
81 80
  doc = Nokogiri::XML(clients_xml.to_s)
82 81
  doc.xpath('//assoc').each do |assoc|
83
    j+=1
82
    j += 1
84 83
  end
85 84
  puts "wifi_assoc.value " + j.to_s
86 85

  
......
89 88
  j = 0
90 89
  doc = Nokogiri::XML(clients_xml.to_s)
91 90
  doc.xpath('//client').each do |client|
92
    j+=1
91
    j += 1
93 92
  end
94 93
  puts "dhcp_clients.value " + j.to_s
95 94

  
......
98 97
  clients_xml = agent.get("#{router_path}/wan_connection_status.xml").body
99 98
  doc = Nokogiri::XML(clients_xml.to_s)
100 99
  uptime = doc.children.search('wan_interface_up_time_0')[0].text
101
  puts "uptime.value " + sprintf( "%.2f", (Float(uptime)/86400) )
100
  puts "uptime.value " + sprintf("%.2f", (Float(uptime) / 86400))
102 101

  
103 102
  # graph overall interface packets transferred per interval
104 103
  puts "multigraph if_packets"
105
  for i in [ "LAN", "WAN", "WLAN" ] do
104
  for i in ["LAN", "WAN", "WLAN"] do
106 105
    puts "#{i}_recv.value " + nics[i]["packets_received"]
107 106
    puts "#{i}_send.value " + nics[i]["packets_sent"]
108 107
  end
109 108

  
110 109
  # graph overall interface dropped packets per interval
111 110
  puts "multigraph if_drop"
112
  for i in [ "LAN", "WAN", "WLAN" ] do
111
  for i in ["LAN", "WAN", "WLAN"] do
113 112
    puts "#{i}_recv.value " + nics[i]["rx_dropped"]
114 113
    puts "#{i}_send.value " + nics[i]["tx_dropped"]
115 114
  end
116 115

  
117 116
  # graph overall interface collisions & errors per interval
118 117
  puts "multigraph if_collerr"
119
  for i in [ "LAN", "WAN", "WLAN" ] do
118
  for i in ["LAN", "WAN", "WLAN"] do
120 119
    puts "#{i}_coll.value " + nics[i]["tx_collisions"]
121 120
    puts "#{i}_err.value " + nics[i]["rx_errors"]
122 121
  end
123 122

  
124 123
  # graph stats for each interface
125
  for i in [ "LAN", "WAN", "WLAN" ] do
124
  for i in ["LAN", "WAN", "WLAN"] do
126 125
    puts "multigraph if_packets.#{i}"
127 126
    puts "send.value " + nics[i]["packets_sent"]
128 127
    puts "recv.value " + nics[i]["packets_received"]
......
135 134
  end
136 135
end
137 136

  
138

  
139 137
def config
140 138
  # build the configuration for graphs
141 139
  puts "multigraph if_packets"
......
143 141
  puts 'graph_category network'
144 142
  puts 'graph_order LAN_recv LAN_send WAN_recv WAN_send WLAN_recv WLAN_send'
145 143
  puts 'graph_vlabel packets in (-) / out (+) per ${graph_period}'
146
  for i in [ "LAN", "WAN", "WLAN" ] do
144
  for i in ["LAN", "WAN", "WLAN"] do
147 145
    puts "#{i}_recv.type DERIVE"
148 146
    puts "#{i}_recv.graph no"
149 147
    puts "#{i}_recv.min 0"
......
158 156
  puts 'graph_category network'
159 157
  puts 'graph_order LAN_recv LAN_send WAN_recv WAN_send WLAN_recv WLAN_send'
160 158
  puts 'graph_vlabel packets / ${graph_period}'
161
  for i in [ "LAN", "WAN", "WLAN" ] do
159
  for i in ["LAN", "WAN", "WLAN"] do
162 160
    puts "#{i}_recv.type DERIVE"
163 161
    puts "#{i}_recv.graph no"
164 162
    puts "#{i}_recv.min 0"
......
173 171
  puts 'graph_category network'
174 172
  puts 'graph_order LAN_coll LAN_err WAN_coll WAN_err WLAN_coll WLAN_coll'
175 173
  puts 'graph_vlabel packets / ${graph_period}'
176
  for i in [ "LAN", "WAN", "WLAN" ] do
174
  for i in ["LAN", "WAN", "WLAN"] do
177 175
    puts "#{i}_coll.label #{i} collisions"
178 176
    puts "#{i}_coll.type DERIVE"
179 177
    puts "#{i}_coll.min 0"
......
201 199
  puts 'uptime.label uptime'
202 200
  puts 'uptime.draw AREA'
203 201

  
204
  for i in [ "LAN", "WAN", "WLAN" ] do
202
  for i in ["LAN", "WAN", "WLAN"] do
205 203
    puts "multigraph if_packets.#{i}"
206 204
    puts "graph_title D-Link DIR-655 #{i} traffic"
207 205
    puts 'graph_category network'
......
244 242
  end
245 243
end
246 244

  
247

  
248 245
# main
249 246
if ARGV.length == 1 and ARGV[0] == 'config'
250 247
  config()

Formats disponibles : Unified diff