AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 425828
Accepted
Mike Pennington
Mike Pennington
Asked: 2012-09-10 19:43:09 +0800 CST2012-09-10 19:43:09 +0800 CST 2012-09-10 19:43:09 +0800 CST

Graphite SNMP 计数器转换

  • 772

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

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

常识告诉您,您需要将 Octets 计数器乘以 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>

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

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

[default]
pattern = .*
retentions = 60s:1w, 5m:1y

/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

输出自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#

输出自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#
networking
  • 3 3 个回答
  • 17321 Views

3 个回答

  • Voted
  1. Best Answer
    Niels
    2012-10-30T10:16:20+08:002012-10-30T10:16:20+08:00

    如果你想要每秒位数,你需要指定 1 而不是 60 作为scaleToSeconds()函数的第二个参数,因为你想要每秒,而不是每分钟。(助记:是到秒,不是从秒:)

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

    • 5
  2. Clayton Dukes
    2016-03-16T12:09:45+08:002016-03-16T12:09:45+08:00

    我花了几个小时试图让它在 Grafana v2.6 中正常工作,但找不到合适的解决方案。所以这里是:

    1. 确保您在中定义了正确的存储聚合/etc/carbon/storage-aggregation.conf

    我所有的网络设备都以net

    [net] pattern = ^net.* retentions = 10s:7d,5m:180d,5m:5y

    1. 创建/etc/collectd/collectd.conf.d/snmp.conf并添加以下内容:

      FQDNLookup true
      AutoLoadPlugin true
      Interval 10
      LoadPlugin syslog
      <Plugin syslog>
        LogLevel info
      </Plugin>
      
      LoadPlugin contextswitch
      LoadPlugin cpu
      LoadPlugin df
      LoadPlugin entropy
      
      LoadPlugin interface
      LoadPlugin irq
      LoadPlugin load
      LoadPlugin memory
      LoadPlugin processes
      #LoadPlugin sensors
      LoadPlugin swap
      LoadPlugin unixsock
      LoadPlugin users
      LoadPlugin write_graphite
      
      <Plugin write_graphite>
        <Node "stats">
          Host "stats.foo.com"
          Port "2003"
          Protocol "tcp"
          LogSendErrors true
          Prefix "net."
          SeparateInstances true
          StoreRates true
          AlwaysAppendDS false
          EscapeCharacter "_"
        </Node>
      </Plugin>
      
      <Plugin unixsock>
        SocketFile "/var/run/collectd-unixsock"
        SocketGroup "adm"
        SocketPerms "0660"
      </Plugin>
      
      <Plugin df>
        # ignore rootfs; else, the root file-system would appear twice, causing
        # one of the updates to fail and spam the log
        FSType rootfs
        # ignore the usual virtual / temporary file-systems
        FSType sysfs
        FSType proc
        FSType devtmpfs
        FSType devpts
        FSType tmpfs
        FSType fusectl
        FSType cgroup
        IgnoreSelected true
      </Plugin>
      
      # added a special types.db for cisco devices
      TypesDB "/usr/share/collectd/types.db" "/usr/share/collectd/types.custom.db"
      
      LoadPlugin snmp
      <Plugin snmp>
        # the <Data> name is what to <Collect> down in the <Host> blocks
        # the "Type" must be from the list included in /usr/share/collectd/types.db (or custom.db)
        <Data "if_octets">
          Type "if_octets"
          Table true
          # Note: I use ifAlias so that it shows the Interface Descriptions instead just "GigabitEthernet_1_0_0, etc. But of course, make sure you have interface descriptions if you use this :)
          Instance "IF-MIB::ifAlias"
          Values "IF-MIB::ifHCInOctets" "IF-MIB::ifHCOutOctets"
        </Data>
        <Data "if_errors">
          Type "if_errors"
          Table true
          Instance "IF-MIB::ifAlias"
          Values "IF-MIB::ifInErrors" "IF-MIB::ifOutErrors"
        </Data>
        <Data "cisco_cpu">
          Type "cisco_cpu"
          Table true
          Values "CISCO-PROCESS-MIB::cpmCPUTotal5secRev" "CISCO-PROCESS-MIB::cpmCPUTotal1minRev" "CISCO-PROCESS-MIB::cpmCPUTotal5minRev"
        </Data>
        <Data "uptime">
          Type "uptime"
          Table false
          Instance "Uptime"
          scale 0.01
          Values  "DISMAN-EVENT-MIB::sysUpTimeInstance"
        </Data>
        <Data "memory_free">
          Type "memory_free"
          Table true
          Instance "CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolName"
          Values  "CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree"
        </Data>
        <Data "memory_used">
          Type "memory_used"
          Table true
          Instance "CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolName"
          Values "CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed"
        </Data>
      
        # Hosts:
        <Host "rtr">
          Address "192.168.1.1"
          Version 2
          Community "public"
          Collect "if_octets" "cisco_cpu" "uptime"
          Interval 10
        </Host>
        <Host "switch">
          Address "192.168.1.254"
          Version 2 
          Community "public"
          Collect "if_octets" "cisco_cpu" "uptime"
          Interval 10
        </Host>
      </Plugin>
      

    这是 custom.db:(我不记得我从哪里得到原件,但多亏了那个家伙!)

    if_stats                ifHCInOctets:COUNTER:0:U, ifHCOutOctets:COUNTER:0:U, ifHCInUcastPkts:COUNTER:0:U, ifHCInMulticastPkts:COUNTER:0:U, ifHCInBroadcastPkts:COUNTER:0:U, ifHCOutUcastPkts:COUNTER:0:U, ifHCOutMulticastPkts:COUNTER:0:U, ifHCOutBroadcastPkts:COUNTER:0:U, ifInDiscards:COUNTER:0:U, ifInErrors:COUNTER:0:U, ifOutDiscards:COUNTER:0:U, ifOutErrors:COUNTER:0:U
    if_octets_hc     ifHCInOctets:COUNTER:0:U, ifHCOutOctets:COUNTER:0:U
    if_packets_hc                   ifHCInUcastPkts:COUNTER:0:U, ifHCInMcastPkts:COUNTER:0:U, ifHCInBcastPkts:COUNTER:0:U, ifHCOutUcastPkts:COUNTER:0:U, ifHCOutMcastPkts:COUNTER:0:U, ifHCOutBcastPkts:COUNTER:0:U
    if_drop_discard_err_que         ifInDiscards:COUNTER:0:U, ifInErrors:COUNTER:0:U, ifOutDiscards:COUNTER:0:U, ifOutErrors:COUNTER:0:U
    if_rgpackets                   ifInUcastPkts:COUNTER:0:U, ifInNUcastPkts:COUNTER:0:U, ifOutUcastPkts:COUNTER:0:U, ifOutNUcastPkts:COUNTER:0:U
    sensors                      sensorValue:GAUGE:U:U, sensorThreshold:GAUGE:U:U
    uptime                  uptime:GAUGE:U:U
    cisco_cpu       cpu5sec:GAUGE:0:100, cpu1min:GAUGE:0:100, cpu5min:GAUGE:0:100
    routes  ipv4routes:GAUGE:0:U, ipv6routes:GAUGE:0:U, mcastroutes:GAUGE:0:U
    ipsla   rttAdmNumDistBkt:GAUGE:0:200, rttAdmDistInt:GAUGE:0:200, rttTotalsInit:COUNTER:0:U, rttCollectDrops:COUNTER:0:U, rttCollectTimeouts:COUNTER:0:U, rttCptComplTimeMn:GAUGE:0:100000, rttCptComplTimeMx:GAUGE:0:100000, rttCptSumCmpTm2Hi:COUNTER:0:U, rttCptSumCmpTm2Lo:COUNTER:0:U, rttCptSumCmpTm:COUNTER:0:U, rttCptOverThres:COUNTER:0:U
    ipslaminimal   rttCptCompletions:COUNTER:0:U
    ipsla2  rttCollectTimeouts:COUNTER:0:U
    

    如果有人有正确的配置(和types.custom.db)来跟踪其他思科指标,如电源、双工、风扇、(特别是)NBAR 等。请分享!

    在 Grafana 中,像这样配置图表:

    alias(scale(scaleToSeconds(net.rtr.snmp.if_octets.RTR-Outside-Gi0_0.rx, 0.125), 3600), 'Download')
    

    您需要替换net.rtr.snmp.if_octets.RTR-Outside-Gi0_0为您的设备名称和 ifAlias

    • 1
  3. AXE Labs
    2014-01-15T13:00:47+08:002014-01-15T13:00:47+08:00

    我正在运行 Graphite 0.9.9,scaleToSeconds 对我不可用。要解决这个问题,您需要详细了解指标......以我的例子为例:

    1000baseT 接口使用图

    Y 值以百万为单位,而不是 Mbps。您可以通过在图表 URL 中设置 yUnitSystem=none 来验证这一点。其次,一个八位字节是一个字节的 8 位数据。我的 2000000000 字节(八位字节)峰值是每分钟的指标,因此为了更清楚地理解它,我们可以做数学运算:

    2000000000B/60s ≈ 33333333B/s ≈ 32 兆字节/秒 ≈ 254 兆比特/秒

    我的千兆以太网 (1000 Mbps) 接口上的 254 Mbps 完全在其能力范围内。我希望这有帮助。

    • 0

相关问题

  • 谁能指出我的 802.11n 范围扩展器?

  • 我怎样才能得到一个网站的IP地址?

  • 在一个 LAN 中使用两台 DHCP 服务器

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve