How to read CCQ on Ubiquiti devices

Last year I published blog post Cacti – How to graph CCQ on Ubiquiti devices. Recently I updated script so it will work with all NanoBridge and PowerBridge devices.


use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Cookies;
use JSON;

if (($#ARGV+1) ne 1) {

my $host = $ARGV[0];
my $cookie_jar = HTTP::Cookies->new();
my $browser  = LWP::UserAgent->new();
my $response = '';
my $directory = '';
my $json = JSON->new();

$browser->cookie_jar( $cookie_jar);

$response = $browser->get(

$response = $browser->post(
  Content_Type => 'form-data',
  Content => [
    username => 'USER',
    password => 'PASS',

$response = $browser->get(

# <link rel="shortcut icon" href="/120816.1338/favicon.ico" >
# Use "120816.1338" directory
# <link rel="shortcut icon" href="/110723.1014/favicon.ico" >
# Use "110723.1014" directory
if ($response->content =~ m/<link rel="shortcut icon" href="\/.*\/favicon.ico".*>/) {
  $directory = $&;
  $directory =~ s/<link.*href="\/(.*)\/.*".*>/$1/;
  $response = $browser->get(

  print ($json->decode($response->content)->{wireless}->{ccq}/10 . "\n");
Please remember to replace USER and PASS with desired credentials.
Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.

Gdansk, Poland