cd ~
wget https://golang.google.cn/dl/go1.15.4.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.15.4.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
go version
go env -w goproxy=https://goproxy.io,direct
cd /sas/prometheus/
wget https://github.com/prometheus/snmp_exporter/releases/download/v0.19.0/snmp_exporter-0.19.0.linux-amd64.tar.gz

tar -xzvf snmp_exporter-0.19.0.linux-amd64.tar.gz
mv snmp_exporter-0.19.0.linux-amd64 snmp_exporter
vi /usr/lib/systemd/system/snmp_exporter.service

[Unit]
Description=Prometheus SNMP Exporter Services
After=network.target 

[Service]
Type=simpleExecStart=/sas/prometheus/snmp_exporter/snmp_exporter --config.file=/sas/prometheus/snmp_exporter/snmp.yml
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl start snmp_exporter.service
systemctl enable snmp_exporter.service
yum install -y gcc gcc-g++ make net-snmp net-snmp-utils net-snmp-libs net-snmp-devel
yum install -y unzip
go get -v github.com/prometheus/snmp_exporter/generator
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator
go build

# 安装下载mib需要用到的解压缩软件
yum install -y unzip p7zip
ln -s /usr/bin/7za /usr/bin/7z

vi Makefile
# CURL_OPTS ?= -s --retry 3 --retry-delay 3 --compressed --location --fail
CURL_OPTS ?= -k -s --retry 3 --retry-delay 3 --compressed --location --fail

make mibs

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给好友。