Поиск по этому блогу

18.04.2017

Сбор Cisco SLA по snmp telegraf'ом

На L3 коммутаторе созданы пара простых SLA, весь смысл которых пинговать удаленный адрес.
ip sla 1
 icmp-echo  99.99.99.99 source-ip 99.99.99.100
 threshold 100
 timeout 1000
 owner org1@Address-1--Address-2
 tag MEGATELECOM
ip sla schedule 1 life forever start-time now

ip sla 2
 icmp-echo  88.88.88.88 source-ip  88.88.88.100
 threshold 100
 timeout 1000
 owner org1@Address-1--Address-3
 tag TAKSEBETK
ip sla schedule 2 life forever start-time now
Поля owner и tag будут записаны в базу influxdb в качестве тегов. Предварительно надо написать view для snmp, т.к. cisco некорректно возвращает вывод данных rttMonLatestRttOperAddress при запросе таблицы rttMonLatestRttOperTable. Поэтому так, иначе - беда:
snmp-server view data ccitt included
snmp-server view data system included
snmp-server view data ifMIB included
snmp-server view data ifEntry included
snmp-server view data dot3.2 included
snmp-server view data lsystem included
snmp-server view data ciscoRttMonMIB included
snmp-server view data ipAddrEntry.2 included
snmp-server view data ifName included
snmp-server view data entPhysicalEntry included
snmp-server view data ciscoEnvMonTemperatureStatusEntry included
snmp-server view data ciscoMemoryPoolEntry included
snmp-server view data rttMonLatestRttOperEntry.3 excluded
snmp-server view data rttMonLatestRttOperEntry.4 excluded
snmp-server view data rttMonLatestRttOperEntry.5 excluded
snmp-server view data rttMonLatestRttOperEntry.6 excluded
snmp-server community bublic view data RO
Или так, если IOS не такой древний, как в предыдущем случае:
[пропущено]
snmp-server view data rttMonLatestRttOperApplSpecificSense excluded
snmp-server view data rttMonLatestRttOperSenseDescription excluded
snmp-server view data rttMonLatestRttOperTime excluded
snmp-server view data rttMonLatestRttOperAddress excluded
По snmp будет следующий краткий ответ без мусора с пустыми полями:
$snmpwalk -c public -v2c с3750 CISCO-RTTMON-MIB::rttMonLatestRttOperTable
CISCO-RTTMON-MIB::rttMonLatestRttOperCompletionTime.1 = Gauge32: 1 milliseconds/microseconds
CISCO-RTTMON-MIB::rttMonLatestRttOperCompletionTime.2 = Gauge32: 1 milliseconds/microseconds
CISCO-RTTMON-MIB::rttMonLatestRttOperSense.1 = INTEGER: ok(1)
CISCO-RTTMON-MIB::rttMonLatestRttOperSense.2 = INTEGER: ok(1)
Необходимо протестировать конфигурационный файл telegraf'а test.cfg:
[пропущена часть с описанием базы]
[[inputs.snmp]]
  interval = "1m"
  agents = [ "с3750" ]
  version = 2
  community = "bublic"

  [[inputs.snmp.table]]
    name = "rttMonLatestRttOperTable"
    oid = "CISCO-RTTMON-MIB::rttMonLatestRttOperTable"

    [[inputs.snmp.table.field]]
      name = "descr"
      oid = "CISCO-RTTMON-MIB::rttMonCtrlAdminOwner"
      is_tag = true

    [[inputs.snmp.table.field]]
      name = "type"
      oid = "CISCO-RTTMON-MIB::rttMonCtrlAdminTag"
      is_tag = true
Запуск telegraf'а для выполнения опроса без записи в базу:
$ telegraf -config test.cfg -test
* Plugin: inputs.snmp, Collection 1
* Internal: 1m0s
> rttMonLatestRttOperTable,descr=org1@Address-1--Address-2,type=MEGATELECOM,agent_host=c3750,host=ubuntu rttMonLatestRttOperCompletionTime=1i,rttMonLatestRttOperSense=1i 1492499694000000000
> rttMonLatestRttOperTable,agent_host=c3750,host=ubuntu,descr=org1@Address-1--Address-3,type=TAKSEBETK rttMonLatestRttOperCompletionTime=1i,rttMonLatestRttOperSense=1i 1492499694000000000
Оставлю здесь значения статусов rttMonLatestRttOperSense:
other(0) - the operation is not started or completed or this object is not applicable for the probe type.
ok(1) - a valid completion occurred and timed successfully
disconnected(2) - the operation did not occur because the connection to the target was lost
overThreshold(3) - a valid completion was received but the completion time exceeded a threshold value
timeout(4) - an operation timed out; no completion time recorded
Конфигурация для прочих SLA выглядит аналогично:
  [[inputs.snmp.table]]
    name ="rttMonLatestJitterOperTable"
    oid = "CISCO-RTTMON-MIB::rttMonLatestJitterOperTable"

    [[inputs.snmp.table.field]]
      name = "descr"
      oid = "CISCO-RTTMON-MIB::rttMonCtrlAdminOwner"
      is_tag = true

    [[inputs.snmp.table.field]]
      name = "type"
      oid = "CISCO-RTTMON-MIB::rttMonCtrlAdminTag"
      is_tag = true
Данные запишутся в базу как measurements rttMonLatestRttOperTable и rttMonLatestJitterOperTable, откуда уже можно будет выбирать статус и rtt.