PortSAMp

Set/Display sflow port sampling characteristics

PortSAMp

Shortest form: psam.

Show or set packet sampling (as used by sFlow) per port: ingress rate, egress rate, and where sampled ingress packets go. The older PortSampRate sets only the two rates.

The first argument is an optional port bitmap (all ports if omitted; see Ports and port bitmaps). It is followed by any of:

  • IngressRate=<n>, EgressRate=<n>: sample on average one packet in n; 0 turns sampling off and 1 samples every packet;

  • IngressDest=None|CPU|Mirror|MirrorAndCPU: where sampled ingress packets go.

Any other word prints PortSAMp: Unknown argument <word>. With keys, the command prints Port = <name>(<n>) for each port and then IngressRate set to <n> (and so on) for each setting. Without keys it prints a Port Sampling Details: table with the columns port, IngressRate, EgressRate and IngressDest. On chips without this sampling support the command does nothing. A port without sFlow shows rates 0 and destination None.

The built-in help shows IngressDest=None|Mirror|CPU|MirrorAndCPU; the shell actually treats any word other than CPU, Mirror and MirrorAndCPU as None, without an error, so a typo turns sampling to the CPU off.

Showing is safe. Setting changes sampling behind SONiC’s back; SONiC’s sFlow configuration is not updated and may later overwrite the change.

Hardware-validated — Show sampling settings of two ports

drivshell> PortSAMp ce0,ce1
Port Sampling Details:
      port    IngressRate     EgressRate      IngressDest
  ce0(  1)              0              0             None
  ce1(  5)              0              0             None

Unvalidated — Sample one in 4096 received packets on ce0 to the CPU

drivshell> PortSAMp ce0 IngressRate=4096 IngressDest=CPU

Built-in help

Set/Display port sampling characteristics.
Parameters: <pbm> [IngressRate=<value>] [EgressRate=<value>]
    [IngressDest=None|Mirror|CPU|MirrorAndCPU]
    IngressRate/EgressRate:
        On average, every 1/(ingress_rate|egress_rate) packets will be sampled.
        A rate of 0 indicates no sampling.
        A rate of 1 indicates all packets sampled.