mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Update ubiquiti_airos_
Multigraph munin plugin to monitor Ubiquiti AirOS devices various parameters. v0.9 - added SSH support and saved some memory, thanks to NVX@UbiquitiNetworksCommunity
This commit is contained in:
parent
88e1563b48
commit
2820bf65c7
@ -1,97 +1,114 @@
|
||||
#!/usr/bin/perl
|
||||
###############################################################################
|
||||
##################################################################################################
|
||||
#
|
||||
#Multigraph munin plugin to monitor Ubiquiti AirOS devices various parameters.
|
||||
# Multigraph munin plugin to monitor Ubiquiti AirOS devices various parameters. It needs
|
||||
# Perl's Net::Telnet or Net::OpenSSH to be able to connect.
|
||||
#
|
||||
#To use this plugin, copy it to the munin's plugin directory (eg. /usr/share/munin/plugins)
|
||||
#under the name "ubiquiti_airos_". Don't change this filename! Follow these steps:
|
||||
# To use this plugin, copy it to the munin's plugin directory (eg. /usr/share/munin/plugins)
|
||||
# under the name "ubiquiti_airos_". Don't change this filename! Follow these steps:
|
||||
#
|
||||
#1. Give names to your devices, in fqdn style. Like "apo.wlan" or "cli.wlan". To make the
|
||||
# system understand that, in your /etc/hosts file, add to localhost these names which corespond
|
||||
# to your devices:
|
||||
# 127.0.0.1 localhost apo.wlan cli.wlan
|
||||
# Don't be fooled by 127.0.0.1, this is the localhost IP address, since munin will handle
|
||||
# them as virtual nodes!
|
||||
# 1. Give names to your devices, in fqdn style. Like "apo.wlan" or "cli.wlan". To make the
|
||||
# system understand that, add them to your /etc/hosts file, like below:
|
||||
# 192.168.2.2 apo.wlan
|
||||
# 192.168.2.3 cli.wlan
|
||||
# You could of course add these to your network's local DNS server if you want to.
|
||||
#
|
||||
#2. Then symlink it to munin's configured plugins directory (eg. /etc/munin/plugins) with names
|
||||
# according to the devices you wish to monitor, eg:
|
||||
# ubiquiti_airos_apo.wlan
|
||||
# ubiquiti_airos_cli.wlan
|
||||
# 2. Then symlink it to munin's configured plugins directory (eg. /etc/munin/plugins) with names
|
||||
# according to the devices you wish to monitor, eg:
|
||||
# ubiquiti_airos_apo.wlan
|
||||
# ubiquiti_airos_cli.wlan
|
||||
#
|
||||
# Important: make sure to use the same names in your symlinks and other config places!
|
||||
# Important: make sure to use the same names in your symlinks and other config places!
|
||||
#
|
||||
#3. In /etc/munin/plugin-conf.d/munin-node add the following, to be able to contact
|
||||
# those devices via telnet (obviously replacing these with your own data):
|
||||
# 3. In /etc/munin/plugin-conf.d/munin-node add the following, to be able to contact
|
||||
# those devices via telnet (obviously replacing these with your own data):
|
||||
#
|
||||
# [ubiquiti_airos_apo.wlan]
|
||||
# env.Name AccessPoint # Friendly name to show in graph infos
|
||||
# env.Host 192.168.2.2 # IP address of the device running AirOS
|
||||
# env.TelnetPort 23 # Port of the Telnet service configured in AirOS web interface
|
||||
# env.TelnetUser foobar # Username to log in
|
||||
# env.TelnetPass raboof # Password to log in
|
||||
# env.PingAddr 192.168.2.3 # An IP address to ping, typically the other wireless device or a gateway
|
||||
# env.PingName Client # Friendly name of the pinged device, to display on the ping graph
|
||||
# [ubiquiti_airos_apo.wlan]
|
||||
# user root # User and Group are required only if using any of the SSH modes to store
|
||||
# group root # the keys in /root/.ssh directory (or any user with homedir and shell)
|
||||
# env.NetMode Telnet # Connection mode, can be 'Telnet' or 'SSHPass' or 'SSHKey'
|
||||
# env.Port 23 # Port of the Telnet or SSH service configured in AirOS web interface
|
||||
# env.User foobar # Username to log in
|
||||
# env.Pass raboof # Password to log in
|
||||
# env.PingAddr 192.168.2.3 # An IP address to ping, typically the other wireless device or a gateway
|
||||
# env.PingName cli.wlan # Friendly name of the pinged device, to display on the ping graph
|
||||
#
|
||||
# [ubiquiti_airos_cli.wlan]
|
||||
# env.Name Client
|
||||
# env.Host 192.168.2.3
|
||||
# env.TelnetPort 23
|
||||
# env.TelnetUser foobar
|
||||
# env.TelnetPass raboof
|
||||
# env.PingAddr 192.168.2.2
|
||||
# env.PingName AccessPoint
|
||||
# [ubiquiti_airos_cli.wlan]
|
||||
# user root
|
||||
# group root
|
||||
# env.NetMode SSHPass
|
||||
# env.Port 22
|
||||
# env.User foobar
|
||||
# env.Pass raboof
|
||||
# env.PingAddr 192.168.2.2
|
||||
# env.PingName apo.wlan
|
||||
#
|
||||
#4. In /etc/munin/munin.conf add them as new virtual nodes:
|
||||
# 4. In /etc/munin/munin.conf add them as new virtual nodes:
|
||||
#
|
||||
# [apo.wlan]
|
||||
# address 127.0.0.1
|
||||
# [apo.wlan]
|
||||
# address 127.0.0.1
|
||||
#
|
||||
# [cli.wlan]
|
||||
# address 127.0.0.1
|
||||
# [cli.wlan]
|
||||
# address 127.0.0.1
|
||||
#
|
||||
#5. Restart the munin node by 'service munin-node restart'.
|
||||
# 5. Restart the munin node by 'service munin-node restart'.
|
||||
#
|
||||
# If all went well, after 5 minutes or so you should have two additional nodes listed
|
||||
# on the Web Interface of munin.
|
||||
# If all went well, after 5 minutes or so you should have two additional nodes listed
|
||||
# on the Web Interface of munin.
|
||||
#
|
||||
#Plugin based on aramsey's script, which is based on a MicroTik plugin, see for more info see this link:
|
||||
#http://community.ubnt.com/t5/NanoStation-and-Loco-Devices/SNMP-data-for-NF-dBm/m-p/39070/highlight/true#M11372
|
||||
# To use the script with public keys authentication and no password, set env.NetMode SSHkey, and
|
||||
# create a pair of keys using command 'sudo ssh-keygen -t rsa'. This will generate in /root/.ssh
|
||||
# directory two files, id_rsa and id_rsa.pub. Upload id_rsa.pub to your Ubiquiti device using
|
||||
# Services > SSH Server > Authorized Keys window. Try to log in to the device by command line
|
||||
# first ('sudo ssh foobar@cli.wlan'), to save the RSA key fingerprint in the root account.
|
||||
#
|
||||
#Tested & working with munin v.2.0.14 and AirOS v5.5.6.
|
||||
#Created in 2013 by robi
|
||||
# v0.7 - added critical thresholds to some graphs, and some descriptions below some of them
|
||||
# v0.6 - added wlan errors by type graph - useful to detect interferences on the same frequency; added CPU usage graph
|
||||
# v0.5 - added ping graph - ping times from the AirOS device to a configured address; other fixes
|
||||
# v0.4 - corrected memory size unit calculation and display, fixed query bug, fancier graphs for memory and link speed
|
||||
# v0.3 - added undefined values handling in case of connection timeout, corrected linefeed character handling
|
||||
# v0.2 - combined all the separate pugins into one multigraph plugin, a couple of charts separated
|
||||
# v0.1 - initial version, separate plugin for each graph, packaged 11 different plugins
|
||||
# Plugin based on aramsey's script, which is based on a MicroTik plugin, see for more info see this link:
|
||||
# http://community.ubnt.com/t5/NanoStation-and-Loco-Devices/SNMP-data-for-NF-dBm/m-p/39070/highlight/true#M11372
|
||||
|
||||
#
|
||||
# Tested & working with munin v.2.0.14 and AirOS v5.5.6.
|
||||
# Created in 2013 by robi
|
||||
# v0.9 - added SSH support and saved some memory, thanks to NVX@UbiquitiNetworksCommunity
|
||||
# v0.8 - cleared up stuff related to naming and added ping graphs from munin-node
|
||||
# v0.7 - added critical thresholds to some graphs, and some descriptions below some of them
|
||||
# v0.6 - added wlan errors by type graph - useful to detect interferences on the same frequency; added CPU usage graph
|
||||
# v0.5 - added ping graph - ping times from the AirOS device to a configured address; other fixes
|
||||
# v0.4 - corrected memory size unit calculation and display, fixed query bug, fancier graphs for memory and link speed
|
||||
# v0.3 - added undefined values handling in case of connection timeout, corrected linefeed character handling
|
||||
# v0.2 - combined all the separate pugins into one multigraph plugin, a couple of charts separated
|
||||
# v0.1 - initial version, separate plugin for each graph, packaged 11 different plugins
|
||||
##############################################################################
|
||||
## Magic Markers
|
||||
#%# family=manual
|
||||
##############################################################################
|
||||
use diagnostics;
|
||||
use Net::Telnet;
|
||||
use strict;
|
||||
use warnings;
|
||||
##############################################################################
|
||||
## Receive environmentals
|
||||
my $Name = $ENV{'Name'};
|
||||
my $Host = $ENV{'Host'};
|
||||
my $TelnetPort = $ENV{'TelnetPort'};
|
||||
my $TelnetUser = $ENV{'TelnetUser'};
|
||||
my $TelnetPass = $ENV{'TelnetPass'};
|
||||
## Receive environmentals and load required modules
|
||||
my $NetMode = $ENV{'NetMode'};
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
use Net::Telnet;
|
||||
}
|
||||
elsif ($NetMode =~ /SSH/) {
|
||||
use Net::OpenSSH;
|
||||
}
|
||||
my $Port = $ENV{'Port'};
|
||||
my $User = $ENV{'User'};
|
||||
my $Pass = $ENV{'Pass'};
|
||||
my $PingAddr = $ENV{'PingAddr'};
|
||||
my $PingName = $ENV{'PingName'};
|
||||
my $HostLo = qx("hostname");
|
||||
chomp ($HostLo);
|
||||
##############################################################################
|
||||
## Define variables
|
||||
my $graph_period = "second";
|
||||
my ($load, $uptime, $ping_time, $packet_loss, $amc, $amq, $conn, $mt, $mf, $mb, $errlrcvd, $errltrans, $errwrcvd, $errwtrans);
|
||||
my ($load, $uptime, $ping_time, $packet_loss, $amc, $amq, $conn, $mt, $mf, $mb, $errlrcvd, $errltrans, $errwrcvd, $errwtrans, $ping_timelo, $packet_losslo);
|
||||
my ($trflup, $trfldown, $trfwup, $trfwdown, $freq, $txccq, $acttimeout, $txsignal, $noisefloor, $txrate, $rxrate, $errnwid);
|
||||
my ($errcrypt, $errfrag, $errretries, $errbmiss, $errother, $cpuuser, $cpusystem, $cpunice, $cpuidle, $cpuiowait, $cpuirq, $cpusoftirq);
|
||||
$load = $uptime = $ping_time = $packet_loss = $amc = $amq = $conn = $mt = $mf = $mb = $errlrcvd = $errltrans = $errwrcvd = $errwtrans = "U\n";
|
||||
$trflup = $trfldown = $trfwup = $trfwdown = $freq = $txccq= $acttimeout = $txsignal = $noisefloor = $txrate = $rxrate = $errnwid = "U\n";
|
||||
$errcrypt = $errfrag = $errretries = $errbmiss = $errother = $cpuuser = $cpusystem = $cpunice = $cpuidle = $cpuiowait = $cpuirq = $cpusoftirq = "U\n";
|
||||
$load = $uptime = $ping_time = $packet_loss = $amc = $amq = $conn = $mt = $mf = $mb = $errlrcvd = $errltrans = $errwrcvd = $errwtrans = $ping_timelo = $packet_losslo = "U";
|
||||
$trflup = $trfldown = $trfwup = $trfwdown = $freq = $txccq= $acttimeout = $txsignal = $noisefloor = $txrate = $rxrate = $errnwid = "U";
|
||||
$errcrypt = $errfrag = $errretries = $errbmiss = $errother = $cpuuser = $cpusystem = $cpunice = $cpuidle = $cpuiowait = $cpuirq = $cpusoftirq = "U";
|
||||
###############################################################################
|
||||
## Determine Hostname and other stuff
|
||||
my $Hostname = undef;
|
||||
@ -116,7 +133,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_scale no\n";
|
||||
print "load.label load\n";
|
||||
print "load.critical 10\n";
|
||||
print "graph_info The load average of " . $Name . " describes how many processes are in the run-queue (scheduled to run 'immediately').\n";
|
||||
print "graph_info The load average of " . $Hostname . " describes how many processes are in the run-queue (scheduled to run 'immediately').\n";
|
||||
print "load.info 5 minute load average\n";
|
||||
print "\n";
|
||||
|
||||
@ -129,7 +146,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_scale no\n";
|
||||
print "uptime.label uptime\n";
|
||||
print "uptime.draw AREA\n";
|
||||
print "graph_info This graph shows how many days have passed since the bootup of " . $Name . ".\n";
|
||||
print "graph_info This graph shows how many days have passed since the bootup of " . $Hostname . ".\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_airmax\n";
|
||||
@ -138,12 +155,12 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title AirMAX Quality and Capacity\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_category radio\n";
|
||||
print "graph_info This graph shows the AirMAX Quality and AirMAX Capacity of " . $Name . ". AirMAX Quality (AMQ) is based on the number of retries and the quality of the physical link. If this value is low, you may have interference and need to change frequencies. If AMQ is above 80% and you do not notice any other issues, then you do not need to make any changes. AirMAX Capacity (AMC) is based on airtime efficiency. The lower the AMC, the less efficient the AP is. If you only have one client, this may not matter, but when you have many clients (for example, more than 30), then AMC becomes very important, and you want it to be as high as possible.\n";
|
||||
print "graph_info This graph shows the AirMAX Quality and AirMAX Capacity of " . $Hostname . ". AirMAX Quality (AMQ) is based on the number of retries and the quality of the physical link. If this value is low, you may have interference and need to change frequencies. If AMQ is above 80% and you do not notice any other issues, then you do not need to make any changes. AirMAX Capacity (AMC) is based on airtime efficiency. The lower the AMC, the less efficient the AP is. If you only have one client, this may not matter, but when you have many clients (for example, more than 30), then AMC becomes very important, and you want it to be as high as possible.\n";
|
||||
print "graph_scale no\n";
|
||||
print "amc.label AirMAX Capacity\n";
|
||||
print "amc.critical 30:\n";
|
||||
print "amc.critical 25:\n";
|
||||
print "amq.label AirMAX Quality\n";
|
||||
print "amq.critical 80:\n";
|
||||
print "amq.critical 55:\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_wconn\n";
|
||||
@ -151,7 +168,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title WLAN connections\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows the number of wireless connections to the wlan interface of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the number of wireless connections to the wlan interface of " . $Hostname . ".\n";
|
||||
print "conn.label Connections\n";
|
||||
print "conn.critical 1:\n";
|
||||
print "\n";
|
||||
@ -161,7 +178,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_period " . $graph_period . "\n";
|
||||
print "graph_vlabel packets in (-) / out (+) per " . $graph_period . "\n";
|
||||
print "graph_info This graph shows the amount of errors on the LAN network interface of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the amount of errors on the LAN network interface of " . $Hostname . ".\n";
|
||||
print "errlrcvd.label errors\n";
|
||||
print "errlrcvd.type COUNTER\n";
|
||||
print "errlrcvd.graph no\n";
|
||||
@ -180,7 +197,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_period " . $graph_period . "\n";
|
||||
print "graph_vlabel packets in (-) / out (+) per " . $graph_period . "\n";
|
||||
print "graph_info This graph shows the amount of errors on the WLAN network interface of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the amount of errors on the WLAN network interface of " . $Hostname . ".\n";
|
||||
print "errwrcvd.label errors\n";
|
||||
print "errwrcvd.type COUNTER\n";
|
||||
print "errwrcvd.graph no\n";
|
||||
@ -199,7 +216,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_period " . $graph_period . "\n";
|
||||
print "graph_vlabel bits in (-) / out (+) per " . $graph_period . "\n";
|
||||
print "graph_info This graph shows the traffic of the LAN network interface of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the traffic of the LAN network interface of " . $Hostname . ".\n";
|
||||
print "trfldown.label received\n";
|
||||
print "trfldown.type DERIVE\n";
|
||||
print "trfldown.graph no\n";
|
||||
@ -220,7 +237,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_period " . $graph_period . "\n";
|
||||
print "graph_vlabel bits in (-) / out (+) per " . $graph_period . "\n";
|
||||
print "graph_info This graph shows the traffic of the WLAN network interface of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the traffic of the WLAN network interface of " . $Hostname . ".\n";
|
||||
print "trfwdown.label received\n";
|
||||
print "trfwdown.type DERIVE\n";
|
||||
print "trfwdown.graph no\n";
|
||||
@ -242,10 +259,9 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title Frequency\n";
|
||||
print "graph_vlabel MHz\n";
|
||||
print "graph_category radio\n";
|
||||
print "graph_info This graph shows the operating frequency of the wireless interface of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the operating frequency of the wireless interface of " . $Hostname . ".\n";
|
||||
print "graph_scale no\n";
|
||||
print "freq.label MHz\n";
|
||||
print "freq.draw LINE2\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_mem\n";
|
||||
@ -254,7 +270,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title Memory usage\n";
|
||||
print "graph_vlabel MB\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the device memory usage status of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the device memory usage status of " . $Hostname . ".\n";
|
||||
print "graph_order memTotal memFree memBuffers\n";
|
||||
print "memFree.label Free\n";
|
||||
print "memFree.cdef memFree,1024,*\n";
|
||||
@ -273,7 +289,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title Client Connection Quality\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_category radio\n";
|
||||
print "graph_info This graph shows the Client Connection Quality value of " . $Name . ". The level is based on a percentage value for which 100% corresponds to a perfect link state.\n";
|
||||
print "graph_info This graph shows the Client Connection Quality value of " . $Hostname . ". The level is based on a percentage value for which 100% corresponds to a perfect link state.\n";
|
||||
print "graph_scale no\n";
|
||||
print "txccq.label Transmit CCQ\n";
|
||||
print "txccq.critical 60:\n";
|
||||
@ -285,7 +301,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title ACK timeout\n";
|
||||
print "graph_vlabel us\n";
|
||||
print "graph_category radio\n";
|
||||
print "graph_info This graph shows the ACK (Acknowledgement) timeout value of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the ACK (Acknowledgement) timeout value of " . $Hostname . ".\n";
|
||||
print "acttimeout.label ACK Timeout\n";
|
||||
print "\n";
|
||||
|
||||
@ -295,7 +311,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title Signal levels\n";
|
||||
print "graph_vlabel dBm\n";
|
||||
print "graph_category radio\n";
|
||||
print "graph_info This graph shows the radio signal levels of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the radio signal levels of " . $Hostname . ".\n";
|
||||
print "txsignal.label Signal Strength\n";
|
||||
print "noisefloor.label Noise Floor\n";
|
||||
print "\n";
|
||||
@ -307,7 +323,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_order rxrate txrate\n";
|
||||
print "graph_period " . $graph_period . "\n";
|
||||
print "graph_vlabel RX (-) / TX (+) Mbps\n";
|
||||
print "graph_info This graph shows the wireless link connection speed of " . $Name . ".\n";
|
||||
print "graph_info This graph shows the wireless link connection speed of " . $Hostname . ".\n";
|
||||
print "rxrate.label RX/TX Rate\n";
|
||||
print "rxrate.graph no\n";
|
||||
print "txrate.label Mbps\n";
|
||||
@ -320,7 +336,7 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title WLAN errors by type\n";
|
||||
print "graph_args -l 0 --units-exponent 0\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows the amount of errors on the received side of the WLAN network interface of " . $Name . ", differentiated by type.\n";
|
||||
print "graph_info This graph shows the amount of errors on the received side of the WLAN network interface of " . $Hostname . ", differentiated by type.\n";
|
||||
print "graph_scale no\n";
|
||||
print "errnwid.label Nwid\n";
|
||||
print "errnwid.info Received WLAN frames that do not belong to the own set BSSID (caused by interference on the same frequency).\n";
|
||||
@ -343,115 +359,190 @@ if(exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title CPU usage\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows how CPU time is spent in " . $Name . ".\n";
|
||||
print "graph_info This graph shows how CPU time is spent in " . $Hostname . ".\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_order system user nice idle iowait irq softirq\n";
|
||||
print "graph_order system user nice iowait irq softirq idle\n";
|
||||
print "system.label cpu-system\n";
|
||||
print "system.draw AREA\n";
|
||||
print "system.min 0\n";
|
||||
print "system.info CPU time spent by the kernel in system activities in " . $Name . ".\n";
|
||||
print "system.info CPU time spent by the kernel in system activities in " . $Hostname . ".\n";
|
||||
print "user.label cpu-user\n";
|
||||
print "user.draw STACK\n";
|
||||
print "user.min 0\n";
|
||||
print "user.info CPU time spent by normal programs and daemons in " . $Name . ".\n";
|
||||
print "user.info CPU time spent by normal programs and daemons in " . $Hostname . ".\n";
|
||||
print "nice.label cpu-nice\n";
|
||||
print "nice.draw STACK\n";
|
||||
print "nice.min 0\n";
|
||||
print "nice.info CPU time spent by nice(1)d programs in " . $Name . ".\n";
|
||||
print "nice.info CPU time spent by nice(1)d programs in " . $Hostname . ".\n";
|
||||
print "idle.label cpu-idle\n";
|
||||
print "idle.draw STACK\n";
|
||||
print "idle.min 0\n";
|
||||
print "idle.info Idle CPU time in " . $Name . ".\n";
|
||||
print "idle.info Idle CPU time in " . $Hostname . ".\n";
|
||||
print "iowait.label cpu-iowait\n";
|
||||
print "iowait.draw STACK\n";
|
||||
print "iowait.min 0\n";
|
||||
print "iowait.info CPU time spent waiting for I/O operations to finish when there is nothing else to do in " . $Name . ".\n";
|
||||
print "iowait.info CPU time spent waiting for I/O operations to finish when there is nothing else to do in " . $Hostname . ".\n";
|
||||
print "irq.label cpu-irq\n";
|
||||
print "irq.draw STACK\n";
|
||||
print "irq.min 0\n";
|
||||
print "irq.info CPU time spent handling interrupts in " . $Name . ".\n";
|
||||
print "irq.info CPU time spent handling interrupts in " . $Hostname . ".\n";
|
||||
print "softirq.label cpu-softirq\n";
|
||||
print "softirq.draw STACK\n";
|
||||
print "softirq.min 0\n";
|
||||
print "softirq.info CPU time spent handling batched interrupts in " . $Name . ".\n";
|
||||
print "softirq.info CPU time spent handling batched interrupts in " . $Hostname . ".\n";
|
||||
print "\n";
|
||||
|
||||
if ($PingAddr // "") {
|
||||
print "multigraph airos_ping1\n";
|
||||
print "host_name " . $Hostname . "\n";
|
||||
print "graph_title Ping times to " . $PingName . "\n";
|
||||
print "graph_title Ping times from " . $Hostname . " to " . $PingName . "\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel roundtrip time (seconds)\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows ping RTT statistics, measured on " . $Name . " (" . $Host . ").\n";
|
||||
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";
|
||||
print "ping.label " . $PingName . "\n";
|
||||
print "ping.info Ping RTT statistics for " . $PingName . " (" . $PingAddr . ").\n";
|
||||
print "packetloss.label packet loss\n";
|
||||
print "packetloss.graph no\n";
|
||||
print "packetloss.critical 0\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print "multigraph airos_pinglo_ping\n";
|
||||
print "host_name " . $Hostname . "\n";
|
||||
print "graph_title Ping times to " . $Hostname . "\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel roundtrip time (seconds)\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows ping RTT statistics, measured on the munin-node " . $HostLo . " against " . $Hostname . ".\n";
|
||||
print "ping.label " . $Hostname . "\n";
|
||||
print "ping.info Ping RTT statistics for " . $Hostname . ".\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_pinglo_loss\n";
|
||||
print "host_name " . $Hostname . "\n";
|
||||
print "graph_title Ping packet loss to " . $Hostname . "\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_category network\n";
|
||||
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";
|
||||
print "packetloss.label " . $Hostname . "\n";
|
||||
print "packetloss.info Packet loss for " . $Hostname . ".\n";
|
||||
print "packetloss.critical 0:0\n";
|
||||
print "\n";
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
## Initiate Telnet Session
|
||||
my $CM = Net::Telnet->new(Port => $TelnetPort,
|
||||
Prompt=> '/ $/',
|
||||
Timeout=>10,
|
||||
Errmode=>'return');
|
||||
my $CM;
|
||||
my $SSH;
|
||||
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
## Initiate Telnet Session
|
||||
$CM = Net::Telnet->new(Port => $Port,
|
||||
Prompt=> '/ $/',
|
||||
Timeout=>10,
|
||||
Errmode=>'return');
|
||||
$CM->open($Hostname);
|
||||
|
||||
if (!defined($CM->login($User, $Pass))) {
|
||||
&printResults(); # Nothing happens, except printing undefined results to munin
|
||||
}
|
||||
}
|
||||
|
||||
elsif ($NetMode =~ /SSHPass/) {
|
||||
## Initiate SSH Session using password authentication
|
||||
$SSH = Net::OpenSSH->new($Hostname,
|
||||
port => $Port,
|
||||
user => $User,
|
||||
password => $Pass,
|
||||
timeout => 10,
|
||||
# master_stderr_discard => 1,
|
||||
master_opts => [-o => "StrictHostKeyChecking=no"]);
|
||||
$SSH->error and
|
||||
# warn "Couldn't establish SSH connection: " . $SSH->error;
|
||||
&printResults(); # Nothing happens, except printing undefined results to munin
|
||||
}
|
||||
|
||||
elsif ($NetMode =~ /SSHKey/) {
|
||||
## Initiate SSH Session using public key authentication
|
||||
$SSH = Net::OpenSSH->new($Hostname,
|
||||
port => $Port,
|
||||
user => $User,
|
||||
timeout => 10,
|
||||
# master_stderr_discard => 1,
|
||||
master_opts => [-o => "StrictHostKeyChecking=no"]);
|
||||
$SSH->error and
|
||||
# warn "Couldn't establish SSH connection: " . $SSH->error;
|
||||
&printResults(); # Nothing happens, except printing undefined results to munin
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$CM->open($Host);
|
||||
###############################################################################
|
||||
## Execution
|
||||
if (!defined($CM->login($TelnetUser, $TelnetPass))) {
|
||||
# Nothing happens
|
||||
} else {
|
||||
my @OutLoad = $CM->cmd("cat /proc/loadavg");
|
||||
foreach my $Line (@OutLoad) {
|
||||
if ($Line !~ /XM.v/ && $Line =~ m/(\d+)/) {
|
||||
$load = substr($Line, 0,4);
|
||||
}
|
||||
my @Out;
|
||||
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
@Out = $CM->cmd("cat /proc/loadavg");
|
||||
}
|
||||
elsif ($NetMode =~ /SSH/) {
|
||||
@Out = $SSH->capture("cat /proc/loadavg");
|
||||
}
|
||||
foreach my $Line (@Out) {
|
||||
if ($Line !~ /XM.v/ && $Line =~ m/(\d+)/) {
|
||||
$load = substr($Line, 0,4);
|
||||
}
|
||||
}
|
||||
|
||||
# my $topcmd = "top -b -n2 | grep '^CPU:' | tail -n1";
|
||||
my $topcmd = "top -b -n2 -d1 | grep '^CPU:' | tail -n1";
|
||||
my @OutCPU = $CM->cmd($topcmd);
|
||||
chomp @OutCPU;
|
||||
my $OutCPU = join(" ", @OutCPU);
|
||||
my $recpu=".*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+)";
|
||||
if ($OutCPU =~ m/$recpu/is) {
|
||||
$cpuuser=$1;
|
||||
$cpusystem=$2;
|
||||
$cpunice=$3;
|
||||
$cpuidle=$4;
|
||||
$cpuiowait=$5;
|
||||
$cpuirq=$6;
|
||||
$cpusoftirq=$7;
|
||||
}
|
||||
# if ($cpuiowait > 100 && $cpusoftirq > 100) {
|
||||
# $cpuiowait = 49;
|
||||
# $cpusoftirq = 49;
|
||||
# }
|
||||
# if ($cpuiowait > 100) {
|
||||
# $cpuiowait = 98;
|
||||
# }
|
||||
# if ($cpusoftirq > 100) {
|
||||
# $cpusoftirq = 98;
|
||||
# }
|
||||
|
||||
sleep 1;
|
||||
my $topcmd = "top -b -n2 -d1 | grep '^CPU:' | tail -n1";
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
@Out = $CM->cmd($topcmd);
|
||||
}
|
||||
elsif ($NetMode =~ /SSH/) {
|
||||
@Out = $SSH->capture($topcmd);
|
||||
}
|
||||
chomp @Out;
|
||||
my $OutCPU = join(" ", @Out);
|
||||
my $recpu=".*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+).*?(\\d+)";
|
||||
if ($OutCPU =~ m/$recpu/is) {
|
||||
$cpuuser=$1;
|
||||
$cpusystem=$2;
|
||||
$cpunice=$3;
|
||||
$cpuiowait=$5;
|
||||
$cpuirq=$6;
|
||||
$cpusoftirq=$7;
|
||||
$cpuidle=100 - $cpuuser - $cpusystem - $cpunice - $cpuiowait - $cpuirq - $cpusoftirq; #=$4
|
||||
}
|
||||
|
||||
my @OutUpt = $CM->cmd("cat /proc/uptime");
|
||||
foreach my $Line (@OutUpt) {
|
||||
if ($Line !~ /XM.v/ && $Line =~ m/(\d+)/) {
|
||||
sleep 1;
|
||||
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
@Out = $CM->cmd("cat /proc/uptime");
|
||||
}
|
||||
elsif ($NetMode =~ /SSH/) {
|
||||
@Out = $SSH->capture("cat /proc/uptime");
|
||||
}
|
||||
|
||||
foreach my $Line (@Out) {
|
||||
if ($Line !~ /XM.v/ && $Line =~ m/(\d+)/) {
|
||||
$uptime = $1 / 86400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my @OutMca = $CM->cmd("ubntbox mca-status");
|
||||
foreach my $Line (@OutMca) {
|
||||
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
@Out = $CM->cmd("ubntbox mca-status");
|
||||
}
|
||||
elsif ($NetMode =~ /SSH/) {
|
||||
@Out = $SSH->capture("ubntbox mca-status");
|
||||
}
|
||||
|
||||
foreach my $Line (@Out) {
|
||||
if ($Line =~ /wlanRxErrors/ && $Line =~ m/(.\d+)/) {
|
||||
$errwrcvd = substr($Line, 13);
|
||||
}
|
||||
@ -544,118 +635,146 @@ if (!defined($CM->login($TelnetUser, $TelnetPass))) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
sleep 1;
|
||||
if ($PingAddr // "") {
|
||||
my $pingcmd = "ping -c 2 " . $PingAddr . " 2>/dev/null";
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
@Out = $CM->cmd($pingcmd);
|
||||
}
|
||||
sleep 1;
|
||||
if ($PingAddr // "") {
|
||||
my $pingcmd = "ping -c 2 " . $PingAddr . " 2>/dev/null";
|
||||
my @ping = $CM->cmd($pingcmd);
|
||||
chomp @ping;
|
||||
my $ping = join(" ", @ping);
|
||||
elsif ($NetMode =~ /SSH/) {
|
||||
@Out = $SSH->capture($pingcmd);
|
||||
}
|
||||
chomp @Out;
|
||||
my $ping = join(" ", @Out);
|
||||
$ping_time = ($1 / 1000) if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
|
||||
$packet_loss = $1 if ($ping =~ /(\d+)% packet loss/);
|
||||
} else {
|
||||
$PingName = "";
|
||||
$PingAddr = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
chomp($load, $uptime, $ping_time, $packet_loss, $amc, $amq, $conn, $mt, $mf, $mb, $errlrcvd, $errltrans,
|
||||
|
||||
if ($NetMode =~ /Telnet/) {
|
||||
$CM->close;
|
||||
}
|
||||
|
||||
my $pingcmdlo = "ping -c 2 " . $Hostname . " 2>/dev/null";
|
||||
my @pinglo = qx($pingcmdlo);
|
||||
chomp @pinglo;
|
||||
my $pinglo = join(" ", @pinglo);
|
||||
$ping_timelo = ($1 / 1000) if ($pinglo =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
|
||||
$packet_losslo = $1 if ($pinglo =~ /(\d+)% packet loss/);
|
||||
|
||||
chomp($load, $uptime, $ping_time, $packet_loss, $amc, $amq, $conn, $mt, $mf, $mb, $errlrcvd, $errltrans, $ping_timelo, $packet_losslo,
|
||||
$errwrcvd, $errwtrans, $trflup, $trfldown, $trfwup, $trfwdown, $freq, $txccq, $acttimeout, $txsignal,
|
||||
$noisefloor, $txrate, $rxrate, $errnwid, $errcrypt, $errfrag, $errretries, $errbmiss, $errother,
|
||||
$cpuuser, $cpusystem, $cpunice, $cpuidle, $cpuiowait, $cpuirq, $cpusoftirq);
|
||||
|
||||
$CM->close;
|
||||
&printResults();
|
||||
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_wrate\n";
|
||||
print "txrate.value " . $txrate . "\n";
|
||||
print "rxrate.value " . $rxrate . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_ccq\n";
|
||||
print "txccq.value " . $txccq . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_ack\n";
|
||||
print "acttimeout.value " . $acttimeout . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_dbm\n";
|
||||
print "txsignal.value " . $txsignal . "\n";
|
||||
print "noisefloor.value " . $noisefloor . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_mem\n";
|
||||
print "memTotal.value " . $mt . "\n";
|
||||
print "memFree.value " . $mf . "\n";
|
||||
print "memBuffers.value " . $mb . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_freq\n";
|
||||
print "freq.value " . $freq . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_trfw\n";
|
||||
print "trfwup.value " . $trfwup . "\n";
|
||||
print "trfwdown.value " . $trfwdown . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_trfl\n";
|
||||
print "trflup.value " . $trflup . "\n";
|
||||
print "trfldown.value " . $trfldown . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_errw\n";
|
||||
print "errwrcvd.value " . $errwrcvd . "\n";
|
||||
print "errwtrans.value " . $errwtrans . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_errl\n";
|
||||
print "errlrcvd.value " . $errlrcvd . "\n";
|
||||
print "errltrans.value " . $errltrans . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_airmax\n";
|
||||
print "amc.value " . $amc . "\n";
|
||||
print "amq.value " . $amq . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_wconn\n";
|
||||
print "conn.value " . $conn . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_load\n";
|
||||
print "load.value " . $load . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_uptime\n";
|
||||
print "uptime.value " . $uptime . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_errwty\n";
|
||||
print "errnwid.value $errnwid\n";
|
||||
print "errcrypt.value $errcrypt\n";
|
||||
print "errfrag.value $errfrag\n";
|
||||
print "errretries.value $errretries\n";
|
||||
print "errbmiss.value $errbmiss\n";
|
||||
print "errother.value $errother\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_cpu\n";
|
||||
print "user.value $cpuuser\n";
|
||||
print "system.value $cpusystem\n";
|
||||
print "nice.value $cpunice\n";
|
||||
print "idle.value $cpuidle\n";
|
||||
print "iowait.value $cpuiowait\n";
|
||||
print "irq.value $cpuirq\n";
|
||||
print "softirq.value $cpusoftirq\n";
|
||||
print "\n";
|
||||
|
||||
if ($PingAddr // "") {
|
||||
print "multigraph airos_ping1\n";
|
||||
print "ping.value " . $ping_time . "\n";
|
||||
print "packetloss.value " . $packet_loss . "\n";
|
||||
sub printResults {
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_wrate\n";
|
||||
print "txrate.value " . $txrate . "\n";
|
||||
print "rxrate.value " . $rxrate . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_ccq\n";
|
||||
print "txccq.value " . $txccq . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_ack\n";
|
||||
print "acttimeout.value " . $acttimeout . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_dbm\n";
|
||||
print "txsignal.value " . $txsignal . "\n";
|
||||
print "noisefloor.value " . $noisefloor . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_mem\n";
|
||||
print "memTotal.value " . $mt . "\n";
|
||||
print "memFree.value " . $mf . "\n";
|
||||
print "memBuffers.value " . $mb . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_freq\n";
|
||||
print "freq.value " . $freq . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_trfw\n";
|
||||
print "trfwup.value " . $trfwup . "\n";
|
||||
print "trfwdown.value " . $trfwdown . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_trfl\n";
|
||||
print "trflup.value " . $trflup . "\n";
|
||||
print "trfldown.value " . $trfldown . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_errw\n";
|
||||
print "errwrcvd.value " . $errwrcvd . "\n";
|
||||
print "errwtrans.value " . $errwtrans . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_errl\n";
|
||||
print "errlrcvd.value " . $errlrcvd . "\n";
|
||||
print "errltrans.value " . $errltrans . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_airmax\n";
|
||||
print "amc.value " . $amc . "\n";
|
||||
print "amq.value " . $amq . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_wconn\n";
|
||||
print "conn.value " . $conn . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_load\n";
|
||||
print "load.value " . $load . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_uptime\n";
|
||||
print "uptime.value " . $uptime . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_errwty\n";
|
||||
print "errnwid.value $errnwid\n";
|
||||
print "errcrypt.value $errcrypt\n";
|
||||
print "errfrag.value $errfrag\n";
|
||||
print "errretries.value $errretries\n";
|
||||
print "errbmiss.value $errbmiss\n";
|
||||
print "errother.value $errother\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_cpu\n";
|
||||
print "user.value $cpuuser\n";
|
||||
print "system.value $cpusystem\n";
|
||||
print "nice.value $cpunice\n";
|
||||
print "idle.value $cpuidle\n";
|
||||
print "iowait.value $cpuiowait\n";
|
||||
print "irq.value $cpuirq\n";
|
||||
print "softirq.value $cpusoftirq\n";
|
||||
print "\n";
|
||||
|
||||
if ($PingAddr // "") {
|
||||
print "multigraph airos_ping1\n";
|
||||
print "ping.value " . $ping_time . "\n";
|
||||
print "packetloss.value " . $packet_loss . "\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print "multigraph airos_pinglo_ping\n";
|
||||
print "ping.value " . $ping_timelo . "\n";
|
||||
print "\n";
|
||||
|
||||
print "multigraph airos_pinglo_loss\n";
|
||||
print "packetloss.value " . $packet_losslo . "\n";
|
||||
print "\n";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user