diff --git a/snmp/Openwrt/README.md b/snmp/Openwrt/README.md new file mode 100644 index 000000000..70f7c2ce2 --- /dev/null +++ b/snmp/Openwrt/README.md @@ -0,0 +1,263 @@ +# OpenWrt-LibreNMS +SNMPD OpenWrt configuration - integration for OpenWrt devices to be visible wtih more features in LibreNMS network management platform. Based on https://github.com/librenms/librenms-agent/tree/master/snmp/Openwrt + +This package provides unified, auto-detecting SNMP monitoring for OpenWrt devices with support for: +- Wireless interface metrics (clients, frequency, rate, noise, SNR) +- Thermal sensor monitoring via LM-SENSORS-MIB +- Auto-discovery of wireless interfaces +- Dynamic configuration generation + +## Key Features + +### 1. Auto-Generation of wlInterfaces.txt + +`wlClients.sh` auto-detects all wireless interfaces on first run and generates the file automatically. + +```bash +# First run automatically creates wlInterfaces.txt +/etc/librenms/wlClients.sh +``` + +### 2. Dynamic Config Generator +**Problem**: Different devices need different snmpd configs based on their wireless interfaces (ap1: wl0-ap0, wl1-ap0; ap2: wlan0, wlan02, wlan12, wlan22). + +**Solution**: `snmpd-config-generator.sh` reads wlInterfaces.txt and generates appropriate UCI config entries for all detected interfaces. + +```bash +# Generate config for current device +/etc/librenms/snmpd-config-generator.sh +``` + +### 3. Unified Base Configuration +**Problem**: Repetitive config entries across devices. + +**Solution**: /etc/config/snmpd is updated with dynamic content. + +### 4. Error Handling +All scripts have: +- Error messages +- Argument validation +- Fallback behavior +- Consistent exit codes + +### 5. Thermal Sensor Support (LM-SENSORS-MIB) +Uses the `pass` directive to provide proper LM-SENSORS-MIB thermal sensors: +- `.1.3.6.1.4.1.2021.13.16.2.1.1` - lmTempSensorsIndex (INTEGER) +- `.1.3.6.1.4.1.2021.13.16.2.1.2` - lmTempSensorsDevice (STRING) +- `.1.3.6.1.4.1.2021.13.16.2.1.3` - lmTempSensorsValue (Gauge32, millidegrees) + +The `pass` script (`lm-sensors-pass.sh`) provides proper data types and table structure, enabling automatic discovery in LibreNMS. + +## File Structure + +``` +/etc/librenms/ +├── wlInterfaces.txt # Auto-generated interface list +├── wlClients.sh # Count Wi-Fi clients (auto-generates wlInterfaces.txt) +├── wlFrequency.sh # Get operating frequency +├── wlNoiseFloor.sh # Get noise floor +├── wlRate.sh # Get TX/RX rates (min/avg/max) +├── wlSNR.sh # Get SNR (min/avg/max) +├── lm-sensors-pass.sh # LM-SENSORS-MIB pass script for thermal sensors +├── distro.sh # Extract OpenWrt version string +├── cleanup-and-fix.sh # Remove old exec entries +└── snmpd-config-generator.sh # Generate UCI config entries +``` + +## Installation + +### Quick Setup +```bash +# Run setup script +chmod +x setup-snmpd.sh +./setup-snmpd.sh + +### Manual Installation +```bash +# Create directory +mkdir -p /etc/librenms + +# Copy all scripts +cp wl*.sh lm-sensors-pass.sh distro.sh cleanup-and-fix.sh snmpd-config-generator.sh /etc/librenms/ +chmod +x /etc/librenms/*.sh + +# Generate interface list +/etc/librenms/wlClients.sh + +# Generate config +/etc/librenms/snmpd-config-generator.sh +``` + +## Usage + +### Generate wlInterfaces.txt +```bash +# Auto-detect all wireless interfaces +/etc/librenms/wlClients.sh + +# Manually edit if needed +vi /etc/librenms/wlInterfaces.txt +# Format: interface,ssid +# Example: +# wl0-ap0,MySSID +# wlan0,GuestNetwork +``` + +### Generate SNMPD Config +```bash +# Generate all extend entries for detected interfaces +/etc/librenms/snmpd-config-generator.sh + +# Output can be appended to /etc/config/snmpd +/etc/librenms/snmpd-config-generator.sh >> /etc/config/snmpd +``` + +### Test Scripts Individually +```bash +# Test client count +/etc/librenms/wlClients.sh wlan0 + +# Test frequency +/etc/librenms/wlFrequency.sh wlan0 + +# Test rate (interface, direction, stat) +/etc/librenms/wlRate.sh wlan0 tx avg + +# Test SNR (interface, stat) +/etc/librenms/wlSNR.sh wlan0 avg + +# Test thermal sensors (pass script) +/etc/librenms/lm-sensors-pass.sh -g .1.3.6.1.4.1.2021.13.16.2.1.3.0 +``` + +### Query SNMP +```bash +# From monitoring server +snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2 + +# Specific metrics +snmpget -v2c -c public localhost NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"clients-wlan0\" +snmpget -v2c -c public localhost NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"frequency-wlan0\" + +# Thermal sensors (LM-SENSORS-MIB) +snmpwalk -v2c -c public localhost LM-SENSORS-MIB::lmTempSensorsValue +``` + +## SNMP OID Reference + +### Wireless Metrics (via nsExtend) +Base OID: `.1.3.6.1.4.1.8072.1.3.2` + +Per interface: +- `clients-` - Connected client count +- `frequency-` - Operating frequency (MHz) +- `rate-tx--min/avg/max` - TX bitrate stats +- `rate-rx--min/avg/max` - RX bitrate stats +- `noise-floor-` - Noise floor (dBm) +- `snr--min/avg/max` - Signal-to-Noise Ratio (dB) + +### Thermal Sensors (LM-Sensors MIB) +- `.1.3.6.1.4.1.2021.13.16.2.1.1` - lmSensorsIndex (INTEGER) +- `.1.3.6.1.4.1.2021.13.16.2.1.2` - lmSensorsDevice (STRING) +- `.1.3.6.1.4.1.2021.13.16.2.1.3` - lmSensorsValue (Gauge32, millidegrees) + +## Configuration Examples + +### Example: 4 Interface Device (like native OpenWrt) +wlInterfaces.txt: +``` +wl0-ap0,IoT +wl0-ap1,guest +wl1-ap0,main +wl1-ap1,uplink +``` + +Generated extends: +- clients-wl0-ap0, clients-wl0-ap1, clients-wl1-ap0, clients-wl1-ap1 +- frequency-wl0-ap0, frequency-wl0-ap1, frequency-wl1-ap0, frequency-wl1-ap1 +- rate-tx-wl0-ap0-min/avg/max (and all other interfaces) +- rate-rx-wl0-ap0-min/avg/max (and all other interfaces) +- And so on... + +### Example: Multi-VLAN Device (like gl.Inet flint3) +wlInterfaces.txt: +``` +wlan0,MainNetwork +wlan02,VLAN2 +wlan12,VLAN12 +wlan22,VLAN22 +``` + +## Troubleshooting + +### wlInterfaces.txt not generated +```bash +# Check for wireless interfaces +ls /sys/class/net/*/wireless +ls /sys/class/net/*/phy80211 + +# Manually create the file +cat > /etc/librenms/wlInterfaces.txt << EOF +wlan0,YourSSID +EOF +``` + +### SNMP not returning data +```bash +# Check if snmpd is running +/etc/init.d/snmpd status + +# Check if scripts are executable +ls -la /etc/librenms/*.sh + +# Test script directly +/etc/librenms/wlClients.sh wlan0 + +# Check snmpd logs +logread | grep snmpd +``` + +### Script errors +```bash +# Enable debug output +sh -x /etc/librenms/wlClients.sh wlan0 + +# Check for required commands +which iw iwinfo awk cut grep +``` + +## Comparison: Before vs After + +### Before (Manual, Per-Device) +❌ Required manual creation of wlInterfaces.txt for each device +❌ Different config file for each device type +❌ Repetitive config entries (280+ lines) +❌ Hard to maintain across multiple devices +❌ Interface changes require manual config updates + +### After (Automated, Unified) +✅ Auto-detects wireless interfaces +✅ Single config generator works for all devices +✅ Generates only needed entries +✅ Easy to maintain and replicate +✅ Interface changes auto-detected on script run + +## Benefits + +1. **Zero Manual Configuration**: Just run setup script +2. **Device-Agnostic**: Works on any OpenWrt device +3. **Self-Documenting**: Auto-generated configs show what's monitored +4. **Easy Replication**: Same process for all devices +5. **Future-Proof**: Adding interfaces doesn't require config changes +6. **Reduced Errors**: No manual typing of repetitive entries +7. **Consistent**: All devices use same monitoring approach + +## Security Notes + +- Default SNMP community strings should be changed in production +- Restrict SNMP access to monitoring network (192.168.0.0/24 in examples) +- Use SNMPv3 for better security if supported by your NMS + +## License + +These scripts are provided as-is for use with OpenWrt systems. diff --git a/snmp/Openwrt/cleanup-and-fix.sh b/snmp/Openwrt/cleanup-and-fix.sh new file mode 100644 index 000000000..4d4637b8f --- /dev/null +++ b/snmp/Openwrt/cleanup-and-fix.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# cleanup-and-fix.sh +# Run this on the OpenWrt device to: +# 1. Remove old broken exec entries +# 2. Verify pass script is working + +echo "Step 1: Removing old exec entries for lmSensors..." + +# Remove exec entries with miboid containing 2021.13.16 +uci show snmpd | grep "exec.*=exec" | cut -d'.' -f2 | cut -d'=' -f1 | while read idx; do + miboid=$(uci get snmpd.$idx.miboid 2>/dev/null) + if echo "$miboid" | grep -q "2021\.13\.16"; then + echo " Removing snmpd.$idx (miboid: $miboid)" + uci delete snmpd.$idx + fi +done + +uci commit snmpd + +echo "" +echo "Step 2: Verifying pass configuration..." +uci show snmpd | grep "pass.*lm-sensors" + +echo "" +echo "Step 3: Restarting snmpd..." +/etc/init.d/snmpd restart + +echo "" +echo "Done! Now test with:" +echo " snmpwalk -v2c -c public localhost LM-SENSORS-MIB::lmTempSensorsValue" diff --git a/snmp/Openwrt/distro.sh b/snmp/Openwrt/distro.sh new file mode 100644 index 000000000..3af86780f --- /dev/null +++ b/snmp/Openwrt/distro.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# distro.sh +# Extracts OpenWrt version string from banner (from "OpenWrt" onwards) + +grep OpenWrt /etc/banner | sed 's/.*OpenWrt/OpenWrt/' | head -1 diff --git a/snmp/Openwrt/lm-sensors-pass.sh b/snmp/Openwrt/lm-sensors-pass.sh new file mode 100644 index 000000000..763a2b45b --- /dev/null +++ b/snmp/Openwrt/lm-sensors-pass.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +# lm-sensors-pass.sh +# SNMP pass script for LM-SENSORS-MIB thermal sensors +# Provides proper MIB structure at .1.3.6.1.4.1.2021.13.16.2.1 + +BASE_OID=".1.3.6.1.4.1.2021.13.16.2.1" + +# Function to get all thermal zone data +# Output format: index:name:temp +# Re-indexes zones sequentially starting from 1 +get_zones() { + local idx=0 + for zone in /sys/devices/virtual/thermal/thermal_zone*; do + [ -d "$zone" ] || continue + idx=$((idx + 1)) + zone_type=$(cat "$zone/type" 2>/dev/null || echo "unknown") + zone_temp=$(cat "$zone/temp" 2>/dev/null || echo "0") + echo "$idx:$zone_type:$zone_temp" + done | sort -t':' -k1 -n +} + +case "$1" in + -g) + # GET request - return exact OID match + REQ_OID="$2" + FOUND=0 + + while IFS=':' read idx name temp; do + case "$REQ_OID" in + "$BASE_OID.1.$idx") + echo "$REQ_OID" + echo "integer" + echo "$idx" + FOUND=1 + break + ;; + "$BASE_OID.2.$idx") + echo "$REQ_OID" + echo "string" + echo "$name" + FOUND=1 + break + ;; + "$BASE_OID.3.$idx") + echo "$REQ_OID" + echo "gauge" + echo "$temp" + FOUND=1 + break + ;; + esac + done << EOF +$(get_zones) +EOF + + [ "$FOUND" -eq 0 ] && echo "NONE" + ;; + + -n) + # GETNEXT request - return next OID after requested + REQ_OID="$2" + + # Create temporary file with all OIDs + TMP_FILE="/tmp/snmp_oids.$$" + > "$TMP_FILE" + + get_zones | while IFS=':' read idx name temp; do + # Pad index to ensure proper numeric sorting + # Format: column.index where index is zero-padded to 3 digits + printf "%d.%03d|$BASE_OID.1.$idx|integer|$idx\n" 1 $idx >> "$TMP_FILE" + printf "%d.%03d|$BASE_OID.2.$idx|string|$name\n" 2 $idx >> "$TMP_FILE" + printf "%d.%03d|$BASE_OID.3.$idx|gauge|$temp\n" 3 $idx >> "$TMP_FILE" + done + + # Sort by our padded key, then extract and compare OIDs + sort -t'|' -k1 "$TMP_FILE" | cut -d'|' -f2- | while IFS='|' read oid type value; do + # Use awk for proper numeric OID comparison + is_greater=$(awk -v req="$REQ_OID" -v curr="$oid" ' + BEGIN { + # Split OIDs into arrays + split(req, req_parts, "."); + split(curr, curr_parts, "."); + + # Compare each part numerically + for (i = 1; i <= length(curr_parts); i++) { + req_val = (i <= length(req_parts)) ? req_parts[i] : 0; + curr_val = curr_parts[i]; + + if (curr_val > req_val) { + print "1"; + exit; + } else if (curr_val < req_val) { + print "0"; + exit; + } + } + print "0"; + } + ') + + if [ "$is_greater" = "1" ]; then + echo "$oid" + echo "$type" + echo "$value" + rm -f "$TMP_FILE" + exit 0 + fi + done + + rm -f "$TMP_FILE" + echo "NONE" + ;; + + *) + echo "Usage: $0 -g|-n OID" >&2 + exit 1 + ;; +esac diff --git a/snmp/Openwrt/setup-snmpd.sh b/snmp/Openwrt/setup-snmpd.sh new file mode 100644 index 000000000..adda05375 --- /dev/null +++ b/snmp/Openwrt/setup-snmpd.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +# setup-snmpd.sh +# Installation and configuration script for OpenWrt SNMP monitoring +# This script sets up all necessary scripts and generates the snmpd config + +SCRIPT_DIR="/etc/librenms" +BACKUP_DIR="/etc/librenms/backup" + +echo "OpenWrt SNMPD Setup Script" +echo "==========================" +echo "" + +# Create directories +echo "Creating directories..." +mkdir -p "$SCRIPT_DIR" +mkdir -p "$BACKUP_DIR" + +# Backup existing config if it exists +if [ -f /etc/config/snmpd ]; then + timestamp=$(date +%Y%m%d_%H%M%S) + echo "Backing up existing /etc/config/snmpd to $BACKUP_DIR/snmpd.$timestamp" + cp /etc/config/snmpd "$BACKUP_DIR/snmpd.$timestamp" +fi + +# Copy scripts to /etc/librenms/ +echo "Installing monitoring scripts to $SCRIPT_DIR..." + +scripts="wlClients.sh wlFrequency.sh wlNoiseFloor.sh wlRate.sh wlSNR.sh lm-sensors-pass.sh distro.sh cleanup-and-fix.sh snmpd-config-generator.sh" + +for script in $scripts; do + if [ -f "$script" ]; then + cp "$script" "$SCRIPT_DIR/" + chmod +x "$SCRIPT_DIR/$script" + echo " ✓ Installed $script" + else + echo " ✗ Warning: $script not found in current directory" + fi +done + +# Generate wlInterfaces.txt +echo "" +echo "Generating wlInterfaces.txt..." +# Force regeneration by removing old file +rm -f "$SCRIPT_DIR/wlInterfaces.txt" +"$SCRIPT_DIR/wlClients.sh" > /dev/null 2>&1 +if [ -f "$SCRIPT_DIR/wlInterfaces.txt" ]; then + echo " ✓ Generated $SCRIPT_DIR/wlInterfaces.txt" + cat "$SCRIPT_DIR/wlInterfaces.txt" +else + echo " ✗ Failed to generate wlInterfaces.txt" +fi + +# Generate sample config +echo "" +echo "Generating SNMPD configuration..." +echo "Run the following command to see the generated config:" +echo "" +echo " $SCRIPT_DIR/snmpd-config-generator.sh" +echo "" +echo "To apply the configuration:" +echo " 1. Backup your current config: cp /etc/config/snmpd /etc/config/snmpd.backup" +echo " 2. Edit /etc/config/snmpd and add the generated sections" +echo " 3. Restart snmpd: /etc/init.d/snmpd restart" +echo "" +echo "Setup complete!" + +# Ask for confirmation +printf "Do you want to update the SNMP configuration? [Y/n]: " +read -r answer + +# Convert to lowercase and check (default to 'y' if empty) +answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]') + +if [ -z "$answer" ] || [ "$answer" = "y" ]; then + echo "Updating snmpd configuration..." + + # 1. Backup existing config + cp /etc/config/snmpd /etc/config/snmpd-backup + + # 2. Append generated config + # Ensure the generator script is executable + chmod +x "$SCRIPT_DIR/snmpd-config-generator.sh" + "$SCRIPT_DIR/snmpd-config-generator.sh" >> /etc/config/snmpd + + # 3. Restart the service + /etc/init.d/snmpd restart + + echo "Done! Service restarted." +else + echo "Aborted. No changes made." + exit 1 +fi diff --git a/snmp/Openwrt/snmpd-config-generator.sh b/snmp/Openwrt/snmpd-config-generator.sh new file mode 100644 index 000000000..b6e1e38c3 --- /dev/null +++ b/snmp/Openwrt/snmpd-config-generator.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +# snmpd-config-generator.sh +# Generates SNMP extend entries for all wireless interfaces dynamically +# Usage: Run this script to generate UCI config commands for /etc/config/snmpd + +SCRIPT_DIR="/etc/librenms" +INTERFACES_FILE="$SCRIPT_DIR/wlInterfaces.txt" + +# Ensure wlInterfaces.txt exists +if [ ! -f "$INTERFACES_FILE" ]; then + echo "Generating $INTERFACES_FILE..." + $SCRIPT_DIR/wlClients.sh >/dev/null 2>&1 +fi + +# Read interfaces +if [ ! -f "$INTERFACES_FILE" ]; then + echo "Error: Could not find or generate $INTERFACES_FILE" + exit 1 +fi + +# Generate config for each interface +cat "$INTERFACES_FILE" | while IFS=',' read -r iface ssid; do + [ -z "$iface" ] && continue + + # Sanitize interface name for use in UCI names (replace - with _) + safe_name=$(echo "$iface" | tr '-' '_') + + echo "" + echo "# Interface: $iface ($ssid)" + echo "" + + # Clients + echo "config extend" + echo " option name 'clients-$iface'" + echo " option prog '$SCRIPT_DIR/wlClients.sh'" + echo " option args '$iface'" + echo "" + + # Frequency + echo "config extend" + echo " option name 'frequency-$iface'" + echo " option prog '$SCRIPT_DIR/wlFrequency.sh'" + echo " option args '$iface'" + echo "" + + # Rate TX (min, avg, max) + for stat in min avg max; do + echo "config extend" + echo " option name 'rate-tx-$iface-$stat'" + echo " option prog '$SCRIPT_DIR/wlRate.sh'" + echo " option args '$iface tx $stat'" + echo "" + done + + # Rate RX (min, avg, max) + for stat in min avg max; do + echo "config extend" + echo " option name 'rate-rx-$iface-$stat'" + echo " option prog '$SCRIPT_DIR/wlRate.sh'" + echo " option args '$iface rx $stat'" + echo "" + done + + # Noise floor + echo "config extend" + echo " option name 'noise-floor-$iface'" + echo " option prog '$SCRIPT_DIR/wlNoiseFloor.sh'" + echo " option args '$iface'" + echo "" + + # SNR (min, avg, max) + for stat in min avg max; do + echo "config extend" + echo " option name 'snr-$iface-$stat'" + echo " option prog '$SCRIPT_DIR/wlSNR.sh'" + echo " option args '$iface $stat'" + echo "" + done +done + +# Generate thermal sensor config using pass (LM-SENSORS-MIB) +echo "" +echo "# Thermal Sensors (LM-SENSORS-MIB via pass)" +echo "" + +echo "config pass" +echo " option name 'lm-sensors'" +echo " option prog '$SCRIPT_DIR/lm-sensors-pass.sh'" +echo " option miboid '.1.3.6.1.4.1.2021.13.16.2.1'" +echo "" diff --git a/snmp/Openwrt/wlClients.sh b/snmp/Openwrt/wlClients.sh index 72e3694cb..0e9579e82 100755 --- a/snmp/Openwrt/wlClients.sh +++ b/snmp/Openwrt/wlClients.sh @@ -2,23 +2,91 @@ # wlClients.sh # Counts connected (associated) Wi-Fi devices -# Arguments: targed interface. Assumes all interfaces if no argument +# Arguments: target interface. Assumes all interfaces if no argument +# Auto-generates wlInterfaces.txt if it doesn't exist + +# Get path to this script (ash-compatible) +scriptdir="$(cd "$(dirname "$0")" && pwd)" +interfaces_file="$scriptdir/wlInterfaces.txt" + +# Function to auto-detect and generate wlInterfaces.txt +generate_interfaces_file() { + local tmpfile="$interfaces_file.tmp" + + # Find all wireless interfaces that are actually in use + for dev in /sys/class/net/*; do + iface=$(basename "$dev") + + # Skip known non-client interfaces + case "$iface" in + mld*|mon.*) #|wifi*|phy*|wlan-* + continue + ;; + esac + + # Check if it's a wireless interface + if [ -d "$dev/wireless" ] || [ -d "$dev/phy80211" ]; then + # Get interface type and SSID using iw first + iw_info=$(/usr/sbin/iw dev "$iface" info 2>/dev/null) + iface_type=$(echo "$iw_info" | /usr/bin/awk '/^[[:space:]]*type / {print $2; exit}') + ssid=$(echo "$iw_info" | /bin/grep ssid | /usr/bin/cut -f 2 -s -d" " | /usr/bin/tr -d '\n') + + # Skip AP/VLAN interfaces which can report "ESSID: unknown" + [ "$iface_type" = "AP/VLAN" ] && continue + + # If no SSID from iw, try iwinfo + if [ -z "$ssid" ]; then + ssid=$(/usr/bin/iwinfo "$iface" info 2>/dev/null | /bin/sed -n \ + -e 's/.*ESSID: "\(.*\)".*/\1/p' \ + -e 's/.*ESSID: \(.*\)$/\1/p' | /usr/bin/head -n 1) + fi + + # Skip interfaces without SSID (not active AP/client interfaces) + [ -z "$ssid" ] && continue + + # Skip malformed or unknown SSIDs + case "$ssid" in + unknown|*ESSID:*) + continue + ;; + esac + + # Add to list (include even if DOWN, since SSID means it's configured) + echo "$iface,$ssid" >> "$tmpfile" + fi + done + + # Only replace if we found interfaces + if [ -s "$tmpfile" ]; then + mv "$tmpfile" "$interfaces_file" + return 0 + else + rm -f "$tmpfile" + return 1 + fi +} + +# Check if wlInterfaces.txt exists, generate if not +if [ ! -f "$interfaces_file" ]; then + generate_interfaces_file + if [ $? -ne 0 ]; then + /bin/echo "Error: Could not generate $interfaces_file and file does not exist" + exit 1 + fi +fi # Check number of arguments if [ $# -gt 1 ]; then - /bin/echo "Usage: wlClients.sh interface" + /bin/echo "Usage: wlClients.sh [interface]" /bin/echo "Too many command line arguments, exiting." exit 1 fi -# Get path to this script -scriptdir=$(dirname "$(readlink -f -- "$0")") - # Get interface list. Set target, which is name returned for interface if [ "$1" ]; then interfaces=$1 else - interfaces=$(cat "$scriptdir"/wlInterfaces.txt | cut -f 1 -d",") + interfaces=$(cat "$interfaces_file" | cut -f 1 -d",") fi # Count associated devices @@ -26,7 +94,7 @@ count=0 for interface in $interfaces do new=$(/usr/sbin/iw dev "$interface" station dump 2>/dev/null | /bin/grep Station | /usr/bin/cut -f 2 -s -d" " | /usr/bin/wc -l) - count=$(( $count + $new )) + count=$(( count + new )) done # Return snmp result diff --git a/snmp/Openwrt/wlFrequency.sh b/snmp/Openwrt/wlFrequency.sh index 4552cc4b7..e4bcd1cac 100755 --- a/snmp/Openwrt/wlFrequency.sh +++ b/snmp/Openwrt/wlFrequency.sh @@ -2,7 +2,7 @@ # wlFrequency.sh # Returns wlFrequency, in MHz (not channel number) -# Arguments: targed interface +# Arguments: target interface # Check number of arguments if [ $# -ne 1 ]; then diff --git a/snmp/Openwrt/wlInterfaces.txt b/snmp/Openwrt/wlInterfaces.txt deleted file mode 100755 index bfe882e0e..000000000 --- a/snmp/Openwrt/wlInterfaces.txt +++ /dev/null @@ -1,2 +0,0 @@ -wlan0,wl-2.4G -wlan1,wl-5.0G diff --git a/snmp/Openwrt/wlNoiseFloor.sh b/snmp/Openwrt/wlNoiseFloor.sh index 102cde435..9f646954c 100755 --- a/snmp/Openwrt/wlNoiseFloor.sh +++ b/snmp/Openwrt/wlNoiseFloor.sh @@ -2,7 +2,7 @@ # wlNoiseFloor.sh # Returns wlNoiseFloor, in dBm -# Arguments: targed interface +# Arguments: target interface # Check number of arguments if [ $# -ne 1 ]; then