Use Prometheus monitoring snmp

Snmp get information

First, get the basic information needed to monitor snmp, assuming the basic information is as follows:

snmp服务IP: 1.1.1.1
snmp community: public
snmp exportor部署地址: 2.2.2.2

Configuration snmp exporter

From the official download snmp exporter executable file.

It also needs its own compiler to generate snmp exporter configuration file, you first need to configure generator.yml file, and then follow the Building and Running steps compiled snmp.yml. generator.yml configuration file can refer to File the Format . generator.yml file only needs to inject snmp community, the following only modify the modules.if_mib.auth field, the rest of the File Format is consistent in.

modules:
  # Default IF-MIB interfaces table with ifIndex.
  if_mib:
    walk: [sysUpTime, interfaces, ifXTable]
    version: 2
    auth:
      community: public
    lookups:
      - source_indexes: [ifIndex]
        lookup: ifAlias
      - source_indexes: [ifIndex]
        lookup: ifDescr
      - source_indexes: [ifIndex]
        # Use OID to avoid conflict with Netscaler NS-ROOT-MIB.
        lookup: 1.3.6.1.2.1.31.1.1.1.1 # ifName
        ...

Snmp.yml to replace the original after generating new snmp.yml.

Configuration Prometheus

Prometheus following minimum configuration, the job can increase a snmp, params.module configuration module may need to be captured is not arranged to represent all crawl.

global:
  scrape_interval: 1m
  scrape_timeout: 60s
  evaluation_interval: 20s
scrape_configs:
  - job_name: 'snmp'
    static_configs:
      - targets:
        - 1.1.1.1
    metrics_path: /snmp
#    params:
#      module: [if_mib]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 2.2.2.2:9116

And Prometheus can start snmp exporter

grafana Configuration

snmp snmp given node where the service (typically switches) interface information, such as interface status, name, In / Out number of packets, number of packets dropped packets and the number of error packets and the like. Simple configuration is given below:

Calculate the total number of packets received

sum(ifInBroadcastPkts+ifInMulticastPkts+ifInUcastPkts)by(ifDescr)

Calculate the average total number of packets received over 2 minutes

sum(rate(ifInBroadcastPkts[2m])+rate(ifInMulticastPkts[2m])+rate(ifInUcastPkts[2m]))by(ifDescr)

The total number of packets sent computing

sum(ifOutBroadcastPkts+ifOutMulticastPkts+ifOutUcastPkts)by(ifDescr)

Calculate the average total number of packets transmitted over 2 minutes

sum(rate(ifOutBroadcastPkts[2m])+rate(ifOutMulticastPkts[2m])+rate(ifOutUcastPkts[2m]))by(ifDescr)

Calculated on the total number of messages that do not send

sum(ifInDiscards+ifInErrors+ifInUnknownProtos)by(ifDescr)

Calculate the average total number of packets not sent to the 2 minutes

sum(rate(ifInDiscards[2m])+rate(ifInErrors[2m])+rate(ifInUnknownProtos[2m]))by(ifDescr)

Calculate the total number of discarded packets

sum(ifOutDiscards+ifOutErrors)by(ifDescr)

Calculating the average total number of packets dropped over 2 minutes

sum(rate(ifOutDiscards[2m])+rate(ifOutErrors[2m]))by(ifDescr)

Guess you like

Origin www.cnblogs.com/charlieroro/p/11118671.html