Passei horas tentando fazer isso funcionar corretamente no Grafana v2.6 e não consegui encontrar a solução certa. Então aqui está:
- Verifique se você tem a Agregação de armazenamento correta definida em
/etc/carbon/storage-aggregation.conf
Eu tenho todos os meus dispositivos de rede prefixados com net
[net]
pattern = ^net.*
retentions = 10s:7d,5m:180d,5m:5y
-
Crie /etc/collectd/collectd.conf.d/snmp.conf
e adicione o seguinte:
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>
Aqui está o custom.db: (não me lembro de onde obtive o original, mas graças a esse cara!)
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
Se alguém tiver a configuração correta (e types.custom.db
) para rastrear outras métricas da Cisco, como Fonte de alimentação, Frente e verso, Ventiladores, (ESPECIALMENTE) NBAR, etc. Compartilhe!
No Grafana, configure o gráfico da seguinte forma:
alias(scale(scaleToSeconds(net.rtr.snmp.if_octets.RTR-Outside-Gi0_0.rx, 0.125), 3600), 'Download')
Você precisará substituir net.rtr.snmp.if_octets.RTR-Outside-Gi0_0
pelo nome do seu dispositivo e ifAlias