Updated 02/26/11 Script + Templates for Ubiquiti AirOS (SSH)

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
dignome
Posts: 8
Joined: Sat Jan 29, 2011 4:01 pm

Updated 02/26/11 Script + Templates for Ubiquiti AirOS (SSH)

Post by dignome »

Hi. Attached is an archive containing a python script + cacti templates for monitoring Ubiquiti devices.

It is not limited to such and has a simple plugin class for writing queries for any ssh enabled device.
There is another such project that does the same albeit using php:
http://code.google.com/p/mysql-cacti-templates/

It is the originator of the idea, but tbh I had no clue it was out there before writing this.

This script uses paramiko to access the ubiquiti devices (user/pass or private key) and will cache queries for a set time period.
The script makes it easy to write plugins against commands available on the ubiquiti airos shell.

A few samples:

Image

Image

Image

Image

Image

Notes:
The release contains one template with all dependencies along with separate templates for each item.
The platform tested was with cacti 0.8.7g on windows using IIS and python 2.7.1 + paramiko.

!!! You will want to disable anonymous access to the scripts/ubnt directory on your web server as this would
contain your private keys and login passwords for the radio network.


paramiko may need patching if you use the AES-128-CBC cipher:
http://www.mail-archive.com/paramiko@la ... 00479.html

The script supports indexed data query to retrieve and graph the associated stations on an access point.

Currently supported:

Code: Select all

UBNT - Station List - Indexed Data Query:

Airmax Quality and Capacity
Wireless Link Uptime
Client Connection Quality (CCQ)
Link Idle Time
RX/TX Data Rates
RX/TX Traffic
Signal Strength/Noise Floor/Fade Margin(SNR)
Supports indexing by MAC Address, Last IP, Association ID, or Device Name

UBNT - Unit Data Query:

Airmax Quality and Capacity
Associated Stations Count
Client Connection Quality (CCQ)
CPU Usage (top)
RX/TX Data Rates
Signal Strength/Noise Floor/Fade Margin(SNR)
WLAN Errors (Beacon Miss, Crypt, Frag, Network ID, Retries, Other)
Ethernet Link Status
Current Frequency
Wireless Link Uptime
Load Average
Memory Usage
Unit Uptime
More:
http://code.google.com/p/scgrab/
http://www.mediafire.com/?n8t5nchsr1g5y
Attachments
scgrab-2011-02-26.zip
(435.22 KiB) Downloaded 1149 times
Last edited by dignome on Sat Feb 26, 2011 12:38 pm, edited 3 times in total.
kaynine
Posts: 3
Joined: Fri Nov 05, 2010 12:45 pm

Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (

Post by kaynine »

I Tried these scripts out, but am getting an error:


python /var/www/cacti/scripts/scgrab/scgrab.py --authcred=user pass.txt --host=x.x.x.x --plugin=ubnt-mcastatus --query=uptime
File "/var/www/cacti/scripts/scgrab/scgrab.py", line 88
except Exception as e:
^
SyntaxError: invalid syntax
dignome
Posts: 8
Joined: Sat Jan 29, 2011 4:01 pm

Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (

Post by dignome »

Hi. Oops - I was using the newer syntax from python3 which was backported to 2.6/2.7.

Please try the below fix:

Code: Select all

--- scgrab.py   2011-02-09 18:29:13.380563996 -0600
+++ scgrab-py25.py      2011-02-09 18:29:53.750563938 -0600
@@ -85,7 +85,7 @@
                                hostKey = paramiko.DSSKey(filename=authKeyFile, password=password)
                        else:
                                hostKey = paramiko.RSAKey(filename=authKeyFile, password=password)
-               except Exception as e:
+               except Exception, e:
                        msg = str(e)
                        if config.debug:
                                print "generate_cache:",
@@ -113,7 +113,7 @@
                        allow_agent=config.auth_auto_keylookup,
                        look_for_keys=config.auth_auto_keylookup
                )
-       except Exception as e:
+       except Exception, e:
                if config.debug:
                        print "generate_cache:", "failed to connect to remote host - reason:", str(e)
                return False
@@ -132,7 +132,7 @@
        command = ''.join(cmd_list)
        try:
                stdin, stdout, stderr = ssh.exec_command(command)
-       except Exception as e:
+       except Exception, e:
                if config.debug: print "generate_cache:", "failed to execute remote command:", str(e)
                return False

kaynine
Posts: 3
Joined: Fri Nov 05, 2010 12:45 pm

Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (

Post by kaynine »

As i am not familure with python, how do i run this to fix the current script?


Thanks
dignome wrote:Hi. Oops - I was using the newer syntax from python3 which was backported to 2.6/2.7.

Please try the below fix:

Code: Select all

--- scgrab.py   2011-02-09 18:29:13.380563996 -0600
+++ scgrab-py25.py      2011-02-09 18:29:53.750563938 -0600
@@ -85,7 +85,7 @@
                                hostKey = paramiko.DSSKey(filename=authKeyFile, password=password)
                        else:
                                hostKey = paramiko.RSAKey(filename=authKeyFile, password=password)
-               except Exception as e:
+               except Exception, e:
                        msg = str(e)
                        if config.debug:
                                print "generate_cache:",
@@ -113,7 +113,7 @@
                        allow_agent=config.auth_auto_keylookup,
                        look_for_keys=config.auth_auto_keylookup
                )
-       except Exception as e:
+       except Exception, e:
                if config.debug:
                        print "generate_cache:", "failed to connect to remote host - reason:", str(e)
                return False
@@ -132,7 +132,7 @@
        command = ''.join(cmd_list)
        try:
                stdin, stdout, stderr = ssh.exec_command(command)
-       except Exception as e:
+       except Exception, e:
                if config.debug: print "generate_cache:", "failed to execute remote command:", str(e)
                return False

kaynine
Posts: 3
Joined: Fri Nov 05, 2010 12:45 pm

Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (

Post by kaynine »

Ok figured it out .. but now another Error :lol:


python /var/www/cacti/scripts/scgrab/scgrab.py --authcred=userpass.txt --host=x.x.x.x --plugin=ubnt-mcastatus --query=freq

File "/var/www/cacti/scripts/scgrab/scgrab.py", line 395
modify_time = datetime.fromtimestamp(os.path.getmtime(cacheFile)) if os.path.exists(cacheFile) else 0
^
SyntaxError: invalid syntax


Here is the Code from the script:


# compute threshold delta based on file modification date
threshold_time = datetime.today() - timedelta(seconds=int(config.threshold))
modify_time = datetime.fromtimestamp(os.path.getmtime(cacheFile)) if os.path.exists(cacheFile) else 0
dignome
Posts: 8
Joined: Sat Jan 29, 2011 4:01 pm

Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (

Post by dignome »

Hi. I opened a ticket for you here:

http://code.google.com/p/scgrab/issues/detail?id=1

Please try the updated script attached in that ticket.

If you are still having problems please use the ticket system above and let me know a few additional details such as your version of python (python --version).
reeyon
Posts: 5
Joined: Sun Jan 01, 2012 10:56 pm

Re: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (

Post by reeyon »

hi your script is wonderful, there is an update for UBNT currently, version 5.5, some part of the querying is not functioning.
miles007
Posts: 1
Joined: Thu Jan 23, 2014 8:52 am

Re: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (

Post by miles007 »

Hi Guys

I'm not good on programming. I came a cross of this script and I will like to use it on Cacti.
I put the folder scgrab no /usr/share/cacti/scripts/scgrap
I'm able to pull interface traffic but I"m not able to pull "graph" , associated client, memory usage, cpu etc .
If someone has little time I highly appreciation you help.

Thx
Miles
stoneii
Posts: 14
Joined: Thu Jul 09, 2015 11:42 pm

Re: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (

Post by stoneii »

Is there a possibility that this old template to the new Ubiquiti Airos is 5.6.1 changed .
since the new update of Ubiquiti does not work anymore !
mfg
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests