<--previous | contents | next-->

# netstat

The netstat module exposes network and protocol information similar to that made available by the familiar netstat(1) tool. Since it uses the Kernel Virtual Memory interface (kvm(3)) to read datastructures from kernel memory, using the netstat module requires root privileges.

Access to data is provided by methods of the Netstat class. Each method returns a nested set of dictionaries and/or lists, the structure and meaning of which should be obvious by inspection. It is frequently useful to be able to refer to the kernel header files where the pertinent data structures are defined, and the documentation for each Netstat method provides this information.

## Example

The following example uses the standard Python pretty-printer to output a complete set of IP traffic statistics.

    import openbsd.netstat

    pp = pprint.PrettyPrinter(indent=4)
    ns = openbsd.netstat.Netstat()
    pp.pprint(ns.ipstats())

<--previous | contents | next--> | (12/21/04)

PyOpenbsd v0.1 Manual