tips:airos

AirOS

snmpwalk -c lessinianet.snmp -v 1 10.210.12.249 IF-MIB::ifDescr                                
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth0
IF-MIB::ifDescr.3 = STRING: eth1
IF-MIB::ifDescr.4 = STRING: wifi0
IF-MIB::ifDescr.5 = STRING: ath0
IF-MIB::ifDescr.6 = STRING: eth0.10
IF-MIB::ifDescr.7 = STRING: br0
snmpget -c lessinianet.snmp -v 1 10.210.12.249 IF-MIB::ifPhysAddress.4                                  
IF-MIB::ifPhysAddress.4 = STRING: 4:18:d6:ec:98:ac

Cercando dalla prima query i “wifi*” e sostituendo l'indice corrispondente (nell'esempio 4) nella seconda query si ottiene il mac. Ovviamente da fare usande le librerie SNMP PHP

<?php
 
// airOS-getFile_HTTP() from Omniflux:
// https://community.ubnt.com/t5/airMAX-AC/Login-to-web-interface-with-PHP/m-p/2291860#M29858
 
// an example of fetching status.cgi from an AF24 (and probably any other UBNT radio)
// the output is a bunch of JSON with the current radio stats
 
// airOS_getFile_HTTP ($username, $password, $file, $address, $schema)
 
#$out = airOS_getFile_HTTP ("root", "xxx", "status.cgi", "10.210.48.2", "https"); // CPE mng
#$out = airOS_getFile_HTTP ("galileo", "xxx", "status.cgi", "10.210.12.247", "http"); // settore
$out = airOS_getFile_HTTP ("root", "xxx", "status.cgi", "109.104.240.187:8008", "http"); // CPE
print $out;
 
function airOS_getFile_HTTP ($username, $password, $file, $address, $schema)
 
&#123;
        $ch = curl_init();
 
        // Setup CURL
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_COOKIEJAR, null);
        curl_setopt ($ch, CURLOPT_HTTPHEADER, Array ('Expect: '));
 
        // Login AirOS >= 8.5.0+ OR get cookie with session ID for AirOS < 8.5.0
        curl_setopt ($ch, CURLOPT_URL, "$schema://$address/api/auth");
        curl_setopt ($ch, CURLOPT_POST, 1);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, Array ('username' => $username, 'password' => $password));
        curl_setopt ($ch, CURLOPT_HEADER, 1);
        $response = curl_exec ($ch);
// uncomment to see raw response
//print "resp: $response\n";
        curl_setopt ($ch, CURLOPT_HEADER, 0); 
 
        // AirOS >= 8.5.0 request and return file
 
        if (curl_getinfo ($ch, CURLINFO_HTTP_CODE) == 200)
        &#123;
                // Get X-CSRF-ID value
                preg_match ('/X-CSRF-ID: .*/', substr ($response, 0, curl_getinfo ($ch, CURLINFO_HEADER_SIZE)), $XCSRFID);
 
                curl_setopt ($ch, CURLOPT_URL, "$schema://$address/$file");
                curl_setopt ($ch, CURLOPT_POST, 0);
                $retfile = curl_exec ($ch);
 
                curl_setopt ($ch, CURLOPT_URL, "$schema://$address/logout.cgi");
                curl_setopt ($ch, CURLOPT_HTTPHEADER, Array (trim ($XCSRFID[0]), 'X-AIROS-LUA: 1'));
                curl_setopt ($ch, CURLOPT_POST, 1);
                curl_setopt ($ch, CURLOPT_POSTFIELDS, Array());
                curl_exec ($ch);
        &#125;
 
        // Login failed, try AirOS < 8.5.0 login, request, and return file
        else
        &#123;
                curl_setopt ($ch, CURLOPT_URL, "$schema://$address/login.cgi");
                curl_setopt ($ch, CURLOPT_POST, 1);
                curl_setopt ($ch, CURLOPT_POSTFIELDS, Array ('username' => $username, 'password' => $password));
                curl_exec ($ch);
 
                curl_setopt ($ch, CURLOPT_URL, "$schema://$address/$file");
                curl_setopt ($ch, CURLOPT_POST, 0);
                $retfile = curl_exec ($ch);
        &#125;
 
        curl_close ($ch);
 
        return $retfile;
&#125;
?>
&#123;
  "chain_names": [
    &#123;
      "number": 1,
      "name": "Chain 0"
    &#125;,
    &#123;
      "number": 2,
      "name": "Chain 1"
    &#125;
  ],
  "host": &#123;
    "hostname": "cpe-188192-gal-lab",
    "uptime": 667685,
    "time": "2018-01-26 08:29:59",
    "timestamp": 828344250,
    "fwversion": "v8.5.0-cs.36727.180118.1402",
    "devmodel": "Rocket Prism 5AC Gen2",
    "netrole": "bridge",
    "loadavg": 0.129883,
    "totalram": 129982464,
    "freeram": 89100288,
    "temperature": 50,
    "cpuload": 39.603962
  &#125;,
  "genuine": "/images/genuine.png",
  "services": &#123;
    "dhcpc": false,
    "dhcpd": false,
    "dhcp6d_stateful": false,
    "pppoe": false,
    "airview": 2
  &#125;,
  "firewall": &#123;
    "iptables": false,
    "ebtables": false,
    "ip6tables": false,
    "eb6tables": false
  &#125;,
  "portfw": false,
  "wireless": &#123;
    "essid": "lessinianet.net",
    "mode": "sta-ptmp",
    "compat_11n": 0,
    "hide_essid": 0,
    "apmac": "80:2A:A8:A4:2F:9D",
    "frequency": 5655,
    "center1_freq": 5655,
    "dfs": 1,
    "distance": 14850,
    "security": "WPA2",
    "noisef": -90,
    "txpower": 22,
    "aprepeater": false,
    "rstatus": 5,
    "chanbw": 20,
    "rx_chainmask": 3,
    "tx_chainmask": 3,
    "cac_state": 0,
    "rx_idx": 4,
    "rx_nss": 2,
    "tx_idx": 6,
    "tx_nss": 2,
    "count": 1,
    "polling": &#123;
      "dcap": 57720,
      "ucap": 95680,
      "use": 2,
      "tx_use": 1,
      "rx_use": 1,
      "atpc_status": 0,
      "fixed_frame": false,
      "gps_sync": false
    &#125;,
    "sta": [
      &#123;
        "mac": "80:2A:A8:A4:2F:9D",
        "lastip": "0.0.0.0",
        "signal": -66,
        "rssi": 30,
        "noisefloor": -90,
        "chainrssi": [
          28,
          26,
          0
        ],
        "tx_idx": 6,
        "rx_idx": 4,
        "tx_nss": 2,
        "rx_nss": 2,
        "tx_latency": 0,
        "distance": 14850,
        "tx_packets": 0,
        "tx_lretries": 0,
        "tx_sretries": 0,
        "uptime": 157916,
        "tx_ratedata": [
          3,
          0,
          0,
          176,
          14327,
          102196,
          156745,
          178340,
          0,
          0
        ],
        "stats": &#123;
          "rx_bytes": 83701813,
          "rx_packets": 588950,
          "rx_pps": 11,
          "tx_bytes": 98347739,
          "tx_packets": 292160,
          "tx_pps": 0
        &#125;,
        "remote": &#123;
          "hostname": "santuario-SudOvest",
          "platform": "Rocket 5AC Prism",
          "version": "XC.qca955x.v8.5.11.39842.190109.1449",
          "uptime": 240246,
          "time": "2019-01-12 10:33:00",
          "cpuload": 7,
          "temperature": 51,
          "totalram": 129961984,
          "freeram": 81661952,
          "netrole": "bridge",
          "mode": "ap-ptmp",
          "compat_11n": 1,
          "signal": -64,
          "rssi": 32,
          "noisefloor": -87,
          "tx_power": 22,
          "distance": 14850,
          "rx_chainmask": 3,
          "chainrssi": [
            30,
            28,
            0
          ],
          "tx_ratedata": [
            2,
            5,
            220,
            3920,
            294380,
            0,
            0,
            0,
            0,
            0
          ],
          "tx_bytes": 139113407571,
          "rx_bytes": 9806798900,
          "ethlist": [
            &#123;
              "ifname": "eth0",
              "enabled": true,
              "plugged": true,
              "duplex": true,
              "speed": 1000,
              "snr": [
                30,
                30,
                30,
                30
              ],
              "cable_len": 14
            &#125;
          ],
          "ipaddr": [
            "10.210.48.248",
            "169.254.47.157"
          ],
          "gps": &#123;
            "lat": "45.545359",
            "lon": "10.878980",
            "fix": 1,
            "sats": 8,
            "dim": 3,
            "dop": "1.30",
            "alt": "341.6"
          &#125;,
          "oob": "false"
        &#125;,
        "airmax": &#123;
          "actual_priority": 2,
          "beam": 0,
          "desired_priority": 2,
          "downlink_capacity": 57720,
          "uplink_capacity": 95680,
          "atpc_status": 0,
          "rx": &#123;
            "usage": 1,
            "cinr": 26,
            "evm": [
              [
                25,
                25,
                25,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                27,
                28,
                28,
                28,
                28,
                28,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                26,
                25,
                25,
                25,
                25,
                25,
                28,
                28,
                28,
                25,
                25,
                25,
                25,
                24,
                24,
                24,
                24,
                24,
                27,
                27,
                27,
                27,
                24,
                24,
                22,
                22,
                26,
                26,
                26,
                26,
                25,
                25,
                25,
                25,
                25,
                25
              ],
              [
                30,
                30,
                30,
                31,
                31,
                31,
                31,
                31,
                31,
                30,
                31,
                30,
                30,
                30,
                30,
                30,
                28,
                28,
                28,
                28,
                28,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                31,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                29,
                29,
                31,
                31,
                31,
                31,
                29,
                29,
                29,
                29,
                29,
                29
              ]
            ]
          &#125;,
          "tx": &#123;
            "usage": 1,
            "cinr": 26,
            "evm": [
              [
                24,
                24,
                24,
                24,
                24,
                24,
                24,
                24,
                24,
                24,
                26,
                26,
                26,
                27,
                27,
                27,
                27,
                25,
                27,
                25,
                26,
                26,
                26,
                26,
                25,
                24,
                24,
                24,
                24,
                24,
                24,
                24,
                24,
                28,
                28,
                28,
                28,
                28,
                28,
                28,
                28,
                25,
                25,
                25,
                25,
                25,
                25,
                25,
                25,
                27,
                27,
                27,
                27,
                27,
                27,
                27,
                27,
                27,
                27,
                26,
                26,
                25,
                27,
                27
              ],
              [
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                30,
                32,
                32,
                32,
                33,
                33,
                33,
                33,
                31,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                33,
                33,
                33,
                33,
                33,
                33,
                33,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32,
                32
              ]
            ]
          &#125;
        &#125;
      &#125;
    ]
  &#125;,
  "interfaces": [
    &#123;
      "ifname": "eth0",
      "hwaddr": "78:8A:20:AD:E4:4C",
      "enabled": true,
      "mtu": 1500,
      "status": &#123;
        "plugged": true,
        "tx_bytes": 126448927,
        "rx_bytes": 32773228,
        "tx_errors": 0,
        "rx_errors": 0,
        "ipaddr": "0.0.0.0",
        "speed": 1000,
        "duplex": true,
        "snr": [
          29,
          28,
          29,
          29
        ],
        "cable_len": 38
      &#125;
    &#125;,
    &#123;
      "ifname": "ath0",
      "hwaddr": "78:8A:20:AC:E4:4C",
      "enabled": true,
      "mtu": 1500,
      "status": &#123;
        "plugged": false,
        "tx_bytes": 394212716,
        "rx_bytes": 361312482,
        "tx_errors": 0,
        "rx_errors": 0,
        "ipaddr": "0.0.0.0",
        "speed": 0,
        "duplex": false
      &#125;
    &#125;,
    &#123;
      "ifname": "br0",
      "hwaddr": "78:8A:20:AC:E4:4C",
      "enabled": true,
      "mtu": 1500,
      "status": &#123;
        "plugged": true,
        "tx_bytes": 312537683,
        "rx_bytes": 249947706,
        "tx_errors": 0,
        "rx_errors": 0,
        "ipaddr": "10.210.48.2",
        "speed": 0,
        "duplex": false
      &#125;
    &#125;
  ],
  "provmode": &#123;&#125;,
  "ntpclient": &#123;&#125;,
  "unms": &#123;
    "status": 1,
    "timestamp": "2018-01-26T08:29:57+0100"
  &#125;
&#125;

risposta CPE

&#123; "host": &#123;
	"uptime": 5104088,
	"time": "2017-02-16 18:53:02",
	"fwversion": "v6.0",
	"fwprefix": "XW",
	"hostname": "cpe-240187",
	"devmodel": "PowerBeam M5 300",
	"netrole": "router",
	"totalram": 63623168,
	"freeram": 39596032,
	"cputotal": 510331084,
	"cpubusy": 3895687
 &#125;,
 "wireless": &#123;
	"mode": "sta",
	"essid": "lessinianet.net",
	"hide_essid": 0,
	"apmac": "04:18:D6:EC:98:AC",
	"countrycode": 380,
	"channel": 40,
	"frequency": "5200 MHz",
	"dfs": "0",
	"opmode": "11NAHT20",
	"antenna": "300 - 22 dBi",
	"chains": "2X2",
	"signal": -70, "rssi": 26, "noisef": -96,
	"txpower": 22,
	"ack": 37,
	"distance": 1950,
	"ccq": 991,
	"txrate": "39", "rxrate": "117",
	"security": "WPA2", "qos": "No QoS",
	"rstatus": 5,
	"count": 1, "cac_nol": 0, "nol_chans": 0,
	"polling": &#123;
		"enabled": 0, "quality": 0, "capacity": 0, "priority": 0, "noack": 0,
		"airsync_mode": 0, "airsync_connections": 0,
		"airsync_down_util" : 0, "airsync_up_util" : 0,
		"airselect" : 0, "airselect_interval" : 0
	&#125;,
	"stats": &#123;		"rx_nwids": 0,
		"rx_crypts": 0,
		"rx_frags": 0,
		"tx_retries": 0,
		"missed_beacons": 0,
		"err_other": 0
	&#125;,
	"wds": 0,
	"aprepeater": 0,
	"chwidth": 20,
	"chanbw": 20,
	"cwmmode": 0,
	"rx_chainmask": 3,
	"tx_chainmask": 3,
	"chainrssi" : [ 20, 25, 0 ],
	"chainrssimgmt" : [ 21, 25, 0 ],
	"chainrssiext" : [ 20, 25, 0 ]
 &#125;,
 "airview": &#123; "enabled": 0 &#125;,
 "services": &#123; "dhcpc": 0, "dhcpd": 1, "pppoe": 1 &#125;,
 "firewall": &#123; "iptables": 0, "ebtables" : 0, "ip6tables": 0, "eb6tables" : 0 &#125;,
 "genuine": "/images/genuine.png",
 "interfaces" : [
	&#123;
		"ifname" : "lo",
		"hwaddr": "00:00:00:00:00:00",
		"enabled" : true,
		"status" : &#123; "plugged": 1, "speed": 0, "duplex": 255 &#125;,
		"services" : &#123; "dhcpc": false, "dhcpd": false, "pppoe": false &#125;
	&#125;,
	&#123;
		"ifname" : "eth0",
		"hwaddr": "80:2A:A8:6F:67:A9",
		"enabled" : true,
		"status" : &#123; "plugged": 1, "speed": 100, "duplex": 1 &#125;,
		"services" : &#123; "dhcpc": false, "dhcpd": false, "pppoe": false &#125;
	&#125;,
	&#123;
		"ifname" : "wifi0",
		"hwaddr": "80:2A:A8:6E:67:A9",
		"enabled" : true,
		"status" : &#123; "plugged": 1, "speed": 0, "duplex": 255 &#125;,
		"services" : &#123; "dhcpc": false, "dhcpd": false, "pppoe": false &#125;
	&#125;,
	&#123;
		"ifname" : "ath0",
		"hwaddr": "80:2A:A8:6E:67:A9",
		"enabled" : true,
		"status" : &#123; "plugged": 1, "speed": 0, "duplex": 255 &#125;,
		"services" : &#123; "dhcpc": false, "dhcpd": false, "pppoe": true &#125;
	&#125;,
	&#123;
		"ifname" : "br0",
		"hwaddr": "80:2A:A8:6F:67:A9",
		"enabled" : true,
		"status" : &#123; "plugged": 1, "speed": 0, "duplex": 255 &#125;,
		"services" : &#123; "dhcpc": false, "dhcpd": true, "pppoe": false &#125;
	&#125;,
	&#123;
		"ifname" : "ppp0",
		"hwaddr": "00:00:00:00:00:00",
		"enabled" : true,
		"status" : &#123; "plugged": 1, "speed": 0, "duplex": 255 &#125;,
		"services" : &#123; "dhcpc": false, "dhcpd": false, "pppoe": false &#125;
	&#125;
 ]
&#125;
  • tips/airos.txt
  • Last modified: 2019/03/15 11:24
  • by scipio