Download details

check_unifi check_unifi.php Beliebt Aktualisiert

Informationen
Erstelldatum 22.12.2020
Änderungsdatum 27.02.2021
Version 1.20210227
Dateigröße 54.18 KB
Downloads 165
Lizenz MIT Lizenz external
Preis Donate PayPal

Nagios Plugin to check a Unifi Controller (Accesspoints and Switches).

Api Version 1.1.68
You need to install php-curl

 

/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -u nagios -p nagios -s -m uplink -a AP02 -w 200 -c 100
OK - Uplink: AP01 - signal=-67%  tx_rate=234 Mbps  rx_rate=526.5 Mbps | tx_rate=234;rx_rate=526.5;signal=67
 
/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -u nagios -p nagios -s -m cpu AP02 -w 80 -c 90
OK - 10.4% (load average: 0.01, 0.05, 0.05) | load=0.01;;;; load5=0.05;;;; load15=0.05;;;;
 
/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -u nagios -p nagios -s -m mem -a AP01 -w 80 -c 90
OK - 83.47 Mb | Total=128.62Mb;102.90;115.76;; Used=83.47Mb;;;; Free=45.15Mb;;;;
 
/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -u nagios -p nagios -s -m ap -w 0 -c 1
WARNING - Online: 3 / Offline: 1 | AP=4 Online=3 Offline=1;1;2;;
 
/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -u nagios -p nagios -s  -m switch -c 0
OK - Online: 1 / Offline: 0 | Switch=1 Online=1 Offline=0;0;0;;
 
/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -u nagios -p nagios -s  -m uplink -a AP01
OK - Uplink SWITCH01 (wire) - speed=1000 Mbps | speed=1000
 
/usr/bin/php ./check_unifi.php -C -m mem% -a AP01 -w 80 -c 90
OK - 31.88 MB | Total=128.62MB;90.03;115.76;0;128.62 Used=31.88MB;;;; Free=96.74MB;;;; Caches=29.89MB;;;;
 
/usr/bin/php ./check_unifi.php -C -a AP01 -m clients_name_guest
OK - Clients: 5/User:5/Guest:0 (2GHz: 2/U:2/G:0, 5GHz: 3/U:3/G:0) MACBOOK(5) VIRTUAL-WLAN(5) CAM01(2) TABLETT04(5) PRS01(2) | Clients=5;;;; 2GHz=2 5GHz=3
 
/usr/bin/php ./check_unifi.php -C -a AP01 -m channels
OK - 2GHz: auto (11(13,-1)) HT40 - 5GHz: auto (58(64,-1)) VHT80| 2GHz=11 5GHz=58
 
/usr/bin/php ./check_unifi.php -C -a AP01 -m transfer
OK - RX: 5,09 Mbit - TX: 166,84 Kbit | RX=5215,38Kbit;;;; TX=166,84Kbit;;;;
 
/usr/bin/php ./check_unifi.php -C -a AP01 -m experience -w 30 -c 20
OK - WIFI Experience: 99% | Experience=99%;30;20;;
 
/usr/bin/php ./check_unifi.php -C -a JHSAP01 -m utilisation -w 75,75 -c 85,85
OK - 2GHz Utilized: 11% (RX Frames: 9%, TX Frames: 1%, Interference: 1%) - 5GHz Utilized: 8% (RX Frames: 6%, TX Frames: 2%, Interference: 0%)| 2GHz=11;75;85;; RX=9;;;; TX=1;;;; Interference=1 5GHz=8;75;85;; RX=6;;;; TX=2;;;; Interference=0
 
/usr/bin/php  ./check_unifi.php -C -a AP01 -m linux_cpu -w 75 -c 85
OK - 10.2% | cpu=10.2%;75;85;0;100
 
/usr/bin/php  ./check_unifi.php -C -a AP01 -m linux_load -w 0.5,0.5,0.5 -c 1,1,1
OK - load average: 0.22, 0.08, 0.07 | load=0.22;0.5;1;; load5=0.08;0.5;1;; load15=0.07;0.5;1;;
 
/usr/bin/php ./check_unifi.php -C -m update -a AP02 -w 1,1,1 -c 1,5,10
CRITICAL - firmware upgradable from version 4.3.28.11361 to 5.43.30.12622
 
/usr/bin/php ./check_unifi.php -C -m site
---------+------------------------------------
Site ID  | Site Name
---------+------------------------------------
default  | unifi.jhoerter.com
a1uobpaz | Test
 
/usr/bin/php ./check_unifi.php -H 192.168.2.213 -P 8443 -s -u nagios -p nagios -S default -m uptime -a AP01
OK - UniFi AP-AC-Lite [unifi.jhoerter.com ] - 0 days, 3 hours, 44 mins.| Uptime=13445
 

 
Usage: /usr/bin/php check_unifi.php -H [controller] -u [controlleruser] -p [controllerpassword] -P [controllerport] -m [mode] -a [Accesspoint/Switch] -w [Warning] -c [Critical] ( -S [siteid] -s =https -C [configfile] -d =debug)
 
mode - controller  = Controller Version, warning if there is an update
       site = list all Site ID and Name
       clients   = list all clients (console)
       clients_wifi = list all wifi clients with connection speed (console)
       clients_name + Accesspoint = list all clients of an accesspoint
       clients_name_guest + Accesspoint = list all clients and guests of an accesspoint
       clients_count + Accesspoint = count clients of an accesspoint
       clients_count_guest + Accesspoint = count clients and guests of an accesspoint
       channels + Accesspoint = channels 2GHz/5GHz of an accesspoint
       transfer + Accesspoint = rx/tx transfer of an accesspoint (Kbit/Mbit)
       transfer+ + Accesspoint = rx/tx transfer of an accesspoint (Kbyte/Mbyte)
       uptime + Accesspoint/Switch = uptime and firmware of an accesspoint/switch
       update + Accesspoint/Switch = update firmware is available of an accesspointi/switch  (point release, major version, minor version)
       uplink + Accesspoint warn crit = uplink of an accesspoint (wireless: with connection speed and warn/critical)
       experience + Accesspoint warn crit = wireless experience of an accesspoint with warn/critical
       utilisation + Accesspoint warn cri = wireless utilisation of an accesspoint with warn/critical (2GHz,5GHz)
       mem + Accesspoint warn crit = memory usage output Mb of an accesspoint or a switch with warn/critical percent
       mem% + Accesspoint warn crit = memory usage output percent of an accesspoint or a switch with warn/critical percent
       cpu + Accesspoint/Switch warn crit = cpu and load combination usage of an accesspoint or a switch with warn/critical procent
       cpu% + Accesspoint/Switch warn cri = cpu usage of an accesspoint or a switch with warn/critical procent
       load + Accesspoint/Switch warn crit = linux_load usage of an accesspoint or a switch with warn/critical 1,5,15
       temperature + Switch = temperature of a switch with warn/critical
       ap warn crit = count Accesspoint (Online and Offline) with warn and critical offline Accesspoints
       switch warn crit  = count Switch (Online and Offline) with warn and critical offline Switch
 
 
-C - config file (default=unifi.php) instead of the controller parameters -H,-u,-p,-P,-s -S (you can specify any file with path)
     example (unifi.php):

     <?php
     $host='192.168.2.213'; # IP or Hostname unifi controller Server
     $prot='https';         # Value http or https
     $port='8443';          # Controller Port
     $user='nagios';        # Loginuser Controller
     $pass='nagios';        # Password Loginuser
     $siteid='default';     # Site ID
     $dir_unifi_client='';  # Directory unifi_client.php
     ?>
 

  
 
unifi_load unifi_mem2 unifi_experience3 unifi_transfer4 unifi_channel_usage5 unifi_nagios6

Changelog

Version 1.20210227
change help 
add client bands to clients_name/clients_name_guest

Version 1.20210225
correct channels (-1/+1)
correct $dir_unifi_client


Version 1.20210219
model is integrated in Api
update ap/switch now with warning and critical
add site (to find the sideid)
add multisite (-S)


Version 1.20210211
minor bugs fixes
add transfer+ 


Version 1.20210211
minor bugs fixes
change Client.php to unifi_client.php
change default path from /usr/local/nagios/libexec to the path of the script 

change modes:
linux_load to load
linux_cpu to cpu%


Version 1.20210210
add following checks:
- transfer
- experience
- utilisation
- clients_name_guest
- clients_count_guest
- linux_load
- linux_cpu
- update

Thank's again to Keith from UK for the input.


Version 1.20210204
-C - config file unifi.php instead of the controller parameter -H,-u,-p,-P and -s
add mem% output memory percent
perfdata uptime (seconds)

Thank's to Keith from UK for the input.


Version 1.20210130
uplink accesspoint now also wire


Version 1.20210127
new API Version 1.1.68
count Accesspoint and count Switch


Version 1.20210124
minor bugs fixes


Version 1.20210118
new API Version 1.1.63


Version 1.20210106
cpu now with warn and crit percent


Version 1.20210104
mapping short label type to real name (uptime)

  

Would you like to support me?
Then donate to PayPal...