설정 파일 위치는 설치자에 따라 다를 겁니다.

제가 설치한 방법을 따라 하셨다면 아래의 경로에 해당 파일이 존재 합니다.

"/opt/snmp_exporter/snmp.yml" 

 

워낙 방대해서 기본 설정이외 수정한 부분을 표시합니다.

필요한 부분은 snmp community string의 설정입니다.

if_mib:
  auth:
    community: <snmp string을 기재> # "<", ">" 표시는 삭제해야 합니다.
  walk:
  - 1.3.6.1.2.1.2
  - 1.3.6.1.2.1.31.1.1
  get:
  - 1.3.6.1.2.1.1.3.0
  metrics:
  - name: sysUpTime
    oid: 1.3.6.1.2.1.1.3
    type: gauge
    help: The time (in hundredths of a second) since the network management portion
      of the system was last re-initialized. - 1.3.6.1.2.1.1.3
      .
      .
      .
      .
      .
      .
      .
      .
 --- 이하 생략 ---

'기술 노트 > snmp_exporter' 카테고리의 다른 글

snmp_exporter 설치 및 실행  (0) 2023.03.22

snmp_exporter 다운로드

https://github.com/prometheus/snmp_exporter/releases/tag/v0.21.0

 

snmp_exporter 설치

[root@tmplogsvr ~]# cd /opt
[root@tmplogsvr opt]# wget https://github.com/prometheus/snmp_exporter/releases/download/v0.21.0/snmp_exporter-0.21.0.linux-amd64.tar.gz
--2023-03-22 14:14:01--  https://github.com/prometheus/snmp_exporter/releases/download/v0.21.0/snmp_exporter-0.21.0.linux-amd64.tar.gz
Resolving github.com (github.com)... 20.200.245.247
Connecting to github.com (github.com)|20.200.245.247|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/31185891/35d0421a-cf03-4349-ae63-426c22348a41?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230322%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230322T051348Z&X-Amz-Expires=300&X-Amz-Signature=4a0ef1b1d88523c258386ec4bc5645e9e8114053243b06e8cfd218ce1895d008&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=31185891&response-content-disposition=attachment%3B%20filename%3Dsnmp_exporter-0.21.0.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2023-03-22 14:14:01--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/31185891/35d0421a-cf03-4349-ae63-426c22348a41?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230322%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230322T051348Z&X-Amz-Expires=300&X-Amz-Signature=4a0ef1b1d88523c258386ec4bc5645e9e8114053243b06e8cfd218ce1895d008&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=31185891&response-content-disposition=attachment%3B%20filename%3Dsnmp_exporter-0.21.0.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8468035 (8.1M) [application/octet-stream]
Saving to: ‘snmp_exporter-0.21.0.linux-amd64.tar.gz’

snmp_exporter-0.21.0.linux-amd64.tar.gz           100%[===========================================================================================================>]   8.08M  43.5MB/s    in 0.2s

2023-03-22 14:14:02 (43.5 MB/s) - ‘snmp_exporter-0.21.0.linux-amd64.tar.gz’ saved [8468035/8468035]

[root@tmplogsvr opt]# tar zxvf ./snmp_exporter-0.21.0.linux-amd64.tar.gz
[root@tmplogsvr opt]# rm -rf ./snmp_exporter-0.21.0.linux-amd64.tar.gz
[root@tmplogsvr opt]# mv ./snmp_exporter-0.21.0.linux-amd64 ./snmp_exporter
[root@tmplogsvr opt]# ln -s /opt/snmp_exporter/snmp_exporter /usr/local/bin/snmp_exporter
[root@tmplogsvr opt]# useradd --system snmp_exporter
[root@tmplogsvr opt]# echo '
[Unit]
Description=Prometheus SNMP Exporter Service
After=network.target

[Service]
Type=simple
User=snmp_exporter
ExecStart=/usr/local/bin/snmp_exporter --config.file="/opt/snmp_exporter/snmp.yml"

[Install]
WantedBy=multi-user.target' > /etc/systemd/system/snmp-exporter.service
[root@tmplogsvr opt]# systemctl daemon-reload
[root@tmplogsvr opt]# systemctl enable snmp-exporter.service

 

snmp_export 실행

[root@tmplogsvr opt]# systemctl start snmp-exporter.service
[root@tmplogsvr opt]# systemctl status snmp-exporter.service
● snmp-exporter.service - Prometheus SNMP Exporter Service
   Loaded: loaded (/etc/systemd/system/snmp-exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-03-22 14:33:22 KST; 5s ago
 Main PID: 241313 (snmp_exporter)
    Tasks: 10 (limit: 99645)
   Memory: 30.7M
   CGroup: /system.slice/snmp-exporter.service
           └─241313 /usr/local/bin/snmp_exporter --config.file=/opt/snmp_exporter/snmp.yml

 3월 22 14:33:22 tmplogsvr systemd[1]: Started Prometheus SNMP Exporter Service.
 3월 22 14:33:22 tmplogsvr snmp_exporter[241313]: ts=2023-03-22T05:33:22.219Z caller=main.go:148 level=info msg="Starting snmp_exporter" version="(version=0.21.0, branch=HEAD, revision=0d8c3527cac0>
 3월 22 14:33:22 tmplogsvr snmp_exporter[241313]: ts=2023-03-22T05:33:22.219Z caller=main.go:149 level=info build_context="(go=go1.19.3, user=root@51dfd4b1f59b, date=20221122-15:14:18)"
 3월 22 14:33:22 tmplogsvr snmp_exporter[241313]: ts=2023-03-22T05:33:22.299Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9116
 3월 22 14:33:22 tmplogsvr snmp_exporter[241313]: ts=2023-03-22T05:33:22.299Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9116
 3월 22 14:33:24 tmplogsvr snmp_exporter[241313]: ts=2023-03-22T05:33:24.370Z caller=collector.go:282 level=info module=if_mib target=192.168.10.2 msg="Error scraping target" err="error getting tar>
lines 1-15/15 (END)

'기술 노트 > snmp_exporter' 카테고리의 다른 글

snmp_exporter 설정  (0) 2023.04.04

+ Recent posts