Issue
Code backup
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
Copyright 2022 Kalarumeth - https://github.com/Kalarumeth
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,172 @@
|
||||
# Check AirOs
|
||||
<img src="https://img.shields.io/badge/Code-Bash-orange?style=flat-square&logo=GNU%20Bash&logoColor=orange" alt="Bash"> <img src="https://img.shields.io/badge/Device-AirOs-0559C9?style=flat-square&logo=Ubiquiti" alt="Checked Device"> <img src="https://img.shields.io/badge/Release-v1.0-green?style=flat-square" alt="Release">
|
||||
|
||||
<img src="https://img.shields.io/badge/Dev by-Kalarumeth-blueviolet?style=flat-square" alt="Dev"> <img src="https://img.shields.io/badge/License-MIT-blue?style=flat-square" alt="MIT License">
|
||||
|
||||
The following script is used to monitor and display the basic information of Ubiquity AirOs via snmpwalk scripts and are processed to provide easy-to-read data. It can be run separately or integrated into Icinga2 as a monitoring plugin.
|
||||
|
||||
**Important**: *snmpwalk command is required for script to run correctly*
|
||||
|
||||
|
||||
# Update Note
|
||||
|
||||
## 1.0 - Release
|
||||
|
||||
+ Release
|
||||
|
||||
# Installation
|
||||
|
||||
1. Download the script and give it privilages for run
|
||||
```
|
||||
curl -LJO https://raw.githubusercontent.com/Kalarumeth/Monitoring-AirOs/main/check_airos.sh
|
||||
```
|
||||
|
||||
2. Move to Icinga Plugin Dir
|
||||
```
|
||||
Default location: /usr/lib/nagios/plugins
|
||||
```
|
||||
|
||||
3. Add command to Icinga
|
||||
```
|
||||
object CheckCommand "check_airos" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/check_airos.sh" ]
|
||||
arguments += {
|
||||
"-c" = {
|
||||
order = 0
|
||||
value = "$snmp_community$"
|
||||
}
|
||||
"-cr" = {
|
||||
order = 3
|
||||
value = "$crit$"
|
||||
}
|
||||
"-h" = {
|
||||
order = 1
|
||||
required = true
|
||||
value = "$address$"
|
||||
}
|
||||
"-t" = {
|
||||
order = 4
|
||||
required = true
|
||||
value = "$airos_type$"
|
||||
}
|
||||
"-wa" = {
|
||||
order = 2
|
||||
value = "$warn$"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Functions
|
||||
|
||||
The Script is designed to monitor the following functions:
|
||||
|
||||
- **[airmax] AirMax:**
|
||||
Show all airMax Statistics of device
|
||||
```
|
||||
AirMax Information
|
||||
Enabled: On
|
||||
Quality: 96 %
|
||||
Capacity: 45 %
|
||||
Priority: None
|
||||
NoAck: Off
|
||||
```
|
||||
|
||||
- **[info] Info:**
|
||||
Show basic information
|
||||
```
|
||||
Device Information
|
||||
Location: OUTSIDE
|
||||
UpTime: 2 days, 18:03:25.00
|
||||
LastChange: 17:01:14.00
|
||||
Ubiquiti Networks, Inc. LiteBeam M5
|
||||
airOs Ver: XW.ar934x.v6.3.6.33330.210818.1930
|
||||
```
|
||||
|
||||
- **[radio] Radio:**
|
||||
Show status and statistics of radio
|
||||
```
|
||||
Radio Information
|
||||
Mode: AP Wireless Distribution System
|
||||
Country: 380
|
||||
Frequency: 5185
|
||||
DFS: Off
|
||||
TxPower: 0
|
||||
Distance: 0
|
||||
Chainmask: 1
|
||||
Antenna: 11x14 - 23 dBi
|
||||
```
|
||||
|
||||
- **[ram] Ram:**
|
||||
Show ram usage
|
||||
```
|
||||
OK! RAM used: 25.27 / 62.14 Mb (40.67%)
|
||||
RAM free: 36.86 Mb (59.33%)
|
||||
Buffer: 2.99 Mb
|
||||
Cache: 0 Kb
|
||||
```
|
||||
|
||||
- **[station] Station:**
|
||||
Show station information, work only on station setup
|
||||
```
|
||||
Station Information
|
||||
Name: AP041
|
||||
Signal: -41 dBm
|
||||
Noise floor: -100
|
||||
CCQ: 99 %
|
||||
Con. Time: 2
|
||||
TX/RX Rate: 150 MB / 150 MB
|
||||
TX/RX Bytes: 3.39 GB / 7.88 GB
|
||||
```
|
||||
|
||||
- **[wireless] Wireless:**
|
||||
Show wireless information
|
||||
```
|
||||
Wireless Information
|
||||
SSID: Bridge
|
||||
Hide: On
|
||||
Signal: -42 dBm
|
||||
RSSI: 54 dBm
|
||||
CCQ: 99
|
||||
Noise floor: -99
|
||||
TX/RX Rate: 150 MB / 150 MB
|
||||
Security: WPA2
|
||||
WDS: On
|
||||
Ap Repeater: Off
|
||||
Channel Width: 40
|
||||
Station Count: 1
|
||||
```
|
||||
|
||||
# How it work
|
||||
|
||||
Method to compose the execution string:
|
||||
|
||||
./check_airos.sh -c <SNMP community> -h <host> [-wa <value> -cr <value>] -t <object>
|
||||
|
||||
### OPTIONS:
|
||||
|
||||
```
|
||||
-c --community SNMP v2 community string with Read access.
|
||||
Default is: public.
|
||||
-h --host [REQUIRED OPTION] Host name or IP address to check.
|
||||
Default is: localhost.
|
||||
-wa --allert-wa Defines the threshold for Warning.
|
||||
Default is: 75.
|
||||
-cr --allert-cr Defines the threshold for Critical.
|
||||
Default is: 50.
|
||||
-t --type [REQUIRED OPTION] Field for select element to check on WatchGuard Device.
|
||||
{ airmax | info | radio | ram | station | wireless }.
|
||||
-H --help Show script help.
|
||||
-V --version Show script version.
|
||||
```
|
||||
|
||||
# Credits
|
||||
|
||||
### Author
|
||||
|
||||
Kalarumeth - https://github.com/Kalarumeth
|
||||
|
||||
### License
|
||||
|
||||
MIT License - Copyright 2022 Kalarumeth
|
||||
@@ -0,0 +1,89 @@
|
||||
SNMPwalk on Ubiquiti LiteBeam M5
|
||||
|
||||
Device Information
|
||||
|
||||
iso.2.840.10036.3.1.2.1.2.5 = STRING: "Ubiquiti Networks, Inc." dot11manufacturerName
|
||||
iso.2.840.10036.3.1.2.1.3.5 = STRING: "LiteBeam M5" dot11manufacturerProductName
|
||||
iso.2.840.10036.3.1.2.1.4.5 = STRING: "XW.ar934x.v6.3.6.33330.210818.1930" dot11manufacturerPro
|
||||
|
||||
|
||||
iso.3.6.1.2.1.1.1.0 = STRING: "Linux 2.6.32.71 #1 Wed Aug 18 19:31:33 EEST 2021 mips" sysDescr
|
||||
iso.3.6.1.2.1.1.3.0 = Timeticks: (58100) 0:09:41.00 sysUpTime
|
||||
iso.3.6.1.2.1.1.4.0 = STRING: "PAL" sysContact
|
||||
iso.3.6.1.2.1.1.5.0 = STRING: "PALAP052" sysName
|
||||
iso.3.6.1.2.1.1.6.0 = STRING: "PAL5" sysLocation
|
||||
iso.3.6.1.2.1.1.7.0 = INTEGER: 79 sysServices
|
||||
iso.3.6.1.2.1.1.8.0 = Timeticks: (29700) 0:04:57.00 sysORLastChange
|
||||
|
||||
Memory
|
||||
|
||||
iso.3.6.1.4.1.10002.1.1.1.1.1.0 = Gauge32: 62136 memTotal KB
|
||||
iso.3.6.1.4.1.10002.1.1.1.1.2.0 = Gauge32: 40468 memFree KB
|
||||
iso.3.6.1.4.1.10002.1.1.1.1.3.0 = Gauge32: 1980 memBuffer KB
|
||||
iso.3.6.1.4.1.10002.1.1.1.1.4.0 = Gauge32: 0 memCache KB
|
||||
|
||||
Cpu
|
||||
|
||||
iso.3.6.1.4.1.10002.1.1.1.2.1.0 = Gauge32: 0 cpuModLoad
|
||||
iso.3.6.1.4.1.10002.1.1.1.2.2.0 = Gauge32: 0 cpuModUsage
|
||||
|
||||
Radio status & statistics
|
||||
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.1.1 = INTEGER: 5
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.2.1 = INTEGER: 1 ubntRadioMode Radio mode sta(1), ap(2), aprepeater(3), apwds(4)
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.3.1 = INTEGER: 380 ubntRadioCCode Country code
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.4.1 = INTEGER: 5180 ubntRadioFreq Operation frequency
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.5.1 = INTEGER: 2 ubntRadioDfsEnabled DFS status
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.6.1 = INTEGER: 0 ubntRadioTxPower Transmit power
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.7.1 = INTEGER: 0 ubntRadioDistance Distance
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.8.1 = INTEGER: 1 ubntRadioChainmask Chainmask
|
||||
iso.3.6.1.4.1.41112.1.4.1.1.9.1 = STRING: "11x14 - 23 dBi" ubntRadioAntenna Antenna
|
||||
|
||||
Wireless Statistic
|
||||
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.1.1 = INTEGER: 5 wireless index
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.2.1 = STRING: "PAL2-PAL5 Bridge" ubntWlStatSsid SSID
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.3.1 = INTEGER: 2 ubntWlStatHideSsid hide on/[off]
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.4.1 = Hex-STRING: 68 D7 9A 9C CC D4 ubntWlStatApMac AP MAC
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.5.1 = INTEGER: -47 ubntWlStatSignal Intensità del segnale, dbm
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.6.1 = INTEGER: 49 ubntWlStatRssi RSSI, dbm
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.7.1 = INTEGER: 86 ubntWlStatCcq Client Connection Quality %
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.8.1 = INTEGER: -98 ubntWlStatNoiseFloor Rumore di fondo dbm
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.9.1 = INTEGER: 150000000 ubntWlStatTxRate TX
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.10.1 = INTEGER: 150000000 ubntWlStatRxRate RX Mbps
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.11.1 = STRING: "WPA2" ubntWlStatSecurity
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.12.1 = INTEGER: 2 ubntWlStatWdsEnabled on/off
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.13.1 = INTEGER: 2 ubntWlStatApRepeater on/off
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.14.1 = INTEGER: 40 ubntWlStatChanWidth
|
||||
iso.3.6.1.4.1.41112.1.4.5.1.15.1 = Gauge32: 1 ubntWlStatStaCount
|
||||
|
||||
airMax Statistic
|
||||
|
||||
iso.3.6.1.4.1.41112.1.4.6.1.1.1 = INTEGER: 5 airMax index
|
||||
iso.3.6.1.4.1.41112.1.4.6.1.2.1 = INTEGER: 1 ubntAirMaxEnabled airMax [on]/off
|
||||
iso.3.6.1.4.1.41112.1.4.6.1.3.1 = INTEGER: 97 ubntAirMaxQuality Qualità airMax %
|
||||
iso.3.6.1.4.1.41112.1.4.6.1.4.1 = INTEGER: 45 ubntAirMaxCapacity Capacità airMax
|
||||
iso.3.6.1.4.1.41112.1.4.6.1.5.1 = INTEGER: 2 ubntAirMaxPriority Priority none(3)/high(0)/low(2)/medium(1)
|
||||
iso.3.6.1.4.1.41112.1.4.6.1.6.1 = INTEGER: 2 ubntAirMaxNoAck NoACK on/[off]
|
||||
|
||||
Station Statistic work only for station
|
||||
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.1.1.104.215.154.156.204.212 = Hex-STRING: 68 D7 9A 9C CC D4 ubntStaMac Mac
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.2.1.104.215.154.156.204.212 = STRING: "PALAP051" ubntStaName Hostname station name
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.3.1.104.215.154.156.204.212 = INTEGER: -47 ubntStaSignal Signal strenght, dBm
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.4.1.104.215.154.156.204.212 = INTEGER: -98 ubntStaNoiseFloor Noise floor
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.5.1.104.215.154.156.204.212 = INTEGER: 0 ubntStaDistance Distance
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.6.1.104.215.154.156.204.212 = INTEGER: 88 ubntStaCcq CCQ %
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.7.1.104.215.154.156.204.212 = INTEGER: 3 ubntStaAmp airMax priority
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.8.1.104.215.154.156.204.212 = INTEGER: 0 ubntStaAmq airMax Quality
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.9.1.104.215.154.156.204.212 = INTEGER: 0 ubntStaAmc airMax Capacity
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.10.1.104.215.154.156.204.212 = IpAddress: 172.16.252.4 ubntStaLastIp last ip
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.11.1.104.215.154.156.204.212 = INTEGER: 150000000 ubntStaTxRate TX rate
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.12.1.104.215.154.156.204.212 = INTEGER: 150000000 ubntStaRxRate RX rate
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.13.1.104.215.154.156.204.212 = Counter64: 51875 ubntStaTxBytes TX Bytes
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.14.1.104.215.154.156.204.212 = Counter64: 23356 ubntStaRxBytes RX Bytes
|
||||
iso.3.6.1.4.1.41112.1.4.7.1.15.1.104.215.154.156.204.212 = Timeticks: (19800) 0:03:18.00 ubntStaConnTime Connection time
|
||||
|
||||
End of MIB
|
||||
|
||||
the selected device is not a station
|
||||
@@ -0,0 +1,448 @@
|
||||
#!/bin/bash
|
||||
|
||||
# - VAR
|
||||
|
||||
# - Bash info
|
||||
APPNAME=$(basename $0)
|
||||
NAME="Check Ubiquiti LiteBeam M5"
|
||||
AUTHOR="Kalarumeth"
|
||||
VERSION="v0.1"
|
||||
URL="https://github.com/Kalarumeth"
|
||||
|
||||
# - Default settings for connection
|
||||
COMMUNITY="public"
|
||||
HOST_NAME="localhost"
|
||||
SNMPVERSION="1"
|
||||
|
||||
# - State Variables
|
||||
STATE_OK=0
|
||||
STATE_WARN=1
|
||||
STATE_CRIT=2
|
||||
STATE_UNK=3
|
||||
STATE=$STATE_OK
|
||||
|
||||
# - Range Variables
|
||||
WA=75
|
||||
CR=50
|
||||
|
||||
# - OID
|
||||
|
||||
UBNT.GetOIDS() {
|
||||
#Device Information
|
||||
OID_dot11manufacturerName="1.2.840.10036.3.1.2.1.2.5"
|
||||
OID_dot11manufacturerProductName="1.2.840.10036.3.1.2.1.3.5"
|
||||
OID_dot11manufacturerProductVersion="1.2.840.10036.3.1.2.1.4.5"
|
||||
OID_sysDescr="1.3.6.1.2.1.1.1.0"
|
||||
OID_sysUpTime="1.3.6.1.2.1.1.3.0"
|
||||
OID_sysContact="1.3.6.1.2.1.1.4.0"
|
||||
OID_sysName="1.3.6.1.2.1.1.5.0"
|
||||
OID_sysLocation="1.3.6.1.2.1.1.6.0"
|
||||
OID_sysORLastChange="1.3.6.1.2.1.1.8.0"
|
||||
|
||||
#Memory
|
||||
OID_memTotal="1.3.6.1.4.1.10002.1.1.1.1.1.0"
|
||||
OID_memFree="1.3.6.1.4.1.10002.1.1.1.1.2.0"
|
||||
OID_memBuffer="1.3.6.1.4.1.10002.1.1.1.1.3.0"
|
||||
OID_memCache="1.3.6.1.4.1.10002.1.1.1.1.4.0"
|
||||
|
||||
#Radio status & statistics
|
||||
OID_ubntRadioMode="1.3.6.1.4.1.41112.1.4.1.1.2.1"
|
||||
OID_ubntRadioCCode="1.3.6.1.4.1.41112.1.4.1.1.3.1"
|
||||
OID_ubntRadioFreq="1.3.6.1.4.1.41112.1.4.1.1.4.1"
|
||||
OID_ubntRadioDfsEnabled="1.3.6.1.4.1.41112.1.4.1.1.5.1"
|
||||
OID_ubntRadioTxPower="1.3.6.1.4.1.41112.1.4.1.1.6.1"
|
||||
OID_ubntRadioDistance="1.3.6.1.4.1.41112.1.4.1.1.7.1"
|
||||
OID_ubntRadioChainmask="1.3.6.1.4.1.41112.1.4.1.1.8.1"
|
||||
OID_ubntRadioAntenna="1.3.6.1.4.1.41112.1.4.1.1.9.1"
|
||||
|
||||
#Wireless statistics
|
||||
OID_ubntWlStatSsid="1.3.6.1.4.1.41112.1.4.5.1.2.1"
|
||||
OID_ubntWlStatHideSsid="1.3.6.1.4.1.41112.1.4.5.1.3.1"
|
||||
OID_ubntWlStatApMac="1.3.6.1.4.1.41112.1.4.5.1.4.1"
|
||||
OID_ubntWlStatSignal="1.3.6.1.4.1.41112.1.4.5.1.5.1"
|
||||
OID_ubntWlStatRssi="1.3.6.1.4.1.41112.1.4.5.1.6.1"
|
||||
OID_ubntWlStatCcq="1.3.6.1.4.1.41112.1.4.5.1.7.1"
|
||||
OID_ubntWlStatNoiseFloor="1.3.6.1.4.1.41112.1.4.5.1.8.1"
|
||||
OID_ubntWlStatTxRate="1.3.6.1.4.1.41112.1.4.5.1.9.1"
|
||||
OID_ubntWlStatRxRate="1.3.6.1.4.1.41112.1.4.5.1.10.1"
|
||||
OID_ubntWlStatSecurity="1.3.6.1.4.1.41112.1.4.5.1.11.1"
|
||||
OID_ubntWlStatWdsEnabled="1.3.6.1.4.1.41112.1.4.5.1.12.1"
|
||||
OID_ubntWlStatApRepeater="1.3.6.1.4.1.41112.1.4.5.1.13.1"
|
||||
OID_ubntWlStatChanWidth="1.3.6.1.4.1.41112.1.4.5.1.14.1"
|
||||
OID_ubntWlStatStaCount="1.3.6.1.4.1.41112.1.4.5.1.15.1"
|
||||
|
||||
#AirMax Statistics
|
||||
OID_ubntAirMaxEnabled="1.3.6.1.4.1.41112.1.4.6.1.2.1"
|
||||
OID_ubntAirMaxQuality="1.3.6.1.4.1.41112.1.4.6.1.3.1"
|
||||
OID_ubntAirMaxCapacity="1.3.6.1.4.1.41112.1.4.6.1.4.1"
|
||||
OID_ubntAirMaxPriority="1.3.6.1.4.1.41112.1.4.6.1.5.1"
|
||||
OID_ubntAirMaxNoAck="1.3.6.1.4.1.41112.1.4.6.1.6.1"
|
||||
|
||||
#Station Statistics
|
||||
OID_ubntStaName="1.3.6.1.4.1.41112.1.4.7.1.2.1.104.215.154.156.204.212"
|
||||
OID_ubntStaSignal="1.3.6.1.4.1.41112.1.4.7.1.3.1.104.215.154.156.204.212"
|
||||
OID_ubntStaNoiseFloor="1.3.6.1.4.1.41112.1.4.7.1.4.1.104.215.154.156.204.212"
|
||||
OID_ubntStaDistance="1.3.6.1.4.1.41112.1.4.7.1.5.1.104.215.154.156.204.212"
|
||||
OID_ubntStaCcq="1.3.6.1.4.1.41112.1.4.7.1.6.1.104.215.154.156.204.212"
|
||||
OID_ubntStaAmp="1.3.6.1.4.1.41112.1.4.7.1.7.1.104.215.154.156.204.212"
|
||||
OID_ubntStaAmq="1.3.6.1.4.1.41112.1.4.7.1.8.1.104.215.154.156.204.212"
|
||||
OID_ubntStaAmc="1.3.6.1.4.1.41112.1.4.7.1.9.1.104.215.154.156.204.212"
|
||||
OID_ubntStaLastIp="1.3.6.1.4.1.41112.1.4.7.1.10.1.104.215.154.156.204.212"
|
||||
OID_ubntStaTxRate="1.3.6.1.4.1.41112.1.4.7.1.11.1.104.215.154.156.204.212"
|
||||
OID_ubntStaRxRate="1.3.6.1.4.1.41112.1.4.7.1.12.1.104.215.154.156.204.212"
|
||||
OID_ubntStaTxBytes="1.3.6.1.4.1.41112.1.4.7.1.13.1.104.215.154.156.204.212"
|
||||
OID_ubntStaRxBytes="1.3.6.1.4.1.41112.1.4.7.1.14.1.104.215.154.156.204.212"
|
||||
OID_ubntStaConnTime="1.3.6.1.4.1.41112.1.4.7.1.15.1.104.215.154.156.204.212"
|
||||
}
|
||||
|
||||
UBNT.GetData() {
|
||||
UBNT.GetOIDS
|
||||
|
||||
case $1 in
|
||||
airmax)
|
||||
ubntAirMaxEnabled=$(Source.SNMP $OID_ubntAirMaxEnabled | cut -d ' ' -f 4)
|
||||
ubntAirMaxQuality=$(Source.SNMP $OID_ubntAirMaxQuality | cut -d ' ' -f 4)
|
||||
ubntAirMaxCapacity=$(Source.SNMP $OID_ubntAirMaxCapacity | cut -d ' ' -f 4)
|
||||
ubntAirMaxPriority=$(Source.SNMP $OID_ubntAirMaxPriority | cut -d ' ' -f 4)
|
||||
ubntAirMaxNoAck=$(Source.SNMP $OID_ubntAirMaxNoAck | cut -d ' ' -f 4)
|
||||
;;
|
||||
info)
|
||||
dot11manufacturerName=$(Source.SNMP $OID_dot11manufacturerName | cut -d '"' -f 2)
|
||||
dot11manufacturerProductName=$(Source.SNMP $OID_dot11manufacturerProductName | cut -d '"' -f 2)
|
||||
dot11manufacturerProductVersion=$(Source.SNMP $OID_dot11manufacturerProductVersion | cut -d '"' -f 2)
|
||||
sysDescr=$(Source.SNMP $OID_sysDescr | cut -d '"' -f 2)
|
||||
sysUpTime=$(Source.SNMP $OID_sysUpTime | cut -d ' ' -f 5)
|
||||
sysLocation=$(Source.SNMP $OID_sysLocation | cut -d '"' -f 2)
|
||||
sysORLastChange=$(Source.SNMP $OID_sysORLastChange | cut -d ' ' -f 5)
|
||||
;;
|
||||
radio)
|
||||
ubntRadioMode=$(Source.SNMP $OID_ubntRadioMode | cut -d ' ' -f 4)
|
||||
ubntRadioCCode=$(Source.SNMP $OID_ubntRadioCCode | cut -d ' ' -f 4)
|
||||
ubntRadioFreq=$(Source.SNMP $OID_ubntRadioFreq | cut -d ' ' -f 4)
|
||||
ubntRadioDfsEnabled=$(Source.SNMP $OID_ubntRadioDfsEnabled | cut -d ' ' -f 4)
|
||||
ubntRadioTxPower=$(Source.SNMP $OID_ubntRadioTxPower | cut -d ' ' -f 4)
|
||||
ubntRadioDistance=$(Source.SNMP $OID_ubntRadioDistance | cut -d ' ' -f 4)
|
||||
ubntRadioChainmask=$(Source.SNMP $OID_ubntRadioChainmask | cut -d ' ' -f 4)
|
||||
ubntRadioAntenna=$(Source.SNMP $OID_ubntRadioAntenna | cut -d '"' -f 2)
|
||||
;;
|
||||
ram)
|
||||
rawRamAll=$(Source.SNMP $OID_memTotal | cut -d ' ' -f 4)
|
||||
rawRamFree=$(Source.SNMP $OID_memFree | cut -d ' ' -f 4)
|
||||
valueRamAllMb=$(echo "$rawRamAll" | awk '{ mbyte = $1 /1000; print mbyte }' | xargs printf "%.2f")
|
||||
valueRamFreeMb=$(echo "$rawRamFree" | awk '{ mbyte = $1 /1000; print mbyte }' | xargs printf "%.2f")
|
||||
printPercetageRam=$(echo "$rawRamFree" "$rawRamAll" | awk '{ ramp = $1 /$2 *100; print ramp }' | xargs printf "%.2f")
|
||||
printPercetageRamUsed=$(echo "$printPercetageRam" | awk '{ ramup = 100 - $1; print ramup }')
|
||||
rangePercetageRam=$(echo "$printPercetageRamUsed" | cut -d "." -f1)
|
||||
rawRamUsed=$(echo "$rawRamAll" "$rawRamFree" | awk '{ used = $1 -$2; print used }')
|
||||
valueRamUsedMb=$(echo "$rawRamUsed" | awk '{ mbyte = $1 /1000; print mbyte }' | xargs printf "%.2f")
|
||||
rawmemBuffer=$(Source.SNMP $OID_memBuffer | cut -d ' ' -f 4)
|
||||
memBuffer=$(echo "$rawmemBuffer" | awk '{ mbyte = $1 /1000; print mbyte }' | xargs printf "%.2f")
|
||||
memCache=$(Source.SNMP $OID_memCache | cut -d ' ' -f 4)
|
||||
;;
|
||||
station)
|
||||
mode=$(Source.SNMP $OID_ubntRadioMode | cut -d ' ' -f 4)
|
||||
ubntStaName=$(Source.SNMP $OID_ubntStaName | cut -d '"' -f 2)
|
||||
ubntStaSignal=$(Source.SNMP $OID_ubntStaSignal | cut -d ' ' -f 4)
|
||||
ubntStaNoiseFloor=$(Source.SNMP $OID_ubntStaNoiseFloor | cut -d ' ' -f 4)
|
||||
ubntStaCcq=$(Source.SNMP $OID_ubntStaCcq | cut -d ' ' -f 4)
|
||||
ubntStaTxRate=$(Source.SNMP $OID_ubntStaTxRate | cut -d ' ' -f 4)
|
||||
ubntStaRxRate=$(Source.SNMP $OID_ubntStaRxRate | cut -d ' ' -f 4)
|
||||
ubntStaTxBytes=$(Source.SNMP $OID_ubntStaTxBytes | cut -d ' ' -f 4)
|
||||
ubntStaRxBytes=$(Source.SNMP $OID_ubntStaRxBytes | cut -d ' ' -f 4)
|
||||
ubntStaConnTime=$(Source.SNMP $OID_ubntStaConnTime | cut -d ' ' -f 5)
|
||||
;;
|
||||
wireless)
|
||||
ubntWlStatSsid=$(Source.SNMP $OID_ubntWlStatSsid | cut -d '"' -f 2)
|
||||
ubntWlStatHideSsid=$(Source.SNMP $OID_ubntWlStatHideSsid | cut -d ' ' -f 4)
|
||||
ubntWlStatApMac=$(Source.SNMP $OID_ubntWlStatApMac | cut -d ' ' -f 4)
|
||||
ubntWlStatSignal=$(Source.SNMP $OID_ubntWlStatSignal | cut -d ' ' -f 4)
|
||||
ubntWlStatRssi=$(Source.SNMP $OID_ubntWlStatRssi | cut -d ' ' -f 4)
|
||||
ubntWlStatCcq=$(Source.SNMP $OID_ubntWlStatCcq | cut -d ' ' -f 4)
|
||||
ubntWlStatNoiseFloor=$(Source.SNMP $OID_ubntWlStatNoiseFloor | cut -d ' ' -f 4)
|
||||
ubntWlStatTxRate=$(Source.SNMP $OID_ubntWlStatTxRate | cut -d ' ' -f 4)
|
||||
ubntWlStatRxRate=$(Source.SNMP $OID_ubntWlStatRxRate | cut -d ' ' -f 4)
|
||||
ubntWlStatSecurity=$(Source.SNMP $OID_ubntWlStatSecurity | cut -d '"' -f 2)
|
||||
ubntWlStatWdsEnabled=$(Source.SNMP $OID_ubntWlStatWdsEnabled | cut -d ' ' -f 4)
|
||||
ubntWlStatApRepeater=$(Source.SNMP $OID_ubntWlStatApRepeater | cut -d ' ' -f 4)
|
||||
ubntWlStatChanWidth=$(Source.SNMP $OID_ubntWlStatChanWidth | cut -d ' ' -f 4)
|
||||
ubntWlStatStaCount=$(Source.SNMP $OID_ubntWlStatStaCount | cut -d ' ' -f 4)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# - MAIN CODE
|
||||
|
||||
Source.HostAlive() {
|
||||
for server in $HOST_NAME; do
|
||||
ping -c1 -W1 -q $server &>/dev/null
|
||||
if [[ $? != 0 ]] ; then
|
||||
printf "%s\n" "$server is unreachable"
|
||||
exit $STATE_UNK
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
Source.SNMP() {
|
||||
snmpwalk -v $SNMPVERSION -r 1 -t 10 -Oe -c $COMMUNITY $HOST_NAME $1
|
||||
}
|
||||
|
||||
Source.SNMP.Hex() {
|
||||
snmpwalk -v $SNMPVERSION -r 1 -t 10 -Oa -c $COMMUNITY $HOST_NAME $1
|
||||
}
|
||||
|
||||
# - Ubiquiti Status Variables
|
||||
|
||||
GetStatus.OnOff() {
|
||||
case $1 in
|
||||
1) local sED="On" ;;
|
||||
2) local sED="Off" ;;
|
||||
esac
|
||||
|
||||
echo $sED
|
||||
}
|
||||
|
||||
GetStatus.BToMB() {
|
||||
local value=$(echo "$1" | awk '{ mbyte = $1 /1000/1000; print mbyte }' | xargs printf "%.f")
|
||||
echo "$value MB"
|
||||
}
|
||||
|
||||
GetStatus.BToGB() {
|
||||
local value=$(echo "$1" | awk '{ gbyte = $1 /1000/1000/1000; print gbyte }' | xargs printf "%.2f")
|
||||
echo "$value GB"
|
||||
}
|
||||
|
||||
GetStatus.RadioMode() {
|
||||
case $1 in
|
||||
1) local sRM="Station" ;;
|
||||
2) local sRM="Access Point" ;;
|
||||
3) local sRM="AP Repeater" ;;
|
||||
4) local sRM="AP Wireless Distribution System" ;;
|
||||
esac
|
||||
|
||||
echo $sRM
|
||||
}
|
||||
|
||||
GetStatus.CheckStaMode() {
|
||||
if [[ $1 != "1" ]]; then
|
||||
printf "%s\n%s\n%s\n" "The following device isn't set to Station." "Is setted on '$(GetStatus.RadioMode $1)'," "disable the following service for this device." && exit $STATE_UNK
|
||||
fi
|
||||
}
|
||||
|
||||
GetStatus.AMQuality() {
|
||||
if [[ $1 < $CR-1 ]]; then
|
||||
local sQuality="CRIT!"
|
||||
STATE=$STATE_CRIT
|
||||
elif [[ $1 < $WA-1 ]]; then
|
||||
local sQuality="WARN!"
|
||||
STATE=$STATE_WARN
|
||||
fi
|
||||
|
||||
echo "$1" "%" "$sQuality"
|
||||
}
|
||||
|
||||
GetStatus.AMPriority() {
|
||||
case $1 in
|
||||
0) local sAMP="High" ;;
|
||||
1) local sAMP="Medium" ;;
|
||||
2) local sAMP="Low" ;;
|
||||
3) local sAMP="None" ;;
|
||||
esac
|
||||
|
||||
echo $sAMP
|
||||
}
|
||||
|
||||
# - Ubiquiti Monitoring
|
||||
|
||||
UBNT.Main() {
|
||||
Source.HostAlive
|
||||
|
||||
case $1 in
|
||||
airmax)
|
||||
UBNT.AirMax
|
||||
exit $STATE ;;
|
||||
info)
|
||||
UBNT.Info
|
||||
exit $STATE ;;
|
||||
radio)
|
||||
UBNT.Radio
|
||||
exit $STATE ;;
|
||||
ram)
|
||||
UBNT.Ram
|
||||
exit $STATE ;;
|
||||
station)
|
||||
UBNT.Station
|
||||
exit $STATE ;;
|
||||
wireless)
|
||||
UBNT.Wireless
|
||||
exit $STATE ;;
|
||||
*)
|
||||
echo "Unknown check!"
|
||||
Help.UBNT
|
||||
exit $STATE_UNK ;;
|
||||
esac
|
||||
}
|
||||
|
||||
UBNT.AirMax() {
|
||||
UBNT.GetData airmax
|
||||
|
||||
printf "%s\n\n" "AirMax Information"
|
||||
|
||||
printf "%s\t%s\n" "Enabled:" "$(GetStatus.OnOff $ubntAirMaxEnabled)"
|
||||
printf "%s\t%s\n" "Quality:" "$(GetStatus.AMQuality $ubntAirMaxQuality)"
|
||||
printf "%s\t%s\n" "Capacity:" "$ubntAirMaxCapacity %"
|
||||
printf "%s\t%s\n" "Priority:" "$(GetStatus.AMPriority $ubntAirMaxPriority)"
|
||||
printf "%s\t\t%s\n" "NoAck:" "$(GetStatus.OnOff $ubntAirMaxNoAck)"
|
||||
}
|
||||
|
||||
UBNT.Info() {
|
||||
UBNT.GetData info
|
||||
|
||||
printf "%s\n\n" "Device Information"
|
||||
|
||||
printf "%s\t%s\n" "Location:" "$sysLocation"
|
||||
printf "%s\t\t%s\n" "UpTime:" "$sysUpTime"
|
||||
printf "%s\t%s\n\n" "LastChange:" "$sysORLastChange"
|
||||
|
||||
printf "%s%s\n" "$dot11manufacturerProductName" "$dot11manufacturerName"
|
||||
printf "%s\t%s\n" "airOs Ver:" "$dot11manufacturerProductVersion"
|
||||
}
|
||||
|
||||
UBNT.Radio() {
|
||||
UBNT.GetData radio
|
||||
|
||||
printf "%s\n\n" "Radio Information"
|
||||
|
||||
printf "%s\t\t%s\n" "Mode:" "$(GetStatus.RadioMode $ubntRadioMode)"
|
||||
printf "%s\t%s\n" "Country:" "$ubntRadioCCode"
|
||||
printf "%s\t%s\n" "Frequency:" "$ubntRadioFreq"
|
||||
printf "%s\t\t%s\n" "DFS:" "$(GetStatus.OnOff $ubntRadioDfsEnabled)"
|
||||
printf "%s\t%s\n" "TxPower:" "$ubntRadioTxPower"
|
||||
printf "%s\t%s\n" "Distance:" "$ubntRadioDistance"
|
||||
printf "%s\t%s\n" "Chainmask:" "$ubntRadioChainmask"
|
||||
printf "%s\t%s\n" "Antenna:" "$ubntRadioAntenna"
|
||||
}
|
||||
|
||||
UBNT.Ram() {
|
||||
UBNT.GetData ram
|
||||
|
||||
case 1 in
|
||||
$(($rangePercetageRam <= $WA-1)))
|
||||
printf "%s\n" "OK! RAM used: $valueRamUsedMb / $valueRamAllMb Mb ($printPercetageRamUsed%)" "RAM free: $valueRamFreeMb Mb ($printPercetageRam%)" "Buffer: $memBuffer Mb" "Cache: $memCache Kb" && exit $STATE_OK ;;
|
||||
$(($rangePercetageRam <= $CR-1)))
|
||||
printf "%s\n" "WARRING! RAM used: $valueRamUsedMb / $valueRamAllMb Mb ($printPercetageRamUsed%)" "RAM free: $valueRamFreeMb Mb ($printPercetageRam%)" "Buffer: $memBuffer Mb" "Cache: $memCache Kb" && exit $STATE_WARN ;;
|
||||
$(($rangePercetageRam > $CR-1)))
|
||||
printf "%s\n" "CRITICAL! RAM used: $valueRamUsedMb / $valueRamAllMb Mb ($printPercetageRamUsed%)" "RAM free: $valueRamFreeMb Mb ($printPercetageRam%)" "Buffer: $memBuffer Mb" "Cache: $memCache Kb" && exit $STATE_CRIT ;;
|
||||
esac
|
||||
}
|
||||
|
||||
UBNT.Station() {
|
||||
UBNT.GetData station
|
||||
GetStatus.CheckStaMode $mode
|
||||
|
||||
printf "%s\n\n" "Station Information"
|
||||
|
||||
printf "%s\t\t%s\n" "Name:" "$ubntStaName"
|
||||
printf "%s\t\t%s\n" "Signal:" "$ubntStaSignal dBm"
|
||||
printf "%s\t%s\n" "Noise floor:" "$ubntStaNoiseFloor"
|
||||
printf "%s\t\t%s\n" "CCQ:" "$ubntStaCcq %"
|
||||
printf "%s\t%s\n\n" "Con. Time:" "$(echo $ubntStaConnTime)"
|
||||
|
||||
printf "%s\t%s\n" "TX/RX Rate:" "$(GetStatus.BToMB $ubntStaTxRate) / $(GetStatus.BToMB $ubntStaRxRate)"
|
||||
printf "%s\t%s\n" "TX/RX Bytes:" "$(GetStatus.BToGB $ubntStaTxBytes) / $(GetStatus.BToGB $ubntStaRxBytes)"
|
||||
}
|
||||
|
||||
UBNT.Wireless() {
|
||||
UBNT.GetData wireless
|
||||
|
||||
printf "%s\n\n" "Wireless Information"
|
||||
|
||||
printf "%s\t\t%s\n" "SSID:" "$ubntWlStatSsid"
|
||||
printf "%s\t\t%s\n" "Hide:" "$(GetStatus.OnOff $ubntWlStatHideSsid)"
|
||||
printf "%s\t\t%s\n" "Signal:" "$ubntWlStatSignal dBm"
|
||||
printf "%s\t\t%s\n" "RSSI:" "$ubntWlStatRssi dBm"
|
||||
printf "%s\t\t%s\n" "CCQ:" "$ubntWlStatCcq"
|
||||
printf "%s\t%s\n" "Noise floor:" "$ubntWlStatNoiseFloor"
|
||||
printf "%s\t%s\n" "TX/RX Rate:" "$(GetStatus.BToMB $ubntWlStatTxRate) / $(GetStatus.BToMB $ubntWlStatRxRate)"
|
||||
printf "%s\t%s\n" "Security:" "$ubntWlStatSecurity"
|
||||
printf "%s\t\t%s\n" "WDS:" "$(GetStatus.OnOff $ubntWlStatWdsEnabled)"
|
||||
printf "%s\t%s\n" "Ap Repeater:" "$(GetStatus.OnOff $ubntWlStatApRepeater)"
|
||||
printf "%s\t%s\n" "Channel Width:" "$ubntWlStatChanWidth"
|
||||
printf "%s\t%s\n" "Station Count:" "$ubntWlStatStaCount"
|
||||
}
|
||||
|
||||
# - Help
|
||||
|
||||
Help.Main() {
|
||||
echo $NAME
|
||||
echo ''
|
||||
Help.Usage
|
||||
echo ''
|
||||
Help.Option
|
||||
echo ''
|
||||
Help.Info
|
||||
echo ''
|
||||
exit $STATE_UNK
|
||||
}
|
||||
|
||||
Help.Usage() {
|
||||
printf "%s\n" "Method to compose the execution string"
|
||||
printf "%s\n" "./$APPNAME -c <SNMP community> -h <host> -t <check>"
|
||||
}
|
||||
|
||||
Help.Option() {
|
||||
printf "%s\n" "OPTIONS:"
|
||||
printf "%s\t%s\t%s\n\t\t\t%s\n" "-c" "--community" "SNMP v2 community string with Read access." " Default is $COMMUNITY."
|
||||
printf "%s\t%s\t\t%s\n\t\t\t%s\n" "-h" "--host" "Host name or IP address to check." " Default is $HOST_NAME."
|
||||
printf "%s\t%s\t\t%s\n\t\t\t%s\n" "-t" "--type" "[REQUIRED OPTION] Field for select element to check on AirOs Device." "{ airmax | info | radio | ram | station | wireless }"
|
||||
printf "%s\t%s\t\t%s\n" "-H" "--help" "Show Script help"
|
||||
printf "%s\t%s\t%s\n" "-V" "--version" "Show Script version"
|
||||
}
|
||||
|
||||
Help.UBNT() {
|
||||
printf "\n%s\n\n" "Ubiquiti airOs Check Function"
|
||||
printf "%s\t%s\n\n" "Check" "Description"
|
||||
printf "%s\t%s\n" "airmax" "Show all airMax Statistics of device"
|
||||
printf "%s\t%s\n" "info" "Show basic information"
|
||||
printf "%s\t%s\n" "radio" "Show status and statistics of radio"
|
||||
printf "%s\t%s\n" "ram" "Show ram usage"
|
||||
printf "%s\t%s\n" "station" "Show station information, work only on station setup"
|
||||
printf "%s\t%s\n" "wireless" "Show wireless information"
|
||||
}
|
||||
|
||||
Help.Info() {
|
||||
printf "%s\t%s\t%s\n" "INFO:" "$NAME" "$VERSION" "" "$AUTHOR" "$URL"
|
||||
}
|
||||
|
||||
# - COMMAND LINE ENCODER
|
||||
|
||||
while test -n "$1"; do
|
||||
case "$1" in
|
||||
--host | -h)
|
||||
HOST_NAME=$2
|
||||
shift ;;
|
||||
--comunity | -c)
|
||||
COMMUNITY=$2
|
||||
shift ;;
|
||||
--allert-wa|-wa)
|
||||
WA=$2
|
||||
shift ;;
|
||||
--allert-cr|-cr)
|
||||
CR=$2
|
||||
shift ;;
|
||||
--type | -t)
|
||||
UBNT.Main $2
|
||||
shift ;;
|
||||
--help | -H)
|
||||
Help.Main ;;
|
||||
--version | -V)
|
||||
Help.Info
|
||||
exit $STATE ;;
|
||||
*)
|
||||
echo "Unknown argument: $1"
|
||||
print_help
|
||||
exit $STATE_UNK ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
UBNT.Main
|
||||
Reference in New Issue
Block a user