Graphite SNMP 计数器转换

Thi*_*his 4 networking snmp collectd graphite

我正在使用石墨版本 0.9.10 来读取ifHCInOctetsand ifHCOutOctets,我正在使用和插件进行轮询;我使用的是5.1.0 版。collectd snmpgraphite_writecollectd

数据毫无问题地到达石墨;但是,我想以每秒位数表示。为了测试我的统计数据是否正确,我开始了 CD iso 下载并观察了下载速率……它在 1.0Mbps 和 2.0Mbps 之间变化。

常识告诉您,您需要将八位字节计数器乘以 8 才能得到位;但是,似乎我需要除以 8 才能正确显示石墨。

当我乘以 0.125 比例因子时scale(scaleToSeconds(nonNegativeDerivative(<SERIES>), 60),0.125),公式正确转换为每秒位数,我看到 1Mpbs 和 2Mbps 之间的数字......

正确比例 - 0.125

当我乘以 8.0 比例因子时scale(scaleToSeconds(nonNegativeDerivative(<SERIES>), 60),8),结果显然是错误的……图表峰值为 120Mbps。我知道这是错误的,因为这是一个具有 5M 上限的住宅电缆调制解调器。

错误的比例

问题:如果我将八位字节发送到石墨,为什么会scale(<foo>, 8)产生不正确的结果?


/opt/collectd/etc/collectd.conf

LoadPlugin syslog 
LoadPlugin cpu
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin snmp
LoadPlugin write_graphite

<Plugin snmp>
   <Data "std_traffic">
       Type "if_octets"
       Table true
       Instance "IF-MIB::ifName"
       Values "IF-MIB::ifHCInOctets" "IF-MIB::ifHCOutOctets"
   </Data>

   <Host "fw.pennington.net">
       Address "172.16.1.1"
       Version 2
       Community "public"
       Collect "std_traffic"
       Interval 60
   </Host>
</Plugin>

<Plugin write_graphite>
  <Carbon>
    Host "localhost"
    Port "2003"
    Prefix ""
    Postfix ""
    StoreRates false
    AlwaysAppendDS false
    EscapeCharacter "_"
  </Carbon>
</Plugin>
Run Code Online (Sandbox Code Playgroud)

/opt/graphite/conf/storage-schema.conf:

[carbon]
pattern = ^carbon\.
retentions = 60s:90d

[default]
pattern = .*
retentions = 60s:1w, 5m:1y
Run Code Online (Sandbox Code Playgroud)

/opt/graphite/conf/carbon.conf:

[cache]

USER = carbon

MAX_CACHE_SIZE = inf

MAX_UPDATES_PER_SECOND = 500

MAX_CREATES_PER_MINUTE = 50

LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2003

ENABLE_UDP_LISTENER = False
UDP_RECEIVER_INTERFACE = 0.0.0.0
UDP_RECEIVER_PORT = 2003

PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2004

USE_INSECURE_UNPICKLER = False

CACHE_QUERY_INTERFACE = 0.0.0.0
CACHE_QUERY_PORT = 7002

USE_FLOW_CONTROL = True

LOG_UPDATES = False

WHISPER_AUTOFLUSH = False

[relay]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2013
PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2014

RELAY_METHOD = rules

REPLICATION_FACTOR = 1

DESTINATIONS = 127.0.0.1:2004

MAX_DATAPOINTS_PER_MESSAGE = 500
MAX_QUEUE_SIZE = 10000

USE_FLOW_CONTROL = True

[aggregator]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2023

PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2024

DESTINATIONS = 127.0.0.1:2004

REPLICATION_FACTOR = 1

MAX_QUEUE_SIZE = 10000

USE_FLOW_CONTROL = True

MAX_DATAPOINTS_PER_MESSAGE = 500

MAX_AGGREGATION_INTERVALS = 5
Run Code Online (Sandbox Code Playgroud)

输出来自 whisper-fetch.py

root@tsunami:/opt/graphite/conf# python /usr/local/bin/whisper-fetch.py --pretty /opt/graphite/storage/whisper/fw_pennington_net/snmp/if_octets-Ethernet0_0/rx.wsp
Mon Sep 10 02:53:00 2012        110454375894.000000
...
Tue Sep 11 02:50:00 2012        110532796093.000000
Tue Sep 11 02:51:00 2012        110532819931.000000 <------------ Correct
Tue Sep 11 02:52:00 2012        None
root@tsunami:/opt/graphite/conf#
Run Code Online (Sandbox Code Playgroud)

输出来自 show interface eth0/0

mpenning-fw# sh int eth0/0
Interface Ethernet0/0 "", is up, line protocol is up
  Hardware is 88E6095, BW 100 Mbps, DLY 100 usec
        Auto-Duplex(Full-duplex), Auto-Speed(100 Mbps)
        Description: TIME WARNER 5Mbps circuit
        Available but not configured via nameif
        MAC address 0019.0726.4a39, MTU not set
        IP address unassigned
        157040376 packets input, 110532814004 bytes, 0 no buffer
                                 ^^^^^^^^^^^^^^^^^^
        Received 68921847 broadcasts, 0 runts, 0 giants
        0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
        0 L2 decode drops
        8589974681 switch ingress policy drops
        57851429 packets output, 8036229250 bytes, 0 underruns
        0 output errors, 0 collisions, 0 interface resets
        0 babbles, 0 late collisions, 0 deferred
        0 lost carrier, 0 no carrier
        0 rate limit drops
        0 switch egress policy drops
mpenning-fw#
Run Code Online (Sandbox Code Playgroud)

小智 5

如果您想要每秒位数,您需要指定 1 而不是 60 作为scaleToSeconds()函数的第二个参数,就像您想要的每秒一样,而不是每分钟。(助记:这是秒,而不是秒:)

这是实现该功能的原始补丁;它可能会澄清。