Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / network / ubiquiti_airfiber_ @ a8cf8e1d

Historique | Voir | Annoter | Télécharger (22,2 ko)

1
#!/usr/bin/perl
2
#######################################################################################################
3
#
4
# Multigraph munin plugin to monitor Ubiquiti AirOS F (airFiber) devices various parameters. It needs
5
# Perl's Net::Telnet or Net::OpenSSH to be able to connect.
6
#
7
# To use this plugin, copy it to the munin's plugin directory (eg. /usr/share/munin/plugins) 
8
# under the name "ubiquiti_airfiber_". Don't change this filename! Follow these steps:
9
#
10
# 1. Give names to your devices, in fqdn style. Like "master.wlan" or  "slave.wlan". To make the
11
#    system understand that, add them to your /etc/hosts file, like below:
12
#    192.168.2.2	master.wlan
13
#    192.168.2.3	slave.wlan
14
#    You could of course add these to your network's local DNS server if you want to.
15
#
16
# 2. Then symlink it to munin's configured plugins directory (eg. /etc/munin/plugins) with names
17
#    according to the devices you wish to monitor, eg:
18
#    ubiquiti_airfiber_master.wlan
19
#    ubiquiti_airfiber_slave.wlan
20
#
21
#    Important: make sure to use the same names in your symlinks and other config places!
22
#
23
# 3. In /etc/munin/plugin-conf.d/munin-node add the following, to be able to contact
24
#    those devices via telnet (obviously replacing these with your own data):
25
# 
26
#    [ubiquiti_airos_master.wlan]
27
#    user root			# User and Group are required only if using any of the SSH modes to store
28
#    group root			# the keys in /root/.ssh directory (or any user with homedir and shell)
29
#    env.NetMode Telnet         # Connection mode, can be 'Telnet' or 'SSHPass' or 'SSHKey'
30
#    env.Port 23		# Port of the Telnet service configured in AirOS F web interface
31
#    env.User foobar		# Username to log in
32
#    env.Pass raboof		# Password to log in
33
#    env.PingAddr 192.168.2.3	# An IP address to ping, typically the other wireless device or a gateway
34
#    env.PingName slave.wlan	# Friendly name of the pinged device, to display on the ping graph
35
#
36
#    [ubiquiti_airos_slave.wlan]
37
#    user root
38
#    group root
39
#    env.NetMode SSHPass
40
#    env.Port 22
41
#    env.User foobar
42
#    env.Pass raboof
43
#    env.PingAddr 192.168.2.2
44
#    env.PingName master.wlan
45
#
46
# 4. In /etc/munin/munin.conf add them as new virtual nodes:
47
#
48
#    [master.wlan]
49
#        address 127.0.0.1
50
#
51
#    [slave.wlan]
52
#        address 127.0.0.1
53
#
54
# 5. Restart the munin node by 'service munin-node restart'.
55
#
56
#    If all went well, after 5 minutes or so you should have two additional nodes listed 
57
#    on the Web Interface of munin.
58
#
59
# To use the script with public keys authentication and no password, set env.NetMode SSHkey, and 
60
# create a pair of keys using command 'sudo ssh-keygen -t rsa'. This will generate in /root/.ssh 
61
# directory two files, id_rsa and id_rsa.pub. Upload id_rsa.pub to your Ubiquiti device using 
62
# Services > SSH Server > Authorized Keys window. Try to log in to the device by command line
63
# first ('sudo ssh foobar@slave.wlan'), to save the RSA key fingerprint in the root account.
64
#
65
# Plugin based on my similar one for AirMax devices:
66
# http://community.ubnt.com/t5/airOS-Software-Configuration/Updated-airOS-plugin-for-Munin-monitoring/td-p/469169
67
#
68
# Tested & working with munin v.2.0.14 and AirOS F v1.1.2.
69
# Created in 2013 by robi
70
#  v0.3 - added SSH support and saved some memory, thanks to NVX@UbiquitiNetworksCommunity
71
#  v0.2 - cleared up stuff related to naming and added ping graphs from munin-node
72
#  v0.1 - initial version, based on ubiquiti_airos_ v0.7.
73
##############################################################################
74
## Magic Markers
75
 #%# family=manual
76
##############################################################################
77
use diagnostics;
78
use strict;
79
use warnings;
80
##############################################################################
81
## Receive environmentals and load required modules
82
my $NetMode = $ENV{'NetMode'};
83
if ($NetMode =~ /Telnet/) {
84
  use Net::Telnet;
85
} 
86
elsif ($NetMode =~ /SSH/) {
87
  use Net::OpenSSH;
88
}
89
my $Port = $ENV{'Port'};
90
my $User = $ENV{'User'};
91
my $Pass = $ENV{'Pass'};
92
my $PingAddr = $ENV{'PingAddr'};
93
my $PingName = $ENV{'PingName'};
94
my $HostLo = qx("hostname");
95
chomp ($HostLo);
96
##############################################################################
97
## Define variables
98
my $graph_period = "second";
99
my ($load, $uptime, $ping_time, $packet_loss, $cpuuser, $cpusystem, $cpunice, $cpuidle, $cpuiowait, $cpuirq, $cpusoftirq, $ping_timelo, $packet_losslo);
100
my ($rxrate, $txrate, $rxpower0, $rxpower1, $powerout, $feet, $dist, $temp0, $temp1);
101
my ($rssi0, $rssi1, $baseline, $fade, $txfreq, $rxfreq, $txmodrate, $speed);
102
$load = $uptime = $ping_time = $packet_loss = $cpuuser = $cpusystem = $cpunice = $cpuidle = $cpuiowait = $cpuirq = $cpusoftirq = $ping_timelo = $packet_losslo = "U";
103
$rxrate = $txrate = $rxpower0 = $rxpower1 = $powerout = $feet = $dist = $temp0 = $temp1 = "U";
104
$rssi0 = $rssi1 = $baseline = $fade = $txfreq = $rxfreq = $txmodrate = $speed = "U";
105
###############################################################################
106
## Determine Hostname and other stuff
107
my $Hostname = undef;
108
$0 =~ /ubiquiti_airfiber_(.+)*$/;
109
unless ($Hostname = $1) {
110
  exit 2;
111
}
112
if ($PingAddr // "") {
113
  if (!($PingName // "")) {
114
    $PingName = $PingAddr;
115
  }
116
}
117
###############################################################################
118
## Configuration
119
if(exists $ARGV[0] and $ARGV[0] eq "config") {
120
  print "multigraph airos_wrate\n";
121
  print "host_name " . $Hostname . "\n";
122
  print "graph_category radio\n";
123
  print "graph_title Wireless link capacity\n";
124
  print "graph_order rxrate txrate\n";
125
  print "graph_period " . $graph_period . "\n";
126
  print "graph_vlabel RX (-) / TX (+) bps\n";
127
  print "graph_info This graph shows the wireless link data transfer capacity as seen on " . $Hostname . ".\n";
128
  print "rxrate.label RX/TX Capacity\n";
129
  print "rxrate.graph no\n";
130
  print "txrate.label bps\n";
131
  print "txrate.draw AREA\n";
132
  print "txrate.negative rxrate\n";
133
  print "\n";
134

    
135
  print "multigraph airos_load\n";
136
  print "host_name " . $Hostname . "\n";
137
  print "graph_args --base 1000 -l 0 \n";
138
  print "graph_title Load average\n";
139
  print "graph_vlabel load\n";
140
  print "graph_category system\n";
141
  print "graph_scale no\n";
142
  print "load.label load\n";
143
  print "load.critical 10\n";
144
  print "graph_info The load average of " . $Hostname . " describes how many processes are in the run-queue (scheduled to run 'immediately').\n";
145
  print "load.info 5 minute load average\n";
146
  print "\n";
147

    
148
  print "multigraph airos_uptime\n";
149
  print "host_name " . $Hostname . "\n";
150
  print "graph_args --base 1000 -l 0 \n";
151
  print "graph_title Uptime\n";
152
  print "graph_vlabel uptime in days\n";
153
  print "graph_category system\n";
154
  print "graph_scale no\n";
155
  print "uptime.label uptime\n";
156
  print "uptime.draw AREA\n";
157
  print "graph_info This graph shows how many days have passed since the bootup of " . $Hostname . ".\n";
158
  print "\n";
159

    
160
  print "multigraph airos_dbm\n";
161
  print "host_name " . $Hostname . "\n";
162
  print "graph_args --base 1000\n";
163
  print "graph_title Signal levels\n";
164
  print "graph_vlabel dBm\n";
165
  print "graph_category radio\n";
166
  print "graph_info This graph shows the radio signal strengths of " . $Hostname . " in dBm.\n";
167
  print "rxpower0.label Chain 0 Signal Strength dBm\n";
168
  print "rxpower1.label Chain 1 Signal Strength dBm\n";
169
  print "\n";
170

    
171
  print "multigraph airos_powerout\n";
172
  print "host_name " . $Hostname . "\n";
173
  print "graph_title Output Power\n";
174
  print "graph_vlabel dBm\n";
175
  print "graph_args --base 1000 --lower-limit 0\n";
176
  print "graph_category radio\n";
177
  print "graph_info This graph shows the output power of " . $Hostname . " radio transmitter in dBm.\n";
178
  print "powerout.label Output Power\n";
179
  print "\n";
180

    
181
  print "multigraph airos_freq\n";
182
  print "host_name " . $Hostname . "\n";
183
  print "graph_args --base 1000 --units-exponent 0 --lower-limit 24.0 --upper-limit 24.3 --rigid --alt-y-grid\n";
184
  print "graph_title Frequency\n";
185
  print "graph_vlabel GHz\n";
186
  print "graph_category radio\n";
187
  print "graph_info This graph shows the operating frequencies of " . $Hostname . ".\n";
188
  print "graph_scale no\n";
189
  print "txfreq.label TX Frequency\n";
190
  print "rxfreq.label RX Frequency\n";
191
  print "\n";
192

    
193
  print "multigraph airos_dist\n";
194
  print "host_name " . $Hostname . "\n";
195
  print "graph_args --base 1000\n";
196
  print "graph_title Distance\n";
197
  print "graph_vlabel meters\n";	#converted to meters below in the code
198
  print "graph_category radio\n";
199
  print "graph_info This graph shows the calculated link distance seen from " . $Hostname . ".\n";
200
  print "dist.label Distance\n";
201
  print "\n";
202

    
203
  print "multigraph airos_temp\n";
204
  print "host_name " . $Hostname . "\n";
205
  print "graph_args --base 1000\n";
206
  print "graph_title Internal Temperature\n";
207
  print "graph_vlabel Degrees Celsius\n";
208
  print "graph_category system\n";
209
  print "graph_info This graph shows the internal temperature of " . $Hostname . ".\n";
210
  print "temp0.label Temp0\n";
211
  print "temp1.label Temp1\n";
212
  print "\n";
213

    
214
  print "multigraph airos_rssi\n";
215
  print "host_name " . $Hostname . "\n";
216
  print "graph_args  --base 1000\n";
217
  print "graph_title Signal levels (RSSI)\n";
218
  print "graph_vlabel %\n";
219
  print "graph_category radio\n";
220
  print "graph_info This graph shows the received signal strength indication on " . $Hostname . " in percent.\n";
221
  print "rssi0.label Chain 0 Signal Strength %\n";
222
  print "rssi1.label Chain 1 Signal Strength %\n";
223
  print "\n";
224

    
225
  print "multigraph airos_baseline\n";
226
  print "host_name " . $Hostname . "\n";
227
  print "graph_args --base 1000\n";
228
  print "graph_title Baseline\n";
229
  print "graph_category radio\n";
230
  print "graph_info Baseline on " . $Hostname . ".\n";
231
  print "baseline.label Baseline\n";
232
  print "\n";
233

    
234
  print "multigraph airos_fade\n";
235
  print "host_name " . $Hostname . "\n";
236
  print "graph_args --base 1000\n";
237
  print "graph_title Fade\n";
238
  print "graph_category radio\n";
239
  print "graph_info Fade on " . $Hostname . ".\n";
240
  print "fade.label Fade\n";
241
  print "\n";
242

    
243
  print "multigraph airos_modrate\n";
244
  print "host_name " . $Hostname . "\n";
245
  print "graph_args --base 1000 --lower-limit -1 --upper-limit 7 --rigid --alt-y-grid\n";
246
  print "graph_title Modulation Rate\n";
247
  print "graph_vlabel x\n";
248
  print "graph_category radio\n";
249
  print "graph_info Current and Maximum possible Modulation Rate on " . $Hostname . ". Possible values: 6x (64QAM MIMO), 4x (16QAM MIMO), 2x (QPSK MIMO), 1x (QPSK SISO), 0x (1/4 QPSK SISO).\n";
250
  print "speed.label (maximum)x\n";
251
  print "txmodrate.label (current)x\n";
252
  print "\n";
253

    
254
  print "multigraph airos_cpu\n";
255
  print "host_name " . $Hostname . "\n";
256
  print "graph_args -l 0 --lower-limit 0 --upper-limit 100\n";
257
  print "graph_title CPU usage\n";
258
  print "graph_vlabel %\n";
259
  print "graph_category system\n";
260
  print "graph_info This graph shows how CPU time is spent in " . $Hostname . ".\n";
261
  print "graph_scale no\n";
262
  print "graph_period second\n";
263
  print "graph_order system user nice iowait irq softirq idle\n";
264
  print "system.label cpu-system\n";
265
  print "system.draw AREA\n";
266
  print "system.min 0\n";
267
  print "system.info CPU time spent by the kernel in system activities in " . $Hostname . ".\n";
268
  print "user.label cpu-user\n";
269
  print "user.draw STACK\n";
270
  print "user.min 0\n";
271
  print "user.info CPU time spent by normal programs and daemons in " . $Hostname . ".\n";
272
  print "nice.label cpu-nice\n";
273
  print "nice.draw STACK\n";
274
  print "nice.min 0\n";
275
  print "nice.info CPU time spent by nice(1)d programs in " . $Hostname . ".\n";
276
  print "idle.label cpu-idle\n";
277
  print "idle.draw STACK\n";
278
  print "idle.min 0\n";
279
  print "idle.info Idle CPU time in " . $Hostname . ".\n";
280
  print "iowait.label cpu-iowait\n";
281
  print "iowait.draw STACK\n";
282
  print "iowait.min 0\n";
283
  print "iowait.info CPU time spent waiting for I/O operations to finish when there is nothing else to do in " . $Hostname . ".\n";
284
  print "irq.label cpu-irq\n";
285
  print "irq.draw STACK\n";
286
  print "irq.min 0\n";
287
  print "irq.info CPU time spent handling interrupts in " . $Hostname . ".\n";
288
  print "softirq.label cpu-softirq\n";
289
  print "softirq.draw STACK\n";
290
  print "softirq.min 0\n";
291
  print "softirq.info CPU time spent handling batched interrupts in " . $Hostname . ".\n";
292
  print "\n";
293

    
294
  if ($PingAddr // "") {
295
    print "multigraph airos_ping1\n";
296
    print "host_name " . $Hostname . "\n";
297
    print "graph_title Ping times from " . $Hostname . " to " . $PingName . "\n";
298
    print "graph_args --base 1000 -l 0\n";
299
    print "graph_vlabel roundtrip time (seconds)\n";
300
    print "graph_category network\n";
301
    print "graph_info This graph shows ping RTT statistics, measured on " . $Hostname . " against " . $PingName . ". If you configure here the other end of the wireless link this graph will show you the pure latency of the wireless segment, without any etra latencies introduced by other network elements or segments.\n";
302
    print "ping.label " . $PingName . "\n";
303
    print "ping.info Ping RTT statistics for " . $PingName . ".\n";
304
    print "packetloss.graph no\n";
305
    print "packetloss.critical 0:0\n";
306
    print "\n";
307
  }
308

    
309
  print "multigraph airos_pinglo_ping\n";
310
  print "host_name " . $Hostname . "\n";
311
  print "graph_title Ping times to " . $Hostname . "\n";
312
  print "graph_args --base 1000 -l 0\n";
313
  print "graph_vlabel roundtrip time (seconds)\n";
314
  print "graph_category network\n";
315
  print "graph_info This graph shows ping RTT statistics, measured on the munin-node " . $HostLo . " against " . $Hostname . ".\n";
316
  print "ping.label " . $Hostname . "\n";
317
  print "ping.info Ping RTT statistics for " . $Hostname . ".\n";
318
  print "\n";
319

    
320
  print "multigraph airos_pinglo_loss\n";
321
  print "host_name " . $Hostname . "\n";
322
  print "graph_title Ping packet loss to " . $Hostname . "\n";
323
  print "graph_args --base 1000 -l 0\n";
324
  print "graph_vlabel %\n";
325
  print "graph_category network\n";
326
  print "graph_info This graph shows ping packet loss, measured on the munin-node " . $HostLo . " against " . $Hostname . ". If this is anything above 0, there may be problems with the network connection, or the devices are unreachable.\n";
327
  print "packetloss.label " . $Hostname . "\n";
328
  print "packetloss.info Packet loss for " . $Hostname . ".\n";
329
  print "packetloss.critical 0:0\n";
330
  print "\n";
331

    
332
  exit;
333
}
334
###############################################################################
335
my $CM;
336
my $SSH;
337

    
338
if ($NetMode =~ /Telnet/) {
339
  ## Initiate Telnet Session
340
  $CM = Net::Telnet->new(Port  => $Port,
341
                         Prompt=> '/ $/',
342
                         Timeout=>10,
343
                         Errmode=>'return');
344
  $CM->open($Hostname);
345

    
346
  if (!defined($CM->login($User, $Pass))) {
347
    &printResults(); # Nothing happens, except printing undefined results to munin
348
  }
349
}
350

    
351
elsif ($NetMode =~ /SSHPass/) {
352
  ## Initiate SSH Session using password authentication
353
  $SSH = Net::OpenSSH->new($Hostname, 
354
                           port => $Port,
355
                           user => $User, 
356
                           password => $Pass,
357
                           timeout => 10,
358
#                           master_stderr_discard => 1,
359
                           master_opts => [-o => "StrictHostKeyChecking=no"]);
360
  $SSH->error and 
361
  #  warn "Couldn't establish SSH connection: " . $SSH->error;
362
    &printResults(); # Nothing happens, except printing undefined results to munin
363
}
364

    
365
elsif ($NetMode =~ /SSHKey/) {
366
  ## Initiate SSH Session using public key authentication  
367
  $SSH = Net::OpenSSH->new($Hostname,
368
                           port => $Port,
369
                           user => $User,
370
                           timeout => 10,
371
#                           master_stderr_discard => 1,
372
                           master_opts => [-o => "StrictHostKeyChecking=no"]);
373
  $SSH->error and
374
  #  warn "Couldn't establish SSH connection: " . $SSH->error;
375
    &printResults(); # Nothing happens, except printing undefined results to munin
376
}
377

    
378
###############################################################################
379
## Execution
380
my @Out;
381

    
382
if ($NetMode =~ /Telnet/) {
383
  @Out = $CM->cmd("cat /proc/loadavg");
384
}
385
elsif ($NetMode =~ /SSH/) {
386
  @Out = $SSH->capture("cat /proc/loadavg");
387
}
388
foreach my $Line (@Out) {
389
  if ($Line !~ /XM.v/ && $Line =~ m/(\d+)/) {
390
    	$load = substr($Line, 0,4);
391
  }
392
}
393

    
394

    
395
my $topcmd = "top -b -n2 -d1 | grep '^CPU:' | tail -n1";
396
if ($NetMode =~ /Telnet/) {
397
  @Out = $CM->cmd($topcmd);
398
}
399
elsif ($NetMode =~ /SSH/) {
400
  @Out = $SSH->capture($topcmd);
401
}
402
chomp @Out;
403
my $OutCPU = join(" ", @Out);
404
my $recpu=".*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+)";
405
if ($OutCPU =~ m/$recpu/is) {
406
  $cpuuser=$1;
407
  $cpusystem=$2;
408
  $cpunice=$3;
409
  $cpuiowait=$5;
410
  $cpuirq=$6;
411
  $cpusoftirq=$7;
412
  $cpuidle=100 - $cpuuser - $cpusystem - $cpunice - $cpuiowait - $cpuirq - $cpusoftirq; #=$4
413
}
414

    
415
sleep 1;
416

    
417
if ($NetMode =~ /Telnet/) {
418
  @Out = $CM->cmd("cat /proc/uptime");
419
}
420
elsif ($NetMode =~ /SSH/) {
421
  @Out = $SSH->capture("cat /proc/uptime");
422
}
423

    
424
foreach my $Line (@Out) {
425
  if ($Line !~ /XM.v/ && $Line =~ m/(\d+)/) {
426
	$uptime = $1 / 86400;
427
  }
428
}
429

    
430

    
431
my $fibcmd = q[af af, | awk '{FS = "," ; x=1; t=1; while (t <= NF){ t++; print $x "=" $t; x+=2; t++;}}'];
432

    
433

    
434
if ($NetMode =~ /Telnet/) {
435
  @Out = $CM->cmd($fibcmd);
436
}
437
elsif ($NetMode =~ /SSH/) {
438
  @Out = $SSH->capture($fibcmd);
439
}
440

    
441
foreach my $Line (@Out) {
442
    if ($Line =~ /rxcapacity/ && $Line =~ m/(.\d+)/) {
443
        $rxrate = substr($Line, 11);
444
        if ($rxrate == 0) {
445
            $rxrate = "U";
446
        }
447
    }
448
    if ($Line =~ /txcapacity/ && $Line =~ m/(.\d+)/) {
449
        $txrate = substr($Line, 11);
450
        if ($txrate == 0) {
451
            $txrate = "U";
452
        }
453
    }
454
    if ($Line =~ /rxpower0/ && $Line !~ /rrx/ && $Line =~ m/(.\d+)/) {
455
        $rxpower0 = substr($Line, 9);
456
    }
457
    if ($Line =~ /rxpower1/ && $Line !~ /rrx/ && $Line =~ m/(.\d+)/) {
458
        $rxpower1 = substr($Line, 9);
459
    }
460
    if ($Line =~ /powerout/ && $Line !~ /rpo/ && $Line =~ m/(.\d+)/) {
461
        $powerout = substr($Line, 9);
462
    }
463
    if ($Line =~ /feet/ && $Line =~ m/(.\d+)/) {
464
        $feet = substr($Line, 5);
465
        if ($feet == 0) {
466
            $feet = "U";
467
        } else {
468
	    $dist = $feet/3.28084; # conversion to meters
469
	}
470
    }
471
    if ($Line =~ /temp0/ && $Line =~ m/(.\d+)/) {
472
        $temp0 = substr($Line, 6);
473
    }
474
    if ($Line =~ /temp1/ && $Line =~ m/(.\d+)/) {
475
        $temp1 = substr($Line, 6);
476
    }
477
    if ($Line =~ /rssi0/ && $Line =~ m/(.\d+)/) {
478
        $rssi0 = substr($Line, 6);
479
    }
480
    if ($Line =~ /rssi1/ && $Line =~ m/(.\d+)/) {
481
        $rssi1 = substr($Line, 6);
482
    }
483
    if ($Line =~ /baseline/ && $Line =~ m/(.\d+)/) {
484
        $baseline = substr($Line, 9);
485
    }
486
    if ($Line =~ /fade/ && $Line =~ m/(.\d+)/) {
487
        $fade = substr($Line, 5);
488
    }
489
    if ($Line =~ /txfrequency/ && $Line =~ m/(.\d+)/) {
490
        $txfreq = substr($Line, 12);
491
	$txfreq =~ s/GHz//;
492
    }
493
    if ($Line =~ /rxfrequency/ && $Line =~ m/(.\d+)/) {
494
        $rxfreq = substr($Line, 12);
495
	$rxfreq =~ s/GHz//;
496
    }
497
    if ($Line =~ /txmodrate/ && $Line !~ /rtx/ && $Line =~ m/(.\d+)/) {
498
        $txmodrate = substr($Line, 10);
499
	$txmodrate =~ s/x//;
500
        if ($txmodrate == 0) {
501
            $txmodrate = "U";
502
        }
503
    }
504
    if ($Line =~ /speed/ && $Line =~ m/(.\d+)/) {
505
        $speed = substr($Line, 6);
506
	$speed =~ s/x//;
507
        if ($speed == 0) {
508
            $speed = "U";
509
        }
510
    }
511

    
512
}
513
sleep 1;
514
if ($PingAddr // "") {
515
  my $pingcmd = "ping -c 2 " . $PingAddr . " 2>/dev/null";
516
  if ($NetMode =~ /Telnet/) {
517
    @Out = $CM->cmd($pingcmd);
518
  }
519
  elsif ($NetMode =~ /SSH/) {
520
    @Out = $SSH->capture($pingcmd);
521
  }
522
    chomp @Out;
523
    my $ping = join(" ", @Out);
524
    $ping_time = ($1 / 1000) if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
525
    $packet_loss = $1 if ($ping =~ /(\d+)% packet loss/);
526
  } else {
527
    $PingName = "";
528
    $PingAddr = "";
529
}
530

    
531

    
532
if ($NetMode =~ /Telnet/) {
533
  $CM->close;
534
}
535

    
536
my $pingcmdlo = "ping -c 2 " . $Hostname . " 2>/dev/null";
537
my @pinglo = qx($pingcmdlo);
538
chomp @pinglo;
539
my $pinglo = join(" ", @pinglo);
540
$ping_timelo = ($1 / 1000) if ($pinglo =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
541
$packet_losslo = $1 if ($pinglo =~ /(\d+)% packet loss/);
542

    
543

    
544
chomp($load, $uptime, $ping_time, $packet_loss, $cpuuser, $cpusystem, $cpunice, $cpuidle, $cpuiowait, $cpuirq, $cpusoftirq, $ping_timelo, $packet_losslo, 
545
	$rxrate, $txrate, $rxpower0, $rxpower1, $powerout, $feet, $dist, $temp0, $temp1, 
546
	$rssi0, $rssi1, $baseline, $fade, $txfreq, $rxfreq, $txmodrate, $speed);
547

    
548
&printResults();
549

    
550
sub printResults {
551

    
552
  print "\n";
553

    
554
  print "multigraph airos_wrate\n";
555
  print "txrate.value " . $txrate . "\n";
556
  print "rxrate.value " . $rxrate . "\n";
557
  print "\n";
558

    
559
  print "multigraph airos_dbm\n";
560
  print "rxpower0.value " . $rxpower0 . "\n";
561
  print "rxpower1.value " . $rxpower1 . "\n";
562
  print "\n";
563

    
564
  print "multigraph airos_powerout\n";
565
  print "powerout.value " . $powerout . "\n";
566
  print "\n";
567

    
568
  print "multigraph airos_freq\n";
569
  print "txfreq.value " . $txfreq . "\n";
570
  print "rxfreq.value " . $rxfreq . "\n";
571
  print "\n";
572

    
573
  print "multigraph airos_dist\n";
574
  print "dist.value " . $dist . "\n";
575
  print "\n";
576

    
577
  print "multigraph airos_temp\n";
578
  print "temp0.value " . $temp0 . "\n";
579
  print "temp1.value " . $temp1 . "\n";
580
  print "\n";
581

    
582
  print "multigraph airos_rssi\n";
583
  print "rssi0.value " . $rssi0 . "\n";
584
  print "rssi1.value " . $rssi1 . "\n";
585
  print "\n";
586

    
587
  print "multigraph airos_baseline\n";
588
  print "baseline.value " . $baseline . "\n";
589
  print "\n";
590

    
591
  print "multigraph airos_fade\n";
592
  print "fade.value " . $fade . "\n";
593
  print "\n";
594

    
595
  print "multigraph airos_modrate\n";
596
  print "speed.value " . $speed . "\n";
597
  print "txmodrate.value " . $txmodrate . "\n";
598
  print "\n";
599

    
600
  print "multigraph airos_load\n";
601
  print "load.value " . $load . "\n";
602
  print "\n";
603

    
604
  print "multigraph airos_uptime\n";
605
  print "uptime.value " . $uptime . "\n";
606
  print "\n";
607

    
608
  print "multigraph airos_cpu\n";
609
  print "user.value $cpuuser\n";
610
  print "system.value $cpusystem\n";
611
  print "nice.value $cpunice\n";
612
  print "idle.value $cpuidle\n";
613
  print "iowait.value $cpuiowait\n";
614
  print "irq.value $cpuirq\n";
615
  print "softirq.value $cpusoftirq\n";
616
  print "\n";
617

    
618
  if ($PingAddr // "") {
619
    print "multigraph airos_ping1\n";
620
    print "ping.value " . $ping_time . "\n";
621
    print "packetloss.value " . $packet_loss . "\n";
622
    print "\n";
623
  }
624

    
625
  print "multigraph airos_pinglo_ping\n";
626
  print "ping.value " . $ping_timelo . "\n";
627
  print "\n";
628

    
629
  print "multigraph airos_pinglo_loss\n";
630
  print "packetloss.value " . $packet_losslo . "\n";
631
  print "\n";
632

    
633
  exit;
634
}
635