Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 11.2   11.3   11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5    Statistic    FMM    Blog  

SystemInfo.NetworkStats

Queries network statistics for link layer on MacOS.

Component Version macOS Windows Linux Server iOS SDK
SystemInfo 10.0 ✅ Yes ❌ No ❌ No ✅ Yes, on macOS ❌ No
MBS( "SystemInfo.NetworkStats"; Name )   More

Parameters

Parameter Description Example
Name The name of the interface to query.
Can be empty for array of all interfaces.
Pass "sum" to sum up all counters.
"en0"

Result

Returns JSON or error.

Description

Queries network statistics for link layer on MacOS.
Returns JSON array of objects, each with the following keys:

Name, PhysicalType, Type, MTU, Baudrate, InputPackets, InputErrors, OutputPackets, OutputErrors, Collisions, InputBytes, OutputBytes, InputMulticasts, OutputMulticasts.

Type is the type of device which includes 1 for ethernet and 6 for Wifi.

BaudrateThe linespeed.
CollisionsThe number of collisions on csma interfaces.
InputBytesTotal number of octets received.
InputErrorsThe number of input errors on interface.
InputMulticastsThe number of packets received via multicast.
InputPacketsThe number of packets received.
MTUThe maximum transmission unit.
NameThe name of the interface.
OutputBytesTotal number of octets sent.
OutputErrorsThe number of output errors.
OutputMulticastsThe number of packets sent via multicast.
OutputPacketsThe number of packets sent.
PhysicalTypeThe physical network type. e.g., AUI, Thinnet, 10base-T, etc
TypeThe network type.

Examples

Query statistics for all interfaces:

MBS( "SystemInfo.NetworkStats" )

Example result:
[
  {
    "Name":   "lo0",
    "PhysicalType":   24,
    "Type":   24,
    "MTU":   16384,
    "Baudrate":   0,
    "InputPackets":   1211504,
    "InputErrors":   0,
    "OutputPackets":   1211504,
    "OutputErrors":   0,
    "Collisions":   0,
    "InputBytes":   424215552,
    "OutputBytes":   424215552,
    "InputMulticasts":   866700,
    "OutputMulticasts":   0
  },
  ...
]

Query statistics for en0, first ethernet card:

MBS( "SystemInfo.NetworkStats"; "en0" )

Example result:
{
  "Name":   "en0",
  "PhysicalType":   6,
  "Type":   6,
  "MTU":   1500,
  "Baudrate":   112050000,
  "InputPackets":   3349997,
  "InputErrors":   0,
  "OutputPackets":   9122258,
  "OutputErrors":   28815,
  "Collisions":   0,
  "InputBytes":   2294099968,
  "OutputBytes":   9673651200,
  "InputMulticasts":   67811,
  "OutputMulticasts":   0
}

Query sum of statistics:

MBS( "SystemInfo.NetworkStats"; "sum" )

Example result:
{
  "Name":   "sum",
  "InputPackets":   3393156,
  "InputErrors":   0,
  "OutputPackets":   9154972,
  "OutputErrors":   29387,
  "Collisions":   0,
  "InputBytes":   2303736832,
  "OutputBytes":   9682581504,
  "InputMulticasts":   88721,
  "OutputMulticasts":   0
}

Release notes

Blog Entries

Created 3th December 2019, last changed 9th November 2021


SystemInfo.MachoArchInfo - SystemInfo.OSName

Feedback: Report problem or ask question.


Start Chat