8 stycznia 2014

Ubiquiti TOUGHSwitch PoE PRO i stany liczników (ruch) dla każdego portu

Odczytanie zawartości /proc/net/dev nic nie mówi o ruchu na portach, jedynie na wewnętrznych interfejsach switch'a. Aby uzyskać stany liczników (ruch) dla każdego z portów osobno, wystarczy otworzyć plik /var/tmp/status_json.

Przykładowa zawartość, format JSON:
{
   "stats":{
      "1":{
         "poe":"0",
         "portSpeed":"100",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":117754941658,
            "TxBroad":110690,
            "TxUni":111089346,
            "TxMulti":93541,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":27881914005,
            "RxBroad":46508,
            "RxUni":88242095,
            "RxMulti":1395,
            "RxFcsErr":1,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":40993599,
            "TRx128Byte":25693523,
            "TRx256Byte":3648856,
            "TRx512Byte":1990133,
            "TRx1024Byte":2362312,
            "TRxMaxByte":13601576
         }
      },
      "2":{
         "poe":"0",
         "portSpeed":"1000",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":163126309,
            "TxBroad":1432704,
            "TxUni":453,
            "TxMulti":567588,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":3241577,
            "RxBroad":0,
            "RxUni":1,
            "RxMulti":6191,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":34,
            "TRx128Byte":0,
            "TRx256Byte":0,
            "TRx512Byte":2471,
            "TRx1024Byte":3687,
            "TRxMaxByte":0
         }
      },
      "3":{
         "poe":"0",
         "portSpeed":"1000",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":163682077,
            "TxBroad":1433291,
            "TxUni":502,
            "TxMulti":567350,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":2740019,
            "RxBroad":0,
            "RxUni":0,
            "RxMulti":6511,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":6,
            "TRx128Byte":0,
            "TRx256Byte":0,
            "TRx512Byte":6505,
            "TRx1024Byte":0,
            "TRxMaxByte":0
         }
      },
      "4":{
         "poe":"0",
         "portSpeed":"1000",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":1393171085555,
            "TxBroad":1431210,
            "TxUni":1290915353,
            "TxMulti":573720,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":156045432312,
            "RxBroad":328,
            "RxUni":958413239,
            "RxMulti":4056,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":498122212,
            "TRx128Byte":318655134,
            "TRx256Byte":54161969,
            "TRx512Byte":17977988,
            "TRx1024Byte":23049878,
            "TRxMaxByte":46450443
         }
      },
      "5":{
         "poe":"0",
         "portSpeed":"1000",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":1336905838571,
            "TxBroad":241505,
            "TxUni":3710249743,
            "TxMulti":496286,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":12183648616197,
            "RxBroad":1178135,
            "RxUni":2229543132,
            "RxMulti":77472,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":657162412,
            "TRx128Byte":1339531801,
            "TRx256Byte":523701573,
            "TRx512Byte":313405085,
            "TRx1024Byte":246887664,
            "TRxMaxByte":3445300570
         }
      },
      "6":{
         "poe":"0",
         "portSpeed":"100",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":45602466100,
            "TxBroad":151096,
            "TxUni":42552269,
            "TxMulti":92342,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":3575597265,
            "RxBroad":26,
            "RxUni":29139075,
            "RxMulti":2768,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":17438436,
            "TRx128Byte":8498808,
            "TRx256Byte":1561161,
            "TRx512Byte":406953,
            "TRx1024Byte":563539,
            "TRxMaxByte":672972
         }
      },
      "7":{
         "poe":"0",
         "portSpeed":"1000",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":3208892838838,
            "TxBroad":1256802,
            "TxUni":2760667465,
            "TxMulti":400569,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":293912171364,
            "RxBroad":176646,
            "RxUni":2009603876,
            "RxMulti":173290,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":1068232579,
            "TRx128Byte":683150554,
            "TRx256Byte":96470449,
            "TRx512Byte":39277959,
            "TRx1024Byte":46666621,
            "TRxMaxByte":76155650
         }
      },
      "8":{
         "poe":"0",
         "portSpeed":"100",
         "linkStatus":"1",
         "duplex":"1",
         "hasVlans":"0",
         "maxFrameSize":"1518",
         "alertEnabled":"0",
         "stpState":"No spanning",
         "stats":{
            "TxByte":7436383703602,
            "TxBroad":1352989,
            "TxUni":2343144437,
            "TxMulti":267006,
            "TxExcCol":0,
            "TxLateCol":0,
            "RxGoodByte":873321777726,
            "RxBroad":32306,
            "RxUni":648949666,
            "RxMulti":310287,
            "RxFcsErr":0,
            "RxAllignErr":0,
            "RxJabber":0,
            "RxFragment":0,
            "RxOversize":0,
            "TRx64Byte":2512756819,
            "TRx128Byte":1695780622,
            "TRx256Byte":226916928,
            "TRx512Byte":98845703,
            "TRx1024Byte":121118002,
            "TRxMaxByte":289468496
         }
      }
   },
   "timestamp":1389173254.935458,
   "now":"2014-01-08 10:27:34",
   "uptime":"506585",
   "management":{
      "up":1,
      "speed":100
   }
}