SNMP Exporter 快速入门
Prometheus exporter for SNMP metrics.
https://github.com/prometheus/snmp_exporter
一、部署 snmp_exporter
下载 snmp_exporter
https://github.com/prometheus/snmp_exporter/releases
解压并安装:
cd /usr/local/src && tar -zxvf memcached_exporter-0.11.2.linux-amd64.tar.gz;
mv memcached_exporter-0.11.2.linux-amd64 /usr/local/memcached_exporter;
cd /usr/local/memcached_exporter;
查看使用帮助:
[root@192 memcached_exporter]# ./memcached_exporter -h
usage: memcached_exporter [<flags>]
Flags:
-h, --[no-]help Show context-sensitive help (also try --help-long and --help-man).
--memcached.address="localhost:11211"
Memcached server address.
--memcached.timeout=1s memcached connect timeout.
--memcached.pid-file="" Optional path to a file containing the memcached PID for additional metrics.
--[no-]memcached.tls.enable
Enable TLS connections to memcached
--memcached.tls.cert-file=""
Client certificate file.
--memcached.tls.key-file=""
Client private key file.
--memcached.tls.ca-file=""
Client root CA file.
--[no-]memcached.tls.insecure-skip-verify
Skip server certificate verification
--memcached.tls.server-name=""
Memcached TLS certificate servername
--[no-]web.systemd-socket Use systemd socket activation listeners instead of port listeners (Linux only).
--web.listen-address=:9150 ...
Addresses on which to expose metrics and web interface. Repeatable for multiple addresses.
--web.config.file="" [EXPERIMENTAL] Path to configuration file that can enable TLS or authentication.
--web.telemetry-path="/metrics"
Path under which to expose metrics.
--log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error]
--log.format=logfmt Output format of log messages. One of: [logfmt, json]
--[no-]version Show application version.
默认情况下,memcache_exporter 在以下端口提供 0.0.0.0:9150
服务/metrics
:
./memcached_exporter
或者提供一个 Dockerfile:
docker run -p 9150:9150 quay.io/prometheus/memcached-exporter:latest
访问监控度量信息地址:
使用 systemd方式启动
# cat >/usr/lib/systemd/system/memcached_exporter.service <<EOF
[Unit]
Description=Prometheus exporter for MySQL server metrics.
Documentation=https://github.com/prometheus/memcached_exporter
After=network.target
[Service]
ExecStart=/usr/local/memcached_exporter/memcached_exporter --memcached.address=localhost:11211 --web.listen-address=:9150
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# systemctl enable memcached_exporter
# systemctl restart memcached_exporter
# systemctl status memcached_exporter
设置随机启动:
[root@local ~]# systemctl daemon-reload
[root@local ~]# systemctl disable memcached_exporter.service
[root@local ~]# systemctl enable memcached_exporter.service
[root@local ~]# systemctl start memcached_exporter.service
[root@local ~]# systemctl status memcached_exporter.service
[root@local ~]# systemctl stop memcached_exporter.service
[root@local ~]# systemctl restart memcached_exporter.service
二、在 prometheus.yaml 中添加 memcached_exporter 的配置
在 Prometheus 配置文件里,您可以按如下方式设置抓取配置
scrape_configs:
- job_name: 'snmp'
static_configs:
- targets:
- 192.168.1.2 # SNMP device.
- switch.local # SNMP device.
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: 127.0.0.1:9116 # The SNMP exporter's real hostname:port.
作者:Jeebiz 创建时间:2023-03-12 22:29
最后编辑:Jeebiz 更新时间:2024-01-24 21:48
最后编辑:Jeebiz 更新时间:2024-01-24 21:48