在文件中收集流量采样输出
您可以将流量采样结果配置为 /var/tmp 目录中的文件。要在文件中收集采样数据包,请在层次结构级别包含 file
语句 [edit forwarding-options sampling output]
:
[edit forwarding-options sampling family family-name output] file <disable> filename filename <files number> <size bytes> <stamp | no-stamp > <world-readable | no-world-readable>;
要配置导出活动流之前的时间段,请在层次结构级别包含 flow-active-timeout
语句 [edit forwarding-options sampling output family (inet | inet6 | mpls)]
:
[edit forwarding-options sampling family (inet | inet6 | mpls) output] flow-active-timeout seconds;
要配置流被视为非活动之前的时间段,请在层次结构级别包含 flow-inactive-timeout
语句 [edit forwarding-options sampling output]
:
[edit forwarding-options sampling family (inet | inet6 | mpls) output] flow-inactive-timeout seconds;
要配置发送受监控信息的接口,请在层次结构级别包含 interface
语句 [edit forwarding-options sampling output]
:
[edit forwarding-options sampling family (inet | inet6 | mpls) output] interface interface-name { engine-id number; engine-type number; source-address address; }
版本 9 模板格式不支持此功能。必须将使用版本 9 收集的流量发送到服务器。有关详细信息 ,请参阅以 Cisco Systems NetFlow 服务导出版本 9 格式收集流量采样输出。
流量采样输出格式
流量采样输出将保存到 ASCII 文本文件中。以下是保存到 /var/tmp 目录中的文件的流量采样输出的示例。输出文件中的每一行都包含一个采样数据包的信息。您可以选择显示每行的时间戳。
列标题在每组 1000 个数据包之后重复。
# Apr 7 15:48:50 Time Dest Src Dest Src Proto TOS Pkt Intf IP TCP addr addr port port len num frag flags Apr 7 15:48:54 192.168.9.194 192.168.9.195 0 0 1 0x0 84 8 0x0 0x0 Apr 7 15:48:55 192.168.9.194 192.168.9.195 0 0 1 0x0 84 8 0x0 0x0 Apr 7 15:48:56 192.168.9.194 192.168.9.195 0 0 1 0x0 84 8 0x0 0x0 Apr 7 15:48:57 192.168.9.194 192.168.9.195 0 0 1 0x0 84 8 0x0 0x0 Apr 7 15:48:58 192.168.9.194 192.168.9.195 0 0 1 0x0 84 8 0x0 0x0
输出包含以下字段:
时间 — 接收数据包的时间(仅当您在配置中包含语句时才
stamp
显示)目标地址 — 数据包中的目标 IP 地址
Src addr — 数据包中的源 IP 地址
目标端口 — 目标地址的传输控制协议 (TCP) 或用户数据报协议 (UDP) 端口
源端口 — 源地址的 TCP 或 UDP 端口
原型 — 数据包的协议类型
TOS — IP 报头中服务类型 (ToS) 字段的内容
pkt len — 采样数据包的长度,以字节为单位
Intf num — 标识采样逻辑接口的唯一编号
IP 碎片 — IP 片段编号(如果适用)
TCP 标志 — 在 IP 报头中找到的任何 TCP 标志
要为文件 my-sample 设置时间戳选项,请输入以下内容:
[edit forwarding-options sampling family (inet | inet6 | mpls) output file] user@host# set filename my-sample files 5 size 2m world-readable stamp;
每当切换时间戳选项时,文件中都会包含一个新的标头。如果设置了 戳 记选项,则会显示 “时间” 字段。
# Apr 7 15:48:50 # Time Dest Src Dest Src Proto TOS Pkt Intf IP TCP # addr addr port port len num frag flags # Feb 1 20:31:21 # Dest Src Dest Src Proto TOS Pkt Intf IP TCP # addr addr port port len num frag flags