Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Feb 21, 2019 11:08 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (SSH)
PostPosted: Sat Jan 29, 2011 5:32 pm 
Offline

Joined: Sat Jan 29, 2011 4:01 pm
Posts: 8
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/[email protected] ... 00479.html

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

Currently supported:
Code:
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 1031 times


Last edited by dignome on Sat Feb 26, 2011 12:38 pm, edited 3 times in total.
Top
 Profile  
 
 Post subject: Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Wed Feb 09, 2011 3:45 pm 
Offline

Joined: Fri Nov 05, 2010 12:45 pm
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Wed Feb 09, 2011 7:38 pm 
Offline

Joined: Sat Jan 29, 2011 4:01 pm
Posts: 8
Hi. Oops - I was using the newer syntax from python3 which was backported to 2.6/2.7.

Please try the below fix:
Code:
--- 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



Top
 Profile  
 
 Post subject: Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Fri Feb 11, 2011 7:28 pm 
Offline

Joined: Fri Nov 05, 2010 12:45 pm
Posts: 3
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:
--- 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



Top
 Profile  
 
 Post subject: Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Fri Feb 11, 2011 7:45 pm 
Offline

Joined: Fri Nov 05, 2010 12:45 pm
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Updated 02/04/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Fri Feb 11, 2011 9:51 pm 
Offline

Joined: Sat Jan 29, 2011 4:01 pm
Posts: 8
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).


Top
 Profile  
 
 Post subject: Re: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Mon Apr 23, 2012 9:52 pm 
Offline

Joined: Sun Jan 01, 2012 10:56 pm
Posts: 5
hi your script is wonderful, there is an update for UBNT currently, version 5.5, some part of the querying is not functioning.


Top
 Profile  
 
 Post subject: Re: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Fri Jan 24, 2014 5:36 am 
Offline

Joined: Thu Jan 23, 2014 8:52 am
Posts: 1
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


Top
 Profile  
 
 Post subject: Re: Updated 02/26/11 Script + Templates for Ubiquiti AirOS (
PostPosted: Thu Jul 09, 2015 11:51 pm 
Offline

Joined: Thu Jul 09, 2015 11:42 pm
Posts: 14
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group