6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Prometheus/GrafanaでCatalystのトラフィックを収集してみる

Last updated at Posted at 2019-10-24

Cisco の Catalyst2960-8のトラフィックデータをPrometheusで取ってみることにしました。

例によって環境ですが、
・MacBookPro(macOS10.14.6)
・WS-C2960-8TC-L(12.2(53)SE2 LANBASE)
・Ubuntu 18.04.2
・DockerCE
・docker-compose

今回はトラフィックデータを取ること"のみ"が目的なので、定番のnode-exporterやAlertManagerは次の機会にします。早速、docker-composeで。

参考にしたのは、「prometheusのsnmp exporterをdockerで動かす」ですが、参考というよりほぼ"まんま"です。。。

docker-compose.yml
version: '3'
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - ./prometheus-data:/prometheus
    ports:
      - 9090:9090
  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    volumes:
      - ./grafana-data:/var/lib/grafana
    ports:
      - 3000:3000
  snmp-exporter:
    image: prom/snmp-exporter:latest
    container_name: snmp-exporter
    volumes:
      - ./snmp.yml:/etc/snmp_exporter/snmp.yml
    ports:
      - 9116:9116

volumes(永続化されるコンテナ外領域)に指定されている各設定ファイル(*.yml)が無いといろいろ起動しないので、作っていきます。

prometheus.yml

global:
#  scrape_interval: 15s
  scrape_interval: 1s
  external_labels:
    monitor: 'codelab_monitor'

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'snmp-exporter'
    static_configs:
      - labels:
          type: cisco
        targets:
          - '192.168.0.110'
#      - labels:
#          type: ubuntu
#        targets:
#          - '192.168.0.111'
    metrics_path: /snmp
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - source_labels: [type]
        target_label: __param_module
      - target_label: __address__
        replacement: '192.168.0.111:9116'

snmp.ymlはこんな感じで作ります。

snmp.yml
cisco:
  walk:
  - 1.3.6.1.2.1.2.2.1.16
  - 1.3.6.1.2.1.2.2.1.20
  - 1.3.6.1.2.1.31.1.1.1.1
  - 1.3.6.1.4.1.9.9.109.1.1.1.1.6
  metrics:
  - name: ifOutOctets
    oid: 1.3.6.1.2.1.2.2.1.16
    type: counter
    indexes:
    - labelname: ifName
      type: gauge
    lookups:
    - labels:
      - ifName
      labelname: ifName
      oid: 1.3.6.1.2.1.31.1.1.1.1
      type: DisplayString
  - name: ifOutErrors
    oid: 1.3.6.1.2.1.2.2.1.20
    type: counter
    indexes:
    - labelname: ifName
      type: gauge
    lookups:
    - labels:
      - ifName
      labelname: ifName
      oid: 1.3.6.1.2.1.31.1.1.1.1
      type: DisplayString
  - name: cpmCPUTotal5secRev
    oid: 1.3.6.1.4.1.9.9.109.1.1.1.1.6
    type: gauge
    indexes:
    - labelname: cpmCPUTotalIndex
      type: gauge
  version: 2
  auth:
    community: public

#ubuntu:
#  walk:
#  - 1.3.6.1.2.1.2.2.1.10
#  - 1.3.6.1.2.1.2.2.1.14
#  metrics:
#  - name: ifInOctets
#    oid: 1.3.6.1.2.1.2.2.1.10
#    type: counter
#    indexes:
#    - labelname: ifIndex
#      type: gauge
#  - name: ifInErrors
#    oid: 1.3.6.1.2.1.2.2.1.14
#    type: counter
#    indexes:
#    - labelname: ifIndex
#      type: gauge
#  version: 2
#  auth:
#    community: public

docker-compose up で起動します。
スクリーンショット 2019-10-24 23.08.05.png

そのうちGrafana書きますw

(2019/11/10追記)
Blackbox Expoerter で死活監視」先に書いた。

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?