sFlow Configuration Commands
sFlow collects statistics and analyzes service traffic. During service provisioning, personal data may be involved. You have an obligation to make privacy policies and take measures according to the applicable law of the country to protect personal data.
display sflow
Function
The display sflow command displays the sFlow configuration in the system or on a specified LPU.
Usage Guidelines
After configuring the sFlow function, you can use the display sflow command to verify the configuration.
The display sflow command shows the sFlow configuration, which helps you locate faults in the system or on an interface.
Example
# Display the sFlow configuration on a specified LPU.
<HUAWEI> display sflow slot 1 sFlow Version 5 Information: -------------------------------------------------------------------------- Agent Information: IP Address: 192.168.1.206(CLI) Address family: IPV4 Vpn-instance: NA -------------------------------------------------------------------------- Collector Information: Collector ID: 1 IP Address: 192.168.1.194 Address family: IPV4 Vpn-instance: NA Port: 6343 Datagram size: 1500 Time out: NA Description: zjm-pc -------------------------------------------------------------------------- Port on slot 1 Information: Interface: GE1/0/1 Flow-sample collector: 1 Counter-sample collector : 1 Flow-sample rate(1/x): 2048 Counter-sample interval(s): 10 Flow-sample maxheader: 64 Flow-sample direction: IN,OUT
Item |
Description |
---|---|
sFlow Version 5 Information |
- |
Agent Information |
Configuration of the sFlow Agent. |
IP Address |
IP address of the sFlow Agent. To configure this parameter, run the sflow agent command. The string in the parentheses next to the IP address can be:
|
Address family |
Address family of the sFlow Agent:
|
Vpn-instance |
VPN instance of the sFlow Agent. To configure this parameter, run the sflow agent command. The value will be NA if this parameter is not configured in the sflow agent command. |
Collector Information |
Configuration of the sFlow Collector. |
Collector ID |
ID of the sFlow Collector. To configure this parameter, run the sflow collector command. |
IP Address |
IP address of the sFlow Collector. To configure this parameter, run the sflow collector command. |
Address family |
Address family of the sFlow collector:
|
Vpn-instance |
VPN instance of the sFlow Collector. To configure this parameter, run the sflow collector command. The value will be NA if this parameter is not configured in the sflow collector command. |
Port |
Port number of the sFlow Collector. To configure this parameter, run the sflow collector command. |
Datagram size |
Maximum length of sFlow packets sent to the sFlow Collector. To configure this parameter, run the sflow collector command. |
Time out |
Aging time of the sFlow Collector. To configure this parameter, run the sflow collector command. The value will be NA if this parameter is not configured or is set to 0 in the sflow collector command. |
Description |
Description of the sFlow Collector. To configure this parameter, run the sflow collector command. The value will be NA if this parameter is not configured in the sflow collector command. |
Port on slot 1 Information |
- |
Interface |
sFlow-enabled interface. To configure this parameter, run the sflow flow-sampling collector command. |
Flow-sample collector |
sFlow Collector that receives flow sampling data. To configure this parameter, run the sflow flow-sampling collector command. |
Counter-sample collector |
sFlow Collector that receives counter sampling data. To configure this parameter, run the sflow counter-sampling collector command. |
Flow-sample rate(1/x) |
Flow sampling rate. To configure this parameter, run the sflow flow-sampling rate command. |
Counter-sample interval(s) |
Counter sampling interval. To configure this parameter, run the sflow counter-sampling interval command. |
Flow-sample maxheader |
The maximum bytes of data that can be copied from a sampled packet in flow sampling. To configure this parameter, run the sflow flow-sampling max-header command. |
Flow-sample direction |
Flow sampling direction:
|
display sflow statistics
Usage Guidelines
The display sflow statistics command displays sFlow statistics, including the sampling mode, number of sampled packets, sequence number of sent packets, and number of discarded sFlow packets because of expiration. You can use the command output to locate faults.
Example
# Display sFlow statistics.
<HUAWEI> display sflow statistics sFlow Version 5 statistic Information: -------------------------------------------------------------------------- Collector 1 Current sample sequence:22388 -------------------------------------------------------------------------- Port on slot 1 statistic Information: Interface: GE1/0/1 Flow-sample sequence : 7 Counter-sample sequence : 44778 Flow-sample inbound pool: 28000 Flow-sample outbound pool: 4000 -------------------------------------------------------------------------- Port on slot 3 statistic Information: -------------------------------------------------------------------------- Port on slot 5 statistic Information: --------------------------------------------------------------------------
Item |
Description |
---|---|
sFlow Version 5 statistic Information |
sFlow sampling of sFlow version 5. |
Collector 1 Current sample sequence |
Sampling sequence number of the sFlow collector. |
Port on slot 1 statistic Information |
sFlow sampling information on slot 1. |
Interface: GE1/0/1 |
sFlow-enabled interface. |
Flow-sample sequence |
Sequence number for flow sampling on an interface. |
Counter-sample sequence |
Sequence number for counter sampling on an interface. |
Flow-sample inbound pool |
Number of incoming packets for flow sampling on an interface. |
Flow-sample outbound pool |
Number of outgoing packets for flow sampling on an interface. |
sflow agent
Function
The sflow agent command creates an sFlow agent and specifies an IP address for the sFlow agent or updates the IP address of the existing sFlow agent.
The undo sflow agent command deletes the IP address of an sFlow agent.
By default, an sFlow agent uses the IP address of the outbound interface in the route to the sFlow collector as the sFlow agent IP address of sFlow packets.
Format
sflow agent { ip [ vpn-instance vpn-instance-name ] ip-address | ipv6 [ vpn-instance vpn-instance-name ] ipv6-address }
undo sflow agent { ip [ vpn-instance vpn-instance-name ] ip-address | ipv6 [ vpn-instance vpn-instance-name ] ipv6-address }
Parameters
Parameter |
Description |
Value |
---|---|---|
ip ip-address |
Specifies the IPv4 address of an sFlow agent. |
The value is in dotted decimal notation and is a valid unicast address except 127.X.X.X. |
ipv6 ipv6-address |
Specifies an IPv6 address of the sFlow agent. |
The value is an IPv6 unicast address, which is a 32-digit hexadecimal number. |
vpn-instance vpn-instance-name |
Specifies the name of a VPN instance. |
The value is a string of 1 to 31 case-sensitive characters without spaces. |
Usage Guidelines
Usage Scenario
sFlow is a traffic monitoring technique that collects and analyzes traffic statistics. An sFlow agent encapsulates traffic statistics into sFlow packets and sends the sFlow packets to specified sFlow collectors. To send the sFlow packets to a certain sFlow collector, configure an IP address for the sFlow agent as the source address of sFlow packets. The sFlow collector analyzes and displays the traffic statistics based on the traffic in the received sFlow packets. Network administrators can view the traffic statistics on a specified interface based on the IP address of the sFlow agent and interface number.
Prerequisites
- The IP address configured as the source address must exist on the device.
- A VPN instance has been created if the sFlow agent is located on a private network.
Configuration Impact
If you run the sflow agent command multiple times, only the latest configuration takes effect.
Precautions
A maximum of two sFlow agents can be configured in the system, and each VPN instance of an address family supports only one agent. The IP address of an agent must be a valid unicast IP address of an interface. If an IPv6 address is specified for an agent, the IPv6 address must be a global unicast address, but cannot be a link-local address.
sflow collector
Function
The sflow collector command creates an sFlow collector and sets or modifies optional parameters for the sFlow collector.
The undo sflow collector command restores default values of optional parameters of the sFlow collector or deletes the sFlow collector.
By default, no sFlow collector is configured.
Format
sflow collector collector-id { ip [ vpn-instance vpn-instance-name ] ip-address | ipv6 [ vpn-instance vpn-instance-name ] ipv6-address } [ datagram-size datagram-size | port port-num | time-out time ] * [ description description ]
sflow collector collector-id { datagram-size datagram-size | port port-num } * [ description description ]
undo sflow collector collector-id [ datagram-size | port | description ] *
Parameters
Parameter |
Description |
Value |
---|---|---|
collector-id |
Specifies the ID of an sFlow collector. This ID is used when you specify the collector in subsequent sFlow configuration. |
The value is an integer that can be 1 or 2. |
vpn-instance vpn-instance-name |
Specifies the name of a VPN instance. |
The value must be an existing VPN instance name. |
ip-address |
Specifies an IPv4 address of the sFlow collector. |
The value is a value unicast IP address in X.X.X.X format, dotted decimal notation. The value cannot be 127.X.X.X. |
ipv6-address |
Specifies an IPv6 address for the sFlow collector. |
The value is a 32-digit hexadecimal number in the format of X:X:X:X:X:X:X:X and is a valid global IPv6 unicast address. |
datagram-size datagram-size |
Specifies the maximum length of sFlow packets sent from an sFlow agent to an sFlow collector. |
The value is an integer, in bytes. It ranges from 1024 to 8100. The default value is 1400. |
port port-num |
Specifies the UDP destination port number of sFlow packets. |
The value is an integer that ranges from 1 to 65535. The default value is 6343. |
description description |
Specifies the description of an sFlow collector. |
The value is a string of 1 to 255 case-sensitive characters without spaces. |
time-out time |
Specifies the aging time of an sFlow collector. |
The value is an integer that ranges from 0 to 3600, in seconds. The default value is 0, indicating that the sFlow collector is not aged out. If the default value is used, the aging time cannot be changed. |
Usage Guidelines
Usage scenario
sFlow is a traffic monitoring technique that collects and analyzes traffic statistics. An sFlow agent encapsulates traffic statistics into sFlow packets and sends the sFlow packets to all sFlow collectors. To send the sFlow packets to a certain sFlow collector, configure an sFlow collector used to receive sFlow packets and analyze traffic of sFlow packets. When both flow sampling and counter sampling are configured on an interface of an sFlow agent, the sFlow agent sends the flow sampling data and counter sampling data to one or two sFlow collectors. Because sFlow packets are sampled quickly and the number of sFlow packets sent every second is limited, run the sflow collector command with datagram-size length specified to set the maximum length of sFlow packets so that an sFlow packet carries more sampled data. This reduces the number of sent sFlow packets.
When you create an sFlow collector, specify the ID and IP address for the sFlow collector. If the aging time of the sFlow collector is not set, the sFlow collector is not aged out by default and the aging time cannot be changed.
Prerequisites
- There is a reachable route between an sFlow agent and an sFlow collector.
- A VPN instance has been created if the sFlow collector is located on a private network.
Configuration Impact
If you run the sflow collector command multiple times on the same address family and VPN instance, only the latest configuration takes effect.
Precautions
A maximum of two sFlow collectors can be configured in the system.
Example
# Configure an IPv4 address for the sFlow collector, and set the aging time of the sFlow collector to 100s.
<HUAWEI> system-view [HUAWEI] sflow collector 1 ip 192.168.100.10 time-out 100
# Configure an IPv6 address for the sFlow collector, and set the aging time of the sFlow collector to 100s.
<HUAWEI> system-view [HUAWEI] sflow collector 1 ipv6 FC00::1 time-out 100
sflow counter-sampling collector
Function
The sflow counter-sampling collector command specifies the target sFlow collector that receives counter sampling data.
The undo sflow counter-sampling collector command deletes the target sFlow collector.
By default, no target sFlow collector is specified.
Format
sflow counter-sampling collector { collector-id | all }
undo sflow counter-sampling collector { collector-id | all }
Parameters
Parameter |
Description |
Value |
---|---|---|
collector-id |
Specifies the ID of the target sFlow collector that receives counter sampling data. |
The value is an integer that can be 1 or 2. NOTE:
The value of collector-id is set using the sflow collector command. |
all |
Indicates all the configured sFlow collectors. |
- |
Usage Guidelines
Usage scenario
Counter sampling is based on time. An sFlow agent periodically obtains traffic statistics on an interface, encapsulates the traffic statistics into sFlow packets, and sends them to an sFlow collector. When multiple sFlow collectors are configured, you can run the sflow counter-sampling collector command to specify the target sFlow collector to receive the counter sampling data. Each interface can send sFlow sampling data to a maximum of two sFlow collectors.
When you run the sflow counter-sampling collector command to specify the first target sFlow collector on an interface, counter sampling is enabled on the interface. When you run the undo sflow counter-sampling collector command to delete the last target sFlow collector on an interface, counter sampling is disabled on the interface.
Prerequisites
An sFlow collector has been created using the sflow collector command.
Precautions
The sflow flow-sampling rate command only applies to Layer 2 physical interfaces, but does not apply to Eth-Trunk or Layer 3 interfaces. However, this command takes effect on the Layer 3 interface which is switched from a Layer 2 interface using the undo portswitch command, and can take effect on Eth-Trunk member interfaces.
Example
# Specify sFlow collector 1 to receive counter sampling data.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 1/0/1 [HUAWEI-GigabitEthernet1/0/1] sflow counter-sampling collector 1
# Configure a port group pg1 that has member ports GE1/0/2 and GE1/0/3, and specify sFlow collector 1 to receive counter sampling data for the port group pg1.
[HUAWEI] port-group pg1 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/2 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/3 [HUAWEI-port-group-pg1] sflow counter-sampling collector 1
sflow counter-sampling interval
Function
The sflow counter-sampling interval command sets the counter sampling interval on an interface.
The undo sflow counter-sampling interval command restores the default counter sampling interval on an interface.
By default, the counter sampling interval on an interface is 10s.
Views
Ethernet interface view, GE interface view, XGE interface view, 40GE interface view, 100GE interface view, port group view
Usage Guidelines
Usage scenario
Counter sampling is based on time. An sFlow agent periodically obtains traffic statistics on an interface, encapsulates the traffic statistics into sFlow packets, and sends them to an sFlow collector. You can run the sflow counter-sampling interval command to set an appropriate counter sampling interval.
Precautions
The sflow flow-sampling rate command only applies to Layer 2 physical interfaces, but does not apply to Eth-Trunk or Layer 3 interfaces. However, this command takes effect on the Layer 3 interface which is switched from a Layer 2 interface using the undo portswitch command, and can take effect on Eth-Trunk member interfaces. If you run the sflow flow-sampling rate command multiple times, only the latest configuration takes effect.
Example
# Set the counter sampling interval to 100s.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 1/0/1 [HUAWEI-GigabitEthernet1/0/1] sflow counter-sampling interval 100
# Configure a port group pg1 that has member ports GE1/0/2 and GE1/0/3, and set the counter sampling interval to 100s for the port group pg1.
[HUAWEI] port-group pg1 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/2 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/3 [HUAWEI-port-group-pg1] sflow counter-sampling interval 100
sflow flow-sampling
Function
The sflow flow-sampling command enables flow sampling in a specified direction on an interface.
The undo sflow flow-sampling command disables flow sampling in a specified direction on an interface.
By default, flow sampling is enabled in both directions on an interface.
Views
Ethernet interface view, GE interface view, XGE interface view, 40GE interface view, 100GE interface view, port group view
Usage Guidelines
Usage scenario
You can specify the direction in which flow sampling is performed. Flow sampling can be performed in both inbound and outbound directions.
Precautions
The sflow flow-sampling rate command only applies to Layer 2 physical interfaces, but does not apply to Eth-Trunk or Layer 3 interfaces. However, this command takes effect on the Layer 3 interface which is switched from a Layer 2 interface using the undo portswitch command, and can take effect on Eth-Trunk member interfaces. If you run the sflow flow-sampling rate command multiple times, only the latest configuration takes effect.
Example
# Enable flow sampling in the inbound direction.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 1/0/1 [HUAWEI-GigabitEthernet1/0/1] sflow flow-sampling inbound
# Configure a port group pg1 that has member ports GE1/0/2 and GE1/0/3, and enable flow sampling in the inbound direction of the port group pg1.
[HUAWEI] port-group pg1 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/2 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/3 [HUAWEI-port-group-pg1] sflow flow-sampling inbound
sflow flow-sampling collector
Function
The sflow flow-sampling collector command specifies the target sFlow collector that receives flow sampling data.
The undo sflow flow-sampling collector command deletes the target sFlow collector that receives flow sampling data.
By default, no target sFlow collector is specified.
Format
sflow flow-sampling collector { collector-id | all }
undo sflow flow-sampling collector { collector-id | all }
Views
Ethernet interface view, GE interface view, XGE interface view, 40GE interface view, 100GE interface view, port group view
Usage Guidelines
Usage scenario
An sFlow agent samples packets in a direction of an interface based on a sampling rate, analyzes packets, encapsulates sampled packets and analysis result into sFlow packets, and then sends the sFlow packets to an sFlow collector. When multiple sFlow collectors are configured, you can run the sflow flow-sampling collector command to specify one or two to receive sFlow packets. Each interface can send sFlow sampling packets to a maximum of two collectors.
When you run the sflow flow-sampling collector command to specify the first target sFlow collector on an interface, flow sampling is enabled on the interface. When you run the undo sflow flow-sampling collector command to delete the last target sFlow collector on an interface, flow sampling is disabled on the interface.
Prerequisites
An sFlow collector has been created using the sflow collector command.
Precautions
The sflow flow-sampling rate command only applies to Layer 2 physical interfaces, but does not apply to Eth-Trunk or Layer 3 interfaces. However, this command takes effect on the Layer 3 interface which is switched from a Layer 2 interface using the undo portswitch command, and can take effect on Eth-Trunk member interfaces.
Example
# Specify sFlow collector 1 to receive the flow sampling data.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 1/0/1 [HUAWEI-GigabitEthernet1/0/1] sflow flow-sampling collector 1
# Configure a port group pg1 that has member ports GE1/0/2 and GE1/0/3, and specify sFlow collector 1 to receive flow sampling data for the port group pg1.
[HUAWEI] port-group pg1 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/2 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/3 [HUAWEI-port-group-pg1] sflow flow-sampling collector 1
sflow flow-sampling max-header
Function
The sflow flow-sampling max-header command sets the maximum bytes of data that can be copied from a sampled packet in flow sampling.
The undo sflow flow-sampling max-header command restores the default maximum bytes of data.
By default, a maximum of 64 bytes of data can be copied from a sampled packet in flow sampling.
Views
Ethernet interface view, GE interface view, XGE interface view, 40GE interface view, 100GE interface view, port group view
Usage Guidelines
Usage scenario
An sFlow agent samples packets in a direction of an interface based on a sampling rate, analyzes packets, encapsulates sampled packets and analysis result into sFlow packets, and then sends the sFlow packets to an sFlow collector. The datagram size of sFlow packets is set using the sflow collector [ datagram-size datagram-size ] command. If only the information carried in the packet header is required, run the sflow flow-sampling max-header command to set the maximum length of data starting from the original packet header that can be copied from a sampled packet.
Precautions
The sflow flow-sampling rate command only applies to Layer 2 physical interfaces, but does not apply to Eth-Trunk or Layer 3 interfaces. However, this command takes effect on the Layer 3 interface which is switched from a Layer 2 interface using the undo portswitch command, and can take effect on Eth-Trunk member interfaces.
Example
# Set the maximum length of data starting from the original packet header that can be copied from a sampled packet to 256 bytes.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 1/0/1 [HUAWEI-GigabitEthernet1/0/1] sflow flow-sampling max-header 256
# Configure a port group pg1 that has member ports GE1/0/2 and GE1/0/3, and set the maximum length of data starting from the original packet header that can be copied from a sampled packet to 256 bytes for the port group pg1.
[HUAWEI] port-group pg1 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/2 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/3 [HUAWEI-port-group-pg1] sflow flow-sampling max-header 256
sflow flow-sampling rate
Function
The sflow flow-sampling rate command sets the sampling rate on an interface.
The undo sflow flow-sampling rate command restores the default sampling rate on an interface.
By default, the sampling rate on a 100GE interface is 1/204800, on a 40GE interface is 1/20480 and on other types of interfaces is 1/2048.
Views
Ethernet interface view, GE interface view, XGE interface view, 40GE interface view, 100GE interface view, port group view
Usage Guidelines
Usage scenario
An sFlow agent samples packets in a direction of an interface based on a sampling rate, analyzes packets, encapsulates sampled packets and analysis result into sFlow packets, and then sends the sFlow packets to an sFlow collector. You can run the sflow flow-sampling rate command to set the sampling rate to limit the number of sampled packets.
Precautions
The sflow flow-sampling rate command only applies to Layer 2 physical interfaces, but does not apply to Eth-Trunk or Layer 3 interfaces. However, this command takes effect on the Layer 3 interface which is switched from a Layer 2 interface using the undo portswitch command, and can take effect on Eth-Trunk member interfaces. If you run the sflow flow-sampling rate command multiple times, only the latest configuration takes effect.
Example
# Set the sampling rate to 1/3072.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 1/0/1 [HUAWEI-GigabitEthernet1/0/1] sflow flow-sampling rate 3072
# Configure a port group pg1 that has member ports of GE1/0/2 and GE1/0/3, and set the sampling rate to 1/3072 for the port group pg1.
[HUAWEI] port-group pg1 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/2 [HUAWEI-port-group-pg1] group-member gigabitethernet 1/0/3 [HUAWEI-port-group-pg1] sflow flow-sampling rate 3072