PRTG and Ubiquiti Switches (UBNT)

I recently added 3 Ubiquiti (UBNT) switches to my private network. After replacing the old switches with the new UBNT switches, these now also had to be integrated into the monitoring. I use the free version of PRTG to monitor my network. There is already a ready-made PowerShell script from Paessler for the Unifi access points. However, this script does not provide any data on the switches.

I have therefore adapted the script from Paessler so that it provides data on the switches. Here is the script from Paessler for the UBNT access points:

Here is the first draft for a sensor that displays the following data in PRTG:

  • Number of connected clients via LAN
  • Number of switches connected to the controller
  • Number of switches that require an update
  • RX/TX Dropped/Error Packets per switch

Here is the modified script for the Unifi Switch Sensor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#
#
#
#
#
#
#
#
#
 
(
     = ,
     = '8443',
     = ,
     = ,
     = '123456',
     =
)
 
}
 
, , , )
 
 
( 3) {
    
    
    
    
    
}
 
=
=
 
 
    
    
    $_
    
    
}
 
    
    
    $_
    
    
}
 
 
 
1
    
}
 
1
    
}
 
    
}
 
 
 
 
 
 
 
1
    
    
    
    
    
     
    
    
    
    
    
     
    
    
    
    
    
     
    
    
    
    
    
     
    
    
    
    
    
}
 
 
    
    
 
    
    
}

The installation follows the same principle as in the article linked above, so there is only a brief overview here:

The script is saved in the folder "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML":

PRTG Sensor

A sensor can now be added to the controller in the PRTG GUI:

PRTG Sensor

The sensor is given a name and the script is assigned. The login information for the Unifi controller must be added as a parameter:

1
'8443'

PRTG Sensor

Once the sensor has been started, the data for the switches is displayed:

PRTG and Ubiquiti Switches (UBNT)

Note: The script accesses the controller's API, the values shown here are only a small part of the values that can be retrieved via the controller's API. However, this example script and the script from Paessler are well suited for creating your own sensors for the API of the Unifi controller. Here is a small excerpt of the values that the API can provide:

Unifi Controller API

Most values can also be retrieved via SNMP, but this quickly causes the number of sensors in PRTG to explode. If, like me, you only use the free version of PRTG (limited to 100 sensors), you will quickly reach the limits of your license with SNMP.

7 thoughts on “PRTG und Ubiquiti Switches (UBNT)”

  1. Hallo Zusammen, Hat sich in den letzten Monaten noch einmal etwas geändert?

    Auch wenn ich die Vorschläge von Bernd befolge erhalte ich aktuell immer den Fehler „Authentication Failed: Unable to connect to the remote server“.

    Folgende Syntax verwende ich bei den Parametern:

    -server ‚%host‘ -port ‚443‘ -site ‚NameMeinerSite‘ -username ‚ctrllerUsername‘ -password ‚ctrllerPassword‘

    Wenn ich mehrere Sites habe kann ich diese ja in mehrere Sensoren angeben und erhalte damit pro Site die ganzen Werte oder?

    Verwendet wird die Unifi-Version 6.5.55 und läuft auf einem Ubuntu. Also kein Cloud Key Controller.

    Reply
  2. Moin,

    mit dem neuen Update des Unifi Controllers werfen die Scripte leider Fehlermeldungen. Ist es geplant diese irgendwann auf die neue Software anzupassen?

    Reply
    • Hallo,
      die Anpassungen sind relativ einfach gemacht damit die Version 6.0.45+ unterstützt wird. Dazu einfach folgendes ändern:

      Zeile 23: VON: [string]$port = ‚8443‘, ZU: [string]$port = ‚443‘,

      Zeile 55: VON: $null = Invoke-Restmethod -Uri „$controller/api/login“ -method post -body $credential -ContentType „application/json; charset=utf-8“ -SessionVariable myWebSession

      ZU: $null = Invoke-Restmethod -Uri „$controller/api/auth/login“ -method post -body $credential -ContentType „application/json; charset=utf-8“ -SessionVariable myWebSession

      und

      Zeile 66: VON: $jsonresultat = Invoke-Restmethod -Uri „$controller/api/s/$site/stat/device/“ -WebSession $myWebSession

      ZU: $jsonresultat = Invoke-Restmethod -Uri „$controller/proxy/network/api/s/$site/stat/device/“ -WebSession $myWebSession

      Dann klappt es wieder.

      Viele Grüße
      Bernd

      Reply
  3. Hallo,

    ist es auch möglich die Temperatur und Lüfterdrehzahl mit PRTG zu überwachen?
    Konnte leider noch nichts dazu finden.

    Danke

    Reply
  4. Ich möchte anmerken, dass es mit Powershell v4 (Server 2012R2) Probleme gibt und nur 0 zurück gibt. Bei Win 10 / Server 2016 und Server 2019 geht es sofort.

    Nach dem Upgrade von PS4 auf PS5.1 auf Server2012R2 funktioniert das Skript auch.

    Ggf sollte das Skript angepasst werden, da nur geprüft wird, ob min. PS3 installiert ist.

    Grüße
    Danny

    Reply
  5. Hi Frank,

    wer kein Pässler Monitoring hat kann auch auf die kostenfreien Controller von Ubiquiti zurückgreifen.
    Hier gibt es zwei Produktlinien zu beachten.
    Die UniFi Switches (Modellname US) können mit einem UniFi Controller verwaltet werden und verwalten auch deren AccessPoints. Funktioniert hervorragend. Die Switche haben aber keine GUI, also für Standalone eher ungeeignet.
    Die EdgeMax Switch Serie (Modellname ES) kann mit einem UNMS Controller überwacht werden. Hier ist derzeit eine reines Monitoring ohne Verwaltung über den Controller möglich. Sobald am Switch eine Konfig verändert wird, sammelt der UNMS aber automatisch das Backup ein, was auch super funktioniert. Mit dem UNMS überwachen wir auch die weiteren Ubiquiti Richtfunk Antennen und es können auch Drittanbieter über SNMP eingebunden werden.

    Alles in allem bietet Ubiquiti meiner Meinung nach ein gutes Preis-Leistungsverhältnis und die Entwicklung geht dort stehts voran.

    VG
    Pascal

    Reply

Leave a Comment