cisco Content Hub Configuring sFlow User Guide

June 8, 2024
Cisco

cisco-Nexus-3000-Series-Low-Latency-Switches-logo

cisco Content Hub Configuring sFlow

cisco-Content-Hub-Configuring-sFlow-product-image

Information About sFlow

sFlow allows you to monitor the real-time traffic in data networks that contain switches and routers. It uses the sampling mechanism in the sFlow Agent software on switches and routers for monitoring traffic and to forward the sample data on ingress and egress ports to the central data collector, also called the sFlow Analyzer.
For more information about sFlow, see RFC 3176.

sFlow Agent

The sFlow Agent, which is embedded in the Cisco NX-OS software, periodically samples or polls the interface counters that are associated with a data source of the sampled packets. The data source can be an Ethernet interface, an Ether Channel interface, or a range of Ethernet interfaces. The sFlow Agent queries the Ethernet port manager for the respective Ether Channel membership information and also receives notifications from the Ethernet port manager for membership changes.
When you enable sFlow sampling in the Cisco NX-OS software, based on the sampling rate and the hardware internal random number, the ingress packets and egress packets are sent to the CPU as an sFlow-sampled packet. The sFlow Agent processes the sampled packets and sends an sFlow datagram to the sFlow Analyzer. In addition to the original sampled packet, an sFlow datagram includes the information about the ingress port, egress port, and the original packet length. An sFlow datagram can have multiple sFlow samples.

Prerequisites

You must enable the sFlow feature using the feature sflow command to configure sFlow.

Guidelines and Limitations for sFlow

The sFlow configuration guidelines and limitations are as follows:

  • When you enable sFlow for an interface, it is enabled for both ingress and egress. You cannot enable sFlow for only ingress or only egress.
  • sFlow egress sampling for multicast, broadcast, or unknown unicast packets is not supported.
  • You should configure the sampling rate based on the sFlow configuration and traffic in the system.
  • Cisco Nexus 3000 Series supports only one sFlow collector.

Default Settings for sFlow

Table 1: Default sFlow Parameters

Parameters Default
sFlow sampling-rate 4096
sFlow sampling-size 128
sFlow max datagram-size 1400
sFlow collector-port 6343
sFlow counter-poll-interval 20

Configuring sFLow

Enabling the sFlow Feature

You must enable the sFlow feature before you can configure sFlow on the switch.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] feature sflow| Enables the sFlow feature.
Step 3| (Optional) show feature| Displays enabled and disabled features.
| Command or Action| Purpose
---|---|---
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running

configuration to the startup configuration.

Example
The following example shows how to enable the sFlow feature:

  • switch# configure terminal
  • switch(config)# feature sflow
  • switch(config)# copy running-config startup-config
Configuring the Sampling Rate

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow sampling-rate sampling-rate| Configures the sFlow sampling rate for packets.
The sampling-rate can be an integer between 4096-1000000000. The default value is 4096.
Step 3| (Optional) show sflow| Displays sFlow information.
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example
This example shows how to set the sampling rate to 50,000:

  • switch# configure terminal
  • switch(config)# sflow sampling-rate 50000
  • switch(config)# copy running-config startup-config
Configuring the Maximum Sampled Size

You can configure the maximum number of bytes that should be copied from a sampled packet.

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow max-sampled-size sampling-size| Configures the sFlow maximum sampling size packets.
The range for the sampling-size is from 64 to 256 bytes. The default value is 128.
Step 3| (Optional) show sflow| Displays sFlow information.
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running

configuration to the startup configuration.

Example
This example shows how to configure the maximum sampling size for the sFlow Agent:

  • switch# configure terminal
  • switch(config)# sflow max-sampled-size 200
  • switch(config)# copy running-config startup-config
Configuring the Counter Poll Interval

You can configure the maximum number of seconds between successive samples of the counters that are associated with the data source. A sampling interval of 0 disables counter sampling.

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow counter-poll-interval poll-interval| Configures the sFlow poll interval for an interface. The range for the poll- interval is from 0 to 2147483647 seconds. The default value is 20.
Step 3| (Optional) show sflow| Displays sFlow information.
| Command or Action| Purpose
---|---|---
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running

configuration to the startup configuration.

Example
This example shows how to configure the sFlow poll interval for an interface:

  • switch# configure terminal
  • switch(config)# sflow counter-poll-interval 100
  • switch(config)# copy running-config startup-config
Configuring the Maximum Datagram Size

You can configure the maximum number of data bytes that can be sent in a single sample datagram.

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow max-datagram-size datagram-size| Configures the sFlow maximum datagram size.

The range for the datagram-size is from 200 to 9000 bytes. The default value is 1400.

Step 3| (Optional) show sflow| Displays sFlow information.
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running

configuration to the startup configuration.

Example
This example shows how to configure the sFlow maximum datagram size:

  • switch# configure terminal
  • switch(config)# sflow max-datagram-size 2000
  • switch(config)# copy running-config startup-config
    [########################################] 100%
Configuring the sFlow Analyzer Address

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow collector-ip IP-address vrf- instance| Configures the IPv4 address for the sFlow Analyzer.
vrfinstance can be one of the following:

  • A user-defined VRF name—You can specify a maximum of 32 alphanumeric characters.
  • vrf management — You must use this option if the sFlow data collector is on the network connected to the management port.
  • vrf default — You must use this option if the sFlow data collector is on the network connected to the front panel ports.

Step 3| (Optional) show sflow| Displays sFlow information.
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example
This example shows how to configure the IPv4 address of the sFlow data collector that is connected  to the management port:

  • switch# configure terminal
  • switch(config)# sflow collector-ip 192.0.2.5 vrf management
  • switch(config)# copy running-config startup-config
Configuring the sFlow Analyzer Port

You can configure the destination port for sFlow datagrams.

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow collector-port collector-port| Configures the UDP port of the sFlow Analyzer.
The range for the collector-port is from 0 to 65535. The default value is 6343.
Step 3| (Optional) show sflow| Displays sFlow information.
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example
This example shows how to configure the destination port for sFlow datagrams:

  • switch# configure terminal

  • switch(config)# sflow collector-port 7000

  • switch(config)# copy running-config startup-config
    [########################################] 100%

  • switch(config)#

Configuring the sFlow Agent Address

Before you begin
Ensure that you have enabled the sFlow feature.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| [ no ] sflow agent-ip ip-address| Configures the IPv4 address of the sFlow Agent.

The default ip-address is 0.0.0.0, which means that all sampling is disabled on the switch. You must specify a valid IP address to enable sFlow functionality.
Note This IP address is not necessarily the source IP address for sending the sFlow datagram to the collector.

Step 3| (Optional) show sflow| Displays sFlow information.
| Command or Action| Purpose
---|---|---
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example
This example shows how to configure the IPv4 address of the sFlow Agent:

  • switch# configure terminal
  • switch(config)# sflow agent-ip 192.0.2.3
  • switch(config)# copy running-config startup-config
Configuring the sFlow Sampling Data Source

The sFlow sampling data source can be an Ethernet port, a range of Ethernet ports, or a port channel.

Before you begin

  • Ensure that you have enabled the sFlow feature.
  • If you want to use a port channel as the data source, ensure that you have already configured the port channel and you know the port channel number.

Procedure

| Command or Action| Purpose
---|---|---
Step 1| switch# configure terminal| Enters global configuration mode.
Step 2| switch(config)# [ no ] sflow data-source interface [ ethernet slot / port [- port ] | port-channel channel-number ]| Configures the sFlow sampling data source.
For an Ethernet data source, slot is the slot number and port can be either a single port number or a range of ports designated as portport.
Step 3| (Optional) switch(config)# show sflow| Displays sFlow information.
Step 4| (Optional) switch(config)# copy running-config startup- config| Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example
This example shows how to configure Ethernet ports 5 through 12 for the sFlow sampler:

  • switch# configure terminal

  • switch(config)# sflow data-source interface ethernet 1/5-12

  • switch(config)# copy running-config startup-config
    [########################################] 100%

  • switch(config)#

This example shows how to configure port channel 100 for the sFlow sampler:

  • switch# configure terminal
  • switch(config)# sflow data-source interface port-channel 100 switch(config)# copy running-config startup-config [########################################] 100%
  • switch(config)#
Verifying the sFlow Configuration

Use the following commands to verify the sFlow configuration information:

Command Purpose
show sflow Displays the sFlow global configuration.
show sflow statistics Displays the sFlow statistics.
clear sflow statistics Clears the sFlow statistics.
show running-config sflow [ all ] Displays the current running sFlow

configuration.

Configuration Examples for sFlow

This example shows how to configure sFlow:

  • feature sflow
  • sflow sampling-rate 5000
  • sflow max-sampled-size 200
  • sflow counter-poll-interval 100
  • sflow max-datagram-size 2000
  • sflow collector-ip 192.0.2.5 vrf management sflow collector-port 7000
  • sflow agent-ip 192.0.2.3
  • sflow data-source interface ethernet 1/5
Additional References for sFlow

Table 2: Related Documents for sFlow

Related Topic Document Title
sFlow CLI commands Cisco Nexus 3000 Series NX-OS System

Management Command Reference.
RFC 3176| Defines the sFlow packet format and SNMP MIB.

http://www.sflow.org/rfc3176.txt

Feature History for sFlow

This table includes only the updates for those releases that have resulted in additions or changes to the feature.

Feature Name Releases Feature Information
sFlow 5.0(3)U4(1) This feature was introduced.

Read User Manual Online (PDF format)

Loading......

Download This Manual (PDF format)

Download this manual  >>

Related Manuals