forked from prometheus/snmp_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
336 lines (281 loc) · 13 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# Copyright 2018 The Prometheus Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
MIBDIR := mibs
MIB_PATH := 'mibs'
CURL_OPTS ?= -L -s --retry 3 --retry-delay 3 --fail
DOCKER_IMAGE_NAME ?= snmp-generator
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
DOCKER_REPO ?= prom
APC_URL := 'https://download.schneider-electric.com/files?p_Doc_Ref=APC_POWERNETMIB_441_EN&p_enDocType=Firmware&p_File_Name=powernet441.mib'
ARISTA_URL := https://www.arista.com/assets/data/docs/MIBS
CISCO_URL := https://raw.githubusercontent.com/cisco/cisco-mibs/main/v2
IANA_CHARSET_URL := https://www.iana.org/assignments/ianacharset-mib/ianacharset-mib
IANA_IFTYPE_URL := https://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib
IANA_PRINTER_URL := https://www.iana.org/assignments/ianaprinter-mib/ianaprinter-mib
KEEPALIVED_URL := https://raw.githubusercontent.com/acassen/keepalived/v2.2.7/doc/KEEPALIVED-MIB.txt
VRRP_URL := https://raw.githubusercontent.com/acassen/keepalived/v2.2.7/doc/VRRP-MIB.txt
VRRPV3_URL := https://raw.githubusercontent.com/acassen/keepalived/v2.2.7/doc/VRRPv3-MIB.txt
KEMP_LM_URL := https://kemptechnologies.com/files/packages/current/LM_mibs.zip
MIKROTIK_URL := 'https://box.mikrotik.com/f/a41daf63d0c14347a088/?dl=1'
NEC_URL := https://jpn.nec.com/univerge/ix/Manual/MIB
NET_SNMP_URL := https://raw.githubusercontent.com/net-snmp/net-snmp/v5.9/mibs
PALOALTO_URL := https://docs.paloaltonetworks.com/content/dam/techdocs/en_US/zip/snmp-mib/pan-10-0-snmp-mib-modules.zip
PRINTER_URL := https://ftp.pwg.org/pub/pwg/pmp/mibs/rfc3805b.mib
SERVERTECH_URL := 'https://cdn10.servertech.com/assets/documents/documents/817/original/Sentry3.mib'
SERVERTECH4_URL := 'https://cdn10.servertech.com/assets/documents/documents/815/original/Sentry4.mib'
SYNOLOGY_URL := 'https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/All/enu/Synology_MIB_File.zip'
UBNT_AIROS_URL := https://dl.ubnt.com/firmwares/airos-ubnt-mib/ubnt-mib.zip
UBNT_AIRFIBER_URL := https://dl.ubnt.com/firmwares/airfiber5X/v4.1.0/UBNT-MIB.txt
UBNT_DL_URL := https://dl.ubnt-ut.com/snmp
WIENER_URL := https://file.wiener-d.com/software/net-snmp/WIENER-CRATE-MIB-5704.zip
RARITAN_URL := https://cdn.raritan.com/download/PX/v1.5.20/PDU-MIB.txt
INFRAPOWER_URL := https://www.austin-hughes.com/wp-content/uploads/2021/05/IPD-03-S-MIB.zip
LIEBERT_URL := https://www.vertiv.com/globalassets/documents/software/monitoring/lgpmib-win_rev16_299461_0.zip
EATON_URL := https://powerquality.eaton.com/Support/Software-Drivers/Downloads/ePDU/EATON-EPDU-MIB.zip
EATON_OIDS_URL := https://raw.githubusercontent.com/librenms/librenms/master/mibs/eaton/EATON-OIDS
CYBERPOWER_VERSION := 2.10
CYBERPOWER_URL := https://dl4jz3rbrsfum.cloudfront.net/software/CyberPower_MIB_v$(CYBERPOWER_VERSION).MIB.zip
.DEFAULT: all
.PHONY: all
all: mibs
clean:
rm -rvf \
$(MIBDIR)/* \
$(MIBDIR)/.cisco_v2 \
$(MIBDIR)/.net-snmp \
$(MIBDIR)/.paloalto_panos \
$(MIBDIR)/.synology \
$(MIBDIR)/.kemp-lm
generator: *.go
go build
generate: generator mibs
MIBDIRS=$(MIB_PATH) ./generator --fail-on-parse-errors generate
parse_errors: generator mibs
MIBDIRS=$(MIB_PATH) ./generator --fail-on-parse-errors parse_errors
.PHONY: docker
docker:
docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
.PHONY: docker-generate
docker-generate: docker mibs
docker run -ti -v "${PWD}:/opt/" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" generate
.PHONY: docker-publish
docker-publish:
docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)"
.PHONY: docker-tag-latest
docker-tag-latest:
docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):latest"
.PHONY: mibs
mibs: mib-dir \
$(MIBDIR)/apc-powernet-mib \
$(MIBDIR)/AIRESPACE-REF-MIB \
$(MIBDIR)/AIRESPACE-WIRELESS-MIB \
$(MIBDIR)/ARISTA-ENTITY-SENSOR-MIB \
$(MIBDIR)/ARISTA-SMI-MIB \
$(MIBDIR)/ARISTA-SW-IP-FORWARDING-MIB \
$(MIBDIR)/ENTITY-MIB \
$(MIBDIR)/ENTITY-SENSOR-MIB \
$(MIBDIR)/ENTITY-STATE-MIB \
$(MIBDIR)/ENTITY-STATE-TC-MIB \
$(MIBDIR)/IANA-CHARSET-MIB.txt \
$(MIBDIR)/IANA-IFTYPE-MIB.txt \
$(MIBDIR)/IANA-PRINTER-MIB.txt \
$(MIBDIR)/ISDN-MIB \
$(MIBDIR)/KEEPALIVED-MIB \
$(MIBDIR)/VRRP-MIB \
$(MIBDIR)/VRRPv3-MIB \
$(MIBDIR)/.kemp-lm \
$(MIBDIR)/MIKROTIK-MIB \
$(MIBDIR)/.net-snmp \
$(MIBDIR)/.paloalto_panos \
$(MIBDIR)/PICO-IPSEC-FLOW-MONITOR-MIB.txt \
$(MIBDIR)/PICO-SMI-ID-MIB.txt \
$(MIBDIR)/PICO-SMI-MIB.txt \
$(MIBDIR)/PRINTER-MIB-V2.txt \
$(MIBDIR)/servertech-sentry3-mib \
$(MIBDIR)/servertech-sentry4-mib \
$(MIBDIR)/.synology \
$(MIBDIR)/UBNT-UniFi-MIB \
$(MIBDIR)/UBNT-AirFiber-MIB \
$(MIBDIR)/UBNT-AirMAX-MIB.txt \
$(MIBDIR)/WIENER-CRATE-MIB-5704.txt \
$(MIBDIR)/PDU-MIB.txt \
$(MIBDIR)/Infrapower-MIB.mib \
$(MIBDIR)/LIEBERT_GP_PDU.MIB \
$(MIBDIR)/EATON-EPDU-MIB.txt \
$(MIBDIR)/EATON-SENSOR-MIB.txt \
$(MIBDIR)/EATON-OIDS.txt \
$(MIBDIR)/CyberPower.MIB
mib-dir:
@mkdir -p -v $(MIBDIR)
$(MIBDIR)/apc-powernet-mib:
@echo ">> Downloading apc-powernet-mib"
@curl $(CURL_OPTS) -o $(MIBDIR)/apc-powernet-mib $(APC_URL)
$(MIBDIR)/ARISTA-ENTITY-SENSOR-MIB:
@echo ">> Downloading ARISTA-ENTITY-SENSOR-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ARISTA-ENTITY-SENSOR-MIB "$(ARISTA_URL)/ARISTA-ENTITY-SENSOR-MIB.txt"
$(MIBDIR)/ARISTA-SMI-MIB:
@echo ">> Downloading ARISTA-SMI-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ARISTA-SMI-MIB "$(ARISTA_URL)/ARISTA-SMI-MIB.txt"
$(MIBDIR)/ARISTA-SW-IP-FORWARDING-MIB:
@echo ">> Downloading ARISTA-SW-IP-FORWARDING-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ARISTA-SW-IP-FORWARDING-MIB "$(ARISTA_URL)/ARISTA-SW-IP-FORWARDING-MIB.txt"
$(MIBDIR)/AIRESPACE-REF-MIB:
@echo ">> Downloading Cisco AIRESPACE-REF-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/AIRESPACE-REF-MIB "$(CISCO_URL)/AIRESPACE-REF-MIB.my"
$(MIBDIR)/AIRESPACE-WIRELESS-MIB:
@echo ">> Downloading Cisco AIRESPACE-WIRELESS-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/AIRESPACE-WIRELESS-MIB "$(CISCO_URL)/AIRESPACE-WIRELESS-MIB.my"
$(MIBDIR)/ENTITY-MIB:
@echo ">> Downloading Cisco ENTITY-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ENTITY-MIB "$(CISCO_URL)/ENTITY-MIB.my"
$(MIBDIR)/ENTITY-SENSOR-MIB:
@echo ">> Downloading Cisco ENTITY-SENSOR-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ENTITY-SENSOR-MIB "$(CISCO_URL)/ENTITY-SENSOR-MIB.my"
$(MIBDIR)/ENTITY-STATE-MIB:
@echo ">> Downloading Cisco ENTITY-STATE-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ENTITY-STATE-MIB "$(CISCO_URL)/ENTITY-STATE-MIB.my"
$(MIBDIR)/ENTITY-STATE-TC-MIB:
@echo ">> Downloading Cisco ENTITY-STATE-TC-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ENTITY-STATE-TC-MIB "$(CISCO_URL)/ENTITY-STATE-TC-MIB.my"
$(MIBDIR)/ISDN-MIB:
@echo ">> Downloading Cisco ISDN-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/ISDN-MIB "$(CISCO_URL)/ISDN-MIB.my"
$(MIBDIR)/IANA-CHARSET-MIB.txt:
@echo ">> Downloading IANA charset MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/IANA-CHARSET-MIB.txt $(IANA_CHARSET_URL)
$(MIBDIR)/IANA-IFTYPE-MIB.txt:
@echo ">> Downloading IANA ifType MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/IANA-IFTYPE-MIB.txt $(IANA_IFTYPE_URL)
$(MIBDIR)/IANA-PRINTER-MIB.txt:
@echo ">> Downloading IANA printer MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/IANA-PRINTER-MIB.txt $(IANA_PRINTER_URL)
$(MIBDIR)/KEEPALIVED-MIB:
@echo ">> Downloading KEEPALIVED-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/KEEPALIVED-MIB $(KEEPALIVED_URL)
$(MIBDIR)/VRRP-MIB:
@echo ">> Downloading VRRP-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/VRRP-MIB $(VRRP_URL)
$(MIBDIR)/VRRPv3-MIB:
@echo ">> Downloading VRRPv3-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/VRRPv3-MIB $(VRRPV3_URL)
$(MIBDIR)/.kemp-lm:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading Kemp LM MIBs to $(TMP)"
@curl $(CURL_OPTS) -L -o $(TMP) $(KEMP_LM_URL)
@unzip -j -d $(MIBDIR) $(TMP) *.txt
# Workaround invalid timestamps.
@sed -i.bak -E 's/"([0-9]{12})[0-9]{2}Z"/"\1Z"/' $(MIBDIR)/*.RELEASE-B100-MIB.txt
@rm $(MIBDIR)/*.RELEASE-B100-MIB.txt.bak
@rm -v $(TMP)
@touch $(MIBDIR)/.kemp-lm
$(MIBDIR)/MIKROTIK-MIB:
@echo ">> Downloading MIKROTIK-MIB"
@curl $(CURL_OPTS) -L -o $(MIBDIR)/MIKROTIK-MIB $(MIKROTIK_URL)
$(MIBDIR)/.net-snmp:
@echo ">> Downloading NET-SNMP mibs"
@curl $(CURL_OPTS) -o $(MIBDIR)/HCNUM-TC $(NET_SNMP_URL)/HCNUM-TC.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/HOST-RESOURCES-MIB $(NET_SNMP_URL)/HOST-RESOURCES-MIB.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/IF-MIB $(NET_SNMP_URL)/IF-MIB.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/INET-ADDRESS-MIB $(NET_SNMP_URL)/INET-ADDRESS-MIB.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/IPV6-TC $(NET_SNMP_URL)/IPV6-TC.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/NET-SNMP-MIB $(NET_SNMP_URL)/NET-SNMP-MIB.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/NET-SNMP-TC $(NET_SNMP_URL)/NET-SNMP-TC.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/SNMP-FRAMEWORK-MIB $(NET_SNMP_URL)/SNMP-FRAMEWORK-MIB.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/SNMPv2-MIB $(NET_SNMP_URL)/SNMPv2-MIB.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/SNMPv2-SMI $(NET_SNMP_URL)/SNMPv2-SMI.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/SNMPv2-TC $(NET_SNMP_URL)/SNMPv2-TC.txt
@curl $(CURL_OPTS) -o $(MIBDIR)/UCD-SNMP-MIB $(NET_SNMP_URL)/UCD-SNMP-MIB.txt
@touch $(MIBDIR)/.net-snmp
$(MIBDIR)/PICO-IPSEC-FLOW-MONITOR-MIB.txt:
@echo ">> Downloading PICO-IPSEC-FLOW-MONITOR-MIB.txt"
@curl $(CURL_OPTS) -o $(MIBDIR)/PICO-IPSEC-FLOW-MONITOR-MIB.txt "$(NEC_URL)/PICO-IPSEC-FLOW-MONITOR-MIB.txt"
$(MIBDIR)/PICO-SMI-MIB.txt:
@echo ">> Downloading PICO-SMI-MIB.txt"
@curl $(CURL_OPTS) -o $(MIBDIR)/PICO-SMI-MIB.txt "$(NEC_URL)/PICO-SMI-MIB.txt"
$(MIBDIR)/PICO-SMI-ID-MIB.txt:
@echo ">> Downloading PICO-SMI-ID-MIB.txt"
@curl $(CURL_OPTS) -o $(MIBDIR)/PICO-SMI-ID-MIB.txt "$(NEC_URL)/PICO-SMI-ID-MIB.txt"
$(MIBDIR)/.paloalto_panos:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading paloalto_pano to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(PALOALTO_URL)
@unzip -j -d $(MIBDIR) $(TMP)
@rm -v $(TMP)
@touch $(MIBDIR)/.paloalto_panos
$(MIBDIR)/PRINTER-MIB-V2.txt:
@echo ">> Downloading Printer MIB v2"
@curl $(CURL_OPTS) -o $(MIBDIR)/PRINTER-MIB-V2.txt $(PRINTER_URL)
$(MIBDIR)/servertech-sentry3-mib:
@echo ">> Downloading servertech-sentry3-mib"
@curl $(CURL_OPTS) -o $(MIBDIR)/servertech-sentry3-mib $(SERVERTECH_URL)
$(MIBDIR)/servertech-sentry4-mib:
@echo ">> Downloading servertech-sentry4-mib"
@curl $(CURL_OPTS) -o $(MIBDIR)/servertech-sentry4-mib $(SERVERTECH4_URL)
$(MIBDIR)/.synology:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading synology to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(SYNOLOGY_URL)
@unzip -j -d $(MIBDIR) $(TMP)
@rm -v $(TMP)
@touch $(MIBDIR)/.synology
$(MIBDIR)/UBNT-UniFi-MIB:
@echo ">> Downloading UBNT-UniFi-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/UBNT-UniFi-MIB "$(UBNT_DL_URL)/UBNT-UniFi-MIB"
$(MIBDIR)/UBNT-AirFiber-MIB:
@echo ">> Downloading UBNT-AirFiber-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/UBNT-AirFiber-MIB $(UBNT_AIRFIBER_URL)
$(MIBDIR)/UBNT-AirMAX-MIB.txt:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading ubnt-airos to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(UBNT_AIROS_URL)
@unzip -j -d $(MIBDIR) $(TMP) UBNT-AirMAX-MIB.txt
@rm -v $(TMP)
$(MIBDIR)/WIENER-CRATE-MIB-5704.txt:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading WIENER-CRATE-MIB to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(WIENER_URL)
@unzip -j -d $(MIBDIR) $(TMP)
@rm -v $(TMP)
$(MIBDIR)/PDU-MIB.txt:
@echo ">> Downloading PDU-MIB"
@curl $(CURL_OPTS) -o $(MIBDIR)/PDU-MIB.txt "$(RARITAN_URL)"
$(MIBDIR)/Infrapower-MIB.mib:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading Infrapower-MIB.mib to $(TMP)"
@rm -vf $(MIBDIR)/IPD-MIB_Q419V9.mib
@curl $(CURL_OPTS) -L -o $(TMP) $(INFRAPOWER_URL)
@unzip -j -d $(MIBDIR) $(TMP) IPD-03-S-MIB_Q320V1.mib
@mv -v $(MIBDIR)/IPD-03-S-MIB_Q320V1.mib $(MIBDIR)/Infrapower-MIB.mib
@rm -v $(TMP)
$(MIBDIR)/LIEBERT_GP_PDU.MIB:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading LIEBERT_GP_PDU.MIB to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(LIEBERT_URL)
@unzip -j -d $(MIBDIR) $(TMP) LIEBERT_GP_PDU.MIB LIEBERT_GP_REG.MIB
@rm -v $(TMP)
$(MIBDIR)/EATON-EPDU-MIB.txt $(MIBDIR)/EATON-SENSOR-MIB.txt:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading EATON-EPDU-MIB.txt to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(EATON_URL)
@unzip -j -d $(MIBDIR) $(TMP) EATON-EPDU-MIB.txt EATON-SENSOR-MIB.txt
@rm -v $(TMP)
$(MIBDIR)/EATON-OIDS.txt:
@echo ">> Downloading EATON-OIDS.txt to $@"
@curl $(CURL_OPTS) -o $@ $(EATON_OIDS_URL)
$(MIBDIR)/CyberPower.MIB:
$(eval TMP := $(shell mktemp))
@echo ">> Downloading CyberPower.MIB to $(TMP)"
@curl $(CURL_OPTS) -o $(TMP) $(CYBERPOWER_URL)
@unzip -j -d $(MIBDIR) $(TMP) CyberPower_MIB_v$(CYBERPOWER_VERSION).MIB
@mv -v $(MIBDIR)/CyberPower_MIB_v$(CYBERPOWER_VERSION).MIB $@
@rm -v $(TMP)