当前位置:   article > 正文

snmp_exporter监控交换机网络流量_snmp exporter

snmp exporter

一.背景与需求

    最近收到机房账单多出了将近70M下行带宽,多交了8K多的费用,很是蛋疼。IDC机房使用每月保底带宽模式, 例如保底100M带宽/月,如果利用955计费方式,没超出100M则只收机柜和保底带宽的费用,如果超出1M则按照额外进行收费。  这里比较蛋疼的是,上行和下行带宽默认不做限制,最高可以跑到1G。。。,之前没做好交换机流量监控,导致没能及时发现问题。Zabbix可以根据交换机开启的snmp服务,采集到交换机各个口的流量指标,但是由于现在已经全面转向Prometheus体系,所以只能通过一些方法将这个监控接入Prometheus。

   简单网络管理协议(Simple Network Management Protocol, SNMP)原名叫做简单网关监控协议(Simple Gateway Monitoring Protocol, SGMP)。最早是IETF的研究小组提出来的,在SGMP协议的基础之上,加上新的管理信息结构和管理信息库,让SGMP更加全面。简单性和扩展性是SNMP所体现出来的,其中包含数据库类型(Database Schema),一个应用层协议(Application Layer Protocol)和一些资料文件。SNMP管理协议不光能够加强网络管理系统的效能,而且还可以用来对网络中的资源进行管理和实时监控。

二.snmp_exporter

    正好官方prometheus项目就提供了这个关于snmp的exporter,按照对接方式将snmp指标采集即可。

   运行命令测试snmp是否正常(默认community是public, 但是如果改过了记得改,要不然测试不通):

snmpwalk -v2c -c my_community 10.23.0.253 1.3.6.1.2.1.31.1.1

    返回获取到交换机端口列表则表示正常。

    snmp_exporter独立运行,并且要加载一个snmp.yml配置文件。 snmp.yml配置文件内容就是包含如下(默认指标):

  1. # WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
  2. if_mib:
  3. version: 2
  4. auth:
  5. community: my_community #这个要根据情况定,默认是public,但是如果已经自定义,则填入自定义的community
  6. walk:
  7. - 1.3.6.1.2.1.2
  8. - 1.3.6.1.2.1.31.1.1
  9. get:
  10. - 1.3.6.1.2.1.1.1.0
  11. - 1.3.6.1.2.1.1.3.0
  12. - 1.3.6.1.2.1.1.5.0
  13. metrics:
  14. - name: sysDescr
  15. oid: 1.3.6.1.2.1.1.1
  16. type: DisplayString
  17. help: A textual description of the entity - 1.3.6.1.2.1.1.1
  18. - name: sysUpTime
  19. oid: 1.3.6.1.2.1.1.3
  20. type: gauge
  21. help: The time (in hundredths of a second) since the network management portion
  22. of the system was last re-initialized. - 1.3.6.1.2.1.1.3
  23. - name: sysName
  24. oid: 1.3.6.1.2.1.1.5
  25. type: DisplayString
  26. help: An administratively-assigned name for this managed node - 1.3.6.1.2.1.1.5
  27. - name: ifNumber
  28. oid: 1.3.6.1.2.1.2.1
  29. type: gauge
  30. help: The number of network interfaces (regardless of their current state) present
  31. on this system. - 1.3.6.1.2.1.2.1
  32. - name: ifIndex
  33. oid: 1.3.6.1.2.1.2.2.1.1
  34. type: gauge
  35. help: A unique value for each interface - 1.3.6.1.2.1.2.2.1.1
  36. indexes:
  37. - labelname: ifIndex
  38. type: gauge
  39. lookups:
  40. - labels:
  41. - ifIndex
  42. labelname: ifAlias
  43. oid: 1.3.6.1.2.1.31.1.1.1.18
  44. type: DisplayString
  45. - labels:
  46. - ifIndex
  47. labelname: ifDescr
  48. oid: 1.3.6.1.2.1.2.2.1.2
  49. type: DisplayString
  50. - labels:
  51. - ifIndex
  52. labelname: ifName
  53. oid: 1.3.6.1.2.1.31.1.1.1.1
  54. type: DisplayString
  55. - name: ifType
  56. oid: 1.3.6.1.2.1.2.2.1.3
  57. type: EnumAsInfo
  58. help: The type of interface, distinguished according to the physical/link protocol(s)
  59. immediately `below' the network layer in the protocol stack. - 1.3.6.1.2.1.2.2.1.3
  60. indexes:
  61. - labelname: ifIndex
  62. type: gauge
  63. lookups:
  64. - labels:
  65. - ifIndex
  66. labelname: ifAlias
  67. oid: 1.3.6.1.2.1.31.1.1.1.18
  68. type: DisplayString
  69. - labels:
  70. - ifIndex
  71. labelname: ifDescr
  72. oid: 1.3.6.1.2.1.2.2.1.2
  73. type: DisplayString
  74. - labels:
  75. - ifIndex
  76. labelname: ifName
  77. oid: 1.3.6.1.2.1.31.1.1.1.1
  78. type: DisplayString
  79. enum_values:
  80. 1: other
  81. 2: regular1822
  82. 3: hdh1822
  83. 4: ddn-x25
  84. 5: rfc877-x25
  85. 6: ethernet-csmacd
  86. 7: iso88023-csmacd
  87. 8: iso88024-tokenBus
  88. 9: iso88025-tokenRing
  89. 10: iso88026-man
  90. 11: starLan
  91. 12: proteon-10Mbit
  92. 13: proteon-80Mbit
  93. 14: hyperchannel
  94. 15: fddi
  95. 16: lapb
  96. 17: sdlc
  97. 18: ds1
  98. 19: e1
  99. 20: basicISDN
  100. 21: primaryISDN
  101. 22: propPointToPointSerial
  102. 23: ppp
  103. 24: softwareLoopback
  104. 25: eon
  105. 26: ethernet-3Mbit
  106. 27: nsip
  107. 28: slip
  108. 29: ultra
  109. 30: ds3
  110. 31: sip
  111. 32: frame-relay
  112. - name: ifMtu
  113. oid: 1.3.6.1.2.1.2.2.1.4
  114. type: gauge
  115. help: The size of the largest datagram which can be sent/received on the interface,
  116. specified in octets - 1.3.6.1.2.1.2.2.1.4
  117. indexes:
  118. - labelname: ifIndex
  119. type: gauge
  120. lookups:
  121. - labels:
  122. - ifIndex
  123. labelname: ifAlias
  124. oid: 1.3.6.1.2.1.31.1.1.1.18
  125. type: DisplayString
  126. - labels:
  127. - ifIndex
  128. labelname: ifDescr
  129. oid: 1.3.6.1.2.1.2.2.1.2
  130. type: DisplayString
  131. - labels:
  132. - ifIndex
  133. labelname: ifName
  134. oid: 1.3.6.1.2.1.31.1.1.1.1
  135. type: DisplayString
  136. - name: ifSpeed
  137. oid: 1.3.6.1.2.1.2.2.1.5
  138. type: gauge
  139. help: An estimate of the interface's current bandwidth in bits per second - 1.3.6.1.2.1.2.2.1.5
  140. indexes:
  141. - labelname: ifIndex
  142. type: gauge
  143. lookups:
  144. - labels:
  145. - ifIndex
  146. labelname: ifAlias
  147. oid: 1.3.6.1.2.1.31.1.1.1.18
  148. type: DisplayString
  149. - labels:
  150. - ifIndex
  151. labelname: ifDescr
  152. oid: 1.3.6.1.2.1.2.2.1.2
  153. type: DisplayString
  154. - labels:
  155. - ifIndex
  156. labelname: ifName
  157. oid: 1.3.6.1.2.1.31.1.1.1.1
  158. type: DisplayString
  159. - name: ifPhysAddress
  160. oid: 1.3.6.1.2.1.2.2.1.6
  161. type: PhysAddress48
  162. help: The interface's address at the protocol layer immediately `below' the network
  163. layer in the protocol stack - 1.3.6.1.2.1.2.2.1.6
  164. indexes:
  165. - labelname: ifIndex
  166. type: gauge
  167. lookups:
  168. - labels:
  169. - ifIndex
  170. labelname: ifAlias
  171. oid: 1.3.6.1.2.1.31.1.1.1.18
  172. type: DisplayString
  173. - labels:
  174. - ifIndex
  175. labelname: ifDescr
  176. oid: 1.3.6.1.2.1.2.2.1.2
  177. type: DisplayString
  178. - labels:
  179. - ifIndex
  180. labelname: ifName
  181. oid: 1.3.6.1.2.1.31.1.1.1.1
  182. type: DisplayString
  183. - name: ifAdminStatus
  184. oid: 1.3.6.1.2.1.2.2.1.7
  185. type: gauge
  186. help: The desired state of the interface - 1.3.6.1.2.1.2.2.1.7
  187. indexes:
  188. - labelname: ifIndex
  189. type: gauge
  190. lookups:
  191. - labels:
  192. - ifIndex
  193. labelname: ifAlias
  194. oid: 1.3.6.1.2.1.31.1.1.1.18
  195. type: DisplayString
  196. - labels:
  197. - ifIndex
  198. labelname: ifDescr
  199. oid: 1.3.6.1.2.1.2.2.1.2
  200. type: DisplayString
  201. - labels:
  202. - ifIndex
  203. labelname: ifName
  204. oid: 1.3.6.1.2.1.31.1.1.1.1
  205. type: DisplayString
  206. enum_values:
  207. 1: up
  208. 2: down
  209. 3: testing
  210. - name: ifOperStatus
  211. oid: 1.3.6.1.2.1.2.2.1.8
  212. type: gauge
  213. help: The current operational state of the interface - 1.3.6.1.2.1.2.2.1.8
  214. indexes:
  215. - labelname: ifIndex
  216. type: gauge
  217. lookups:
  218. - labels:
  219. - ifIndex
  220. labelname: ifAlias
  221. oid: 1.3.6.1.2.1.31.1.1.1.18
  222. type: DisplayString
  223. - labels:
  224. - ifIndex
  225. labelname: ifDescr
  226. oid: 1.3.6.1.2.1.2.2.1.2
  227. type: DisplayString
  228. - labels:
  229. - ifIndex
  230. labelname: ifName
  231. oid: 1.3.6.1.2.1.31.1.1.1.1
  232. type: DisplayString
  233. enum_values:
  234. 1: up
  235. 2: down
  236. 3: testing
  237. - name: ifLastChange
  238. oid: 1.3.6.1.2.1.2.2.1.9
  239. type: gauge
  240. help: The value of sysUpTime at the time the interface entered its current operational
  241. state - 1.3.6.1.2.1.2.2.1.9
  242. indexes:
  243. - labelname: ifIndex
  244. type: gauge
  245. lookups:
  246. - labels:
  247. - ifIndex
  248. labelname: ifAlias
  249. oid: 1.3.6.1.2.1.31.1.1.1.18
  250. type: DisplayString
  251. - labels:
  252. - ifIndex
  253. labelname: ifDescr
  254. oid: 1.3.6.1.2.1.2.2.1.2
  255. type: DisplayString
  256. - labels:
  257. - ifIndex
  258. labelname: ifName
  259. oid: 1.3.6.1.2.1.31.1.1.1.1
  260. type: DisplayString
  261. - name: ifInOctets
  262. oid: 1.3.6.1.2.1.2.2.1.10
  263. type: counter
  264. help: The total number of octets received on the interface, including framing
  265. characters. - 1.3.6.1.2.1.2.2.1.10
  266. indexes:
  267. - labelname: ifIndex
  268. type: gauge
  269. lookups:
  270. - labels:
  271. - ifIndex
  272. labelname: ifAlias
  273. oid: 1.3.6.1.2.1.31.1.1.1.18
  274. type: DisplayString
  275. - labels:
  276. - ifIndex
  277. labelname: ifDescr
  278. oid: 1.3.6.1.2.1.2.2.1.2
  279. type: DisplayString
  280. - labels:
  281. - ifIndex
  282. labelname: ifName
  283. oid: 1.3.6.1.2.1.31.1.1.1.1
  284. type: DisplayString
  285. - name: ifInUcastPkts
  286. oid: 1.3.6.1.2.1.2.2.1.11
  287. type: counter
  288. help: The number of subnetwork-unicast packets delivered to a higher-layer protocol.
  289. - 1.3.6.1.2.1.2.2.1.11
  290. indexes:
  291. - labelname: ifIndex
  292. type: gauge
  293. lookups:
  294. - labels:
  295. - ifIndex
  296. labelname: ifAlias
  297. oid: 1.3.6.1.2.1.31.1.1.1.18
  298. type: DisplayString
  299. - labels:
  300. - ifIndex
  301. labelname: ifDescr
  302. oid: 1.3.6.1.2.1.2.2.1.2
  303. type: DisplayString
  304. - labels:
  305. - ifIndex
  306. labelname: ifName
  307. oid: 1.3.6.1.2.1.31.1.1.1.1
  308. type: DisplayString
  309. - name: ifInNUcastPkts
  310. oid: 1.3.6.1.2.1.2.2.1.12
  311. type: counter
  312. help: The number of non-unicast (i.e., subnetwork- broadcast or subnetwork-multicast)
  313. packets delivered to a higher-layer protocol. - 1.3.6.1.2.1.2.2.1.12
  314. indexes:
  315. - labelname: ifIndex
  316. type: gauge
  317. lookups:
  318. - labels:
  319. - ifIndex
  320. labelname: ifAlias
  321. oid: 1.3.6.1.2.1.31.1.1.1.18
  322. type: DisplayString
  323. - labels:
  324. - ifIndex
  325. labelname: ifDescr
  326. oid: 1.3.6.1.2.1.2.2.1.2
  327. type: DisplayString
  328. - labels:
  329. - ifIndex
  330. labelname: ifName
  331. oid: 1.3.6.1.2.1.31.1.1.1.1
  332. type: DisplayString
  333. - name: ifInDiscards
  334. oid: 1.3.6.1.2.1.2.2.1.13
  335. type: counter
  336. help: The number of inbound packets which were chosen to be discarded even though
  337. no errors had been detected to prevent their being deliverable to a higher-layer
  338. protocol - 1.3.6.1.2.1.2.2.1.13
  339. indexes:
  340. - labelname: ifIndex
  341. type: gauge
  342. lookups:
  343. - labels:
  344. - ifIndex
  345. labelname: ifAlias
  346. oid: 1.3.6.1.2.1.31.1.1.1.18
  347. type: DisplayString
  348. - labels:
  349. - ifIndex
  350. labelname: ifDescr
  351. oid: 1.3.6.1.2.1.2.2.1.2
  352. type: DisplayString
  353. - labels:
  354. - ifIndex
  355. labelname: ifName
  356. oid: 1.3.6.1.2.1.31.1.1.1.1
  357. type: DisplayString
  358. - name: ifInErrors
  359. oid: 1.3.6.1.2.1.2.2.1.14
  360. type: counter
  361. help: The number of inbound packets that contained errors preventing them from
  362. being deliverable to a higher-layer protocol. - 1.3.6.1.2.1.2.2.1.14
  363. indexes:
  364. - labelname: ifIndex
  365. type: gauge
  366. lookups:
  367. - labels:
  368. - ifIndex
  369. labelname: ifAlias
  370. oid: 1.3.6.1.2.1.31.1.1.1.18
  371. type: DisplayString
  372. - labels:
  373. - ifIndex
  374. labelname: ifDescr
  375. oid: 1.3.6.1.2.1.2.2.1.2
  376. type: DisplayString
  377. - labels:
  378. - ifIndex
  379. labelname: ifName
  380. oid: 1.3.6.1.2.1.31.1.1.1.1
  381. type: DisplayString
  382. - name: ifInUnknownProtos
  383. oid: 1.3.6.1.2.1.2.2.1.15
  384. type: counter
  385. help: The number of packets received via the interface which were discarded because
  386. of an unknown or unsupported protocol. - 1.3.6.1.2.1.2.2.1.15
  387. indexes:
  388. - labelname: ifIndex
  389. type: gauge
  390. lookups:
  391. - labels:
  392. - ifIndex
  393. labelname: ifAlias
  394. oid: 1.3.6.1.2.1.31.1.1.1.18
  395. type: DisplayString
  396. - labels:
  397. - ifIndex
  398. labelname: ifDescr
  399. oid: 1.3.6.1.2.1.2.2.1.2
  400. type: DisplayString
  401. - labels:
  402. - ifIndex
  403. labelname: ifName
  404. oid: 1.3.6.1.2.1.31.1.1.1.1
  405. type: DisplayString
  406. - name: ifOutOctets
  407. oid: 1.3.6.1.2.1.2.2.1.16
  408. type: counter
  409. help: The total number of octets transmitted out of the interface, including framing
  410. characters. - 1.3.6.1.2.1.2.2.1.16
  411. indexes:
  412. - labelname: ifIndex
  413. type: gauge
  414. lookups:
  415. - labels:
  416. - ifIndex
  417. labelname: ifAlias
  418. oid: 1.3.6.1.2.1.31.1.1.1.18
  419. type: DisplayString
  420. - labels:
  421. - ifIndex
  422. labelname: ifDescr
  423. oid: 1.3.6.1.2.1.2.2.1.2
  424. type: DisplayString
  425. - labels:
  426. - ifIndex
  427. labelname: ifName
  428. oid: 1.3.6.1.2.1.31.1.1.1.1
  429. type: DisplayString
  430. - name: ifOutUcastPkts
  431. oid: 1.3.6.1.2.1.2.2.1.17
  432. type: counter
  433. help: The total number of packets that higher-level protocols requested be transmitted
  434. to a subnetwork-unicast address, including those that were discarded or not
  435. sent. - 1.3.6.1.2.1.2.2.1.17
  436. indexes:
  437. - labelname: ifIndex
  438. type: gauge
  439. lookups:
  440. - labels:
  441. - ifIndex
  442. labelname: ifAlias
  443. oid: 1.3.6.1.2.1.31.1.1.1.18
  444. type: DisplayString
  445. - labels:
  446. - ifIndex
  447. labelname: ifDescr
  448. oid: 1.3.6.1.2.1.2.2.1.2
  449. type: DisplayString
  450. - labels:
  451. - ifIndex
  452. labelname: ifName
  453. oid: 1.3.6.1.2.1.31.1.1.1.1
  454. type: DisplayString
  455. - name: ifOutNUcastPkts
  456. oid: 1.3.6.1.2.1.2.2.1.18
  457. type: counter
  458. help: The total number of packets that higher-level protocols requested be transmitted
  459. to a non- unicast (i.e., a subnetwork-broadcast or subnetwork-multicast) address,
  460. including those that were discarded or not sent. - 1.3.6.1.2.1.2.2.1.18
  461. indexes:
  462. - labelname: ifIndex
  463. type: gauge
  464. lookups:
  465. - labels:
  466. - ifIndex
  467. labelname: ifAlias
  468. oid: 1.3.6.1.2.1.31.1.1.1.18
  469. type: DisplayString
  470. - labels:
  471. - ifIndex
  472. labelname: ifDescr
  473. oid: 1.3.6.1.2.1.2.2.1.2
  474. type: DisplayString
  475. - labels:
  476. - ifIndex
  477. labelname: ifName
  478. oid: 1.3.6.1.2.1.31.1.1.1.1
  479. type: DisplayString
  480. - name: ifOutDiscards
  481. oid: 1.3.6.1.2.1.2.2.1.19
  482. type: counter
  483. help: The number of outbound packets which were chosen to be discarded even though
  484. no errors had been detected to prevent their being transmitted - 1.3.6.1.2.1.2.2.1.19
  485. indexes:
  486. - labelname: ifIndex
  487. type: gauge
  488. lookups:
  489. - labels:
  490. - ifIndex
  491. labelname: ifAlias
  492. oid: 1.3.6.1.2.1.31.1.1.1.18
  493. type: DisplayString
  494. - labels:
  495. - ifIndex
  496. labelname: ifDescr
  497. oid: 1.3.6.1.2.1.2.2.1.2
  498. type: DisplayString
  499. - labels:
  500. - ifIndex
  501. labelname: ifName
  502. oid: 1.3.6.1.2.1.31.1.1.1.1
  503. type: DisplayString
  504. - name: ifOutErrors
  505. oid: 1.3.6.1.2.1.2.2.1.20
  506. type: counter
  507. help: The number of outbound packets that could not be transmitted because of
  508. errors. - 1.3.6.1.2.1.2.2.1.20
  509. indexes:
  510. - labelname: ifIndex
  511. type: gauge
  512. lookups:
  513. - labels:
  514. - ifIndex
  515. labelname: ifAlias
  516. oid: 1.3.6.1.2.1.31.1.1.1.18
  517. type: DisplayString
  518. - labels:
  519. - ifIndex
  520. labelname: ifDescr
  521. oid: 1.3.6.1.2.1.2.2.1.2
  522. type: DisplayString
  523. - labels:
  524. - ifIndex
  525. labelname: ifName
  526. oid: 1.3.6.1.2.1.31.1.1.1.1
  527. type: DisplayString
  528. - name: ifOutQLen
  529. oid: 1.3.6.1.2.1.2.2.1.21
  530. type: gauge
  531. help: The length of the output packet queue (in packets). - 1.3.6.1.2.1.2.2.1.21
  532. indexes:
  533. - labelname: ifIndex
  534. type: gauge
  535. lookups:
  536. - labels:
  537. - ifIndex
  538. labelname: ifAlias
  539. oid: 1.3.6.1.2.1.31.1.1.1.18
  540. type: DisplayString
  541. - labels:
  542. - ifIndex
  543. labelname: ifDescr
  544. oid: 1.3.6.1.2.1.2.2.1.2
  545. type: DisplayString
  546. - labels:
  547. - ifIndex
  548. labelname: ifName
  549. oid: 1.3.6.1.2.1.31.1.1.1.1
  550. type: DisplayString
  551. - name: ifSpecific
  552. oid: 1.3.6.1.2.1.2.2.1.22
  553. type: OctetString
  554. help: A reference to MIB definitions specific to the particular media being used
  555. to realize the interface - 1.3.6.1.2.1.2.2.1.22
  556. indexes:
  557. - labelname: ifIndex
  558. type: gauge
  559. lookups:
  560. - labels:
  561. - ifIndex
  562. labelname: ifAlias
  563. oid: 1.3.6.1.2.1.31.1.1.1.18
  564. type: DisplayString
  565. - labels:
  566. - ifIndex
  567. labelname: ifDescr
  568. oid: 1.3.6.1.2.1.2.2.1.2
  569. type: DisplayString
  570. - labels:
  571. - ifIndex
  572. labelname: ifName
  573. oid: 1.3.6.1.2.1.31.1.1.1.1
  574. type: DisplayString
  575. - name: ifInMulticastPkts
  576. oid: 1.3.6.1.2.1.31.1.1.1.2
  577. type: counter
  578. help: The number of packets, delivered by this sub-layer to a higher (sub-)layer,
  579. which were addressed to a multicast address at this sub-layer - 1.3.6.1.2.1.31.1.1.1.2
  580. indexes:
  581. - labelname: ifIndex
  582. type: gauge
  583. lookups:
  584. - labels:
  585. - ifIndex
  586. labelname: ifAlias
  587. oid: 1.3.6.1.2.1.31.1.1.1.18
  588. type: DisplayString
  589. - labels:
  590. - ifIndex
  591. labelname: ifDescr
  592. oid: 1.3.6.1.2.1.2.2.1.2
  593. type: DisplayString
  594. - labels:
  595. - ifIndex
  596. labelname: ifName
  597. oid: 1.3.6.1.2.1.31.1.1.1.1
  598. type: DisplayString
  599. - name: ifInBroadcastPkts
  600. oid: 1.3.6.1.2.1.31.1.1.1.3
  601. type: counter
  602. help: The number of packets, delivered by this sub-layer to a higher (sub-)layer,
  603. which were addressed to a broadcast address at this sub-layer - 1.3.6.1.2.1.31.1.1.1.3
  604. indexes:
  605. - labelname: ifIndex
  606. type: gauge
  607. lookups:
  608. - labels:
  609. - ifIndex
  610. labelname: ifAlias
  611. oid: 1.3.6.1.2.1.31.1.1.1.18
  612. type: DisplayString
  613. - labels:
  614. - ifIndex
  615. labelname: ifDescr
  616. oid: 1.3.6.1.2.1.2.2.1.2
  617. type: DisplayString
  618. - labels:
  619. - ifIndex
  620. labelname: ifName
  621. oid: 1.3.6.1.2.1.31.1.1.1.1
  622. type: DisplayString
  623. - name: ifOutMulticastPkts
  624. oid: 1.3.6.1.2.1.31.1.1.1.4
  625. type: counter
  626. help: The total number of packets that higher-level protocols requested be transmitted,
  627. and which were addressed to a multicast address at this sub-layer, including
  628. those that were discarded or not sent - 1.3.6.1.2.1.31.1.1.1.4
  629. indexes:
  630. - labelname: ifIndex
  631. type: gauge
  632. lookups:
  633. - labels:
  634. - ifIndex
  635. labelname: ifAlias
  636. oid: 1.3.6.1.2.1.31.1.1.1.18
  637. type: DisplayString
  638. - labels:
  639. - ifIndex
  640. labelname: ifDescr
  641. oid: 1.3.6.1.2.1.2.2.1.2
  642. type: DisplayString
  643. - labels:
  644. - ifIndex
  645. labelname: ifName
  646. oid: 1.3.6.1.2.1.31.1.1.1.1
  647. type: DisplayString
  648. - name: ifOutBroadcastPkts
  649. oid: 1.3.6.1.2.1.31.1.1.1.5
  650. type: counter
  651. help: The total number of packets that higher-level protocols requested be transmitted,
  652. and which were addressed to a broadcast address at this sub-layer, including
  653. those that were discarded or not sent - 1.3.6.1.2.1.31.1.1.1.5
  654. indexes:
  655. - labelname: ifIndex
  656. type: gauge
  657. lookups:
  658. - labels:
  659. - ifIndex
  660. labelname: ifAlias
  661. oid: 1.3.6.1.2.1.31.1.1.1.18
  662. type: DisplayString
  663. - labels:
  664. - ifIndex
  665. labelname: ifDescr
  666. oid: 1.3.6.1.2.1.2.2.1.2
  667. type: DisplayString
  668. - labels:
  669. - ifIndex
  670. labelname: ifName
  671. oid: 1.3.6.1.2.1.31.1.1.1.1
  672. type: DisplayString
  673. - name: ifHCInOctets
  674. oid: 1.3.6.1.2.1.31.1.1.1.6
  675. type: counter
  676. help: The total number of octets received on the interface, including framing
  677. characters - 1.3.6.1.2.1.31.1.1.1.6
  678. indexes:
  679. - labelname: ifIndex
  680. type: gauge
  681. lookups:
  682. - labels:
  683. - ifIndex
  684. labelname: ifAlias
  685. oid: 1.3.6.1.2.1.31.1.1.1.18
  686. type: DisplayString
  687. - labels:
  688. - ifIndex
  689. labelname: ifDescr
  690. oid: 1.3.6.1.2.1.2.2.1.2
  691. type: DisplayString
  692. - labels:
  693. - ifIndex
  694. labelname: ifName
  695. oid: 1.3.6.1.2.1.31.1.1.1.1
  696. type: DisplayString
  697. - name: ifHCInUcastPkts
  698. oid: 1.3.6.1.2.1.31.1.1.1.7
  699. type: counter
  700. help: The number of packets, delivered by this sub-layer to a higher (sub-)layer,
  701. which were not addressed to a multicast or broadcast address at this sub-layer
  702. - 1.3.6.1.2.1.31.1.1.1.7
  703. indexes:
  704. - labelname: ifIndex
  705. type: gauge
  706. lookups:
  707. - labels:
  708. - ifIndex
  709. labelname: ifAlias
  710. oid: 1.3.6.1.2.1.31.1.1.1.18
  711. type: DisplayString
  712. - labels:
  713. - ifIndex
  714. labelname: ifDescr
  715. oid: 1.3.6.1.2.1.2.2.1.2
  716. type: DisplayString
  717. - labels:
  718. - ifIndex
  719. labelname: ifName
  720. oid: 1.3.6.1.2.1.31.1.1.1.1
  721. type: DisplayString
  722. - name: ifHCInMulticastPkts
  723. oid: 1.3.6.1.2.1.31.1.1.1.8
  724. type: counter
  725. help: The number of packets, delivered by this sub-layer to a higher (sub-)layer,
  726. which were addressed to a multicast address at this sub-layer - 1.3.6.1.2.1.31.1.1.1.8
  727. indexes:
  728. - labelname: ifIndex
  729. type: gauge
  730. lookups:
  731. - labels:
  732. - ifIndex
  733. labelname: ifAlias
  734. oid: 1.3.6.1.2.1.31.1.1.1.18
  735. type: DisplayString
  736. - labels:
  737. - ifIndex
  738. labelname: ifDescr
  739. oid: 1.3.6.1.2.1.2.2.1.2
  740. type: DisplayString
  741. - labels:
  742. - ifIndex
  743. labelname: ifName
  744. oid: 1.3.6.1.2.1.31.1.1.1.1
  745. type: DisplayString
  746. - name: ifHCInBroadcastPkts
  747. oid: 1.3.6.1.2.1.31.1.1.1.9
  748. type: counter
  749. help: The number of packets, delivered by this sub-layer to a higher (sub-)layer,
  750. which were addressed to a broadcast address at this sub-layer - 1.3.6.1.2.1.31.1.1.1.9
  751. indexes:
  752. - labelname: ifIndex
  753. type: gauge
  754. lookups:
  755. - labels:
  756. - ifIndex
  757. labelname: ifAlias
  758. oid: 1.3.6.1.2.1.31.1.1.1.18
  759. type: DisplayString
  760. - labels:
  761. - ifIndex
  762. labelname: ifDescr
  763. oid: 1.3.6.1.2.1.2.2.1.2
  764. type: DisplayString
  765. - labels:
  766. - ifIndex
  767. labelname: ifName
  768. oid: 1.3.6.1.2.1.31.1.1.1.1
  769. type: DisplayString
  770. - name: ifHCOutOctets
  771. oid: 1.3.6.1.2.1.31.1.1.1.10
  772. type: counter
  773. help: The total number of octets transmitted out of the interface, including framing
  774. characters - 1.3.6.1.2.1.31.1.1.1.10
  775. indexes:
  776. - labelname: ifIndex
  777. type: gauge
  778. lookups:
  779. - labels:
  780. - ifIndex
  781. labelname: ifAlias
  782. oid: 1.3.6.1.2.1.31.1.1.1.18
  783. type: DisplayString
  784. - labels:
  785. - ifIndex
  786. labelname: ifDescr
  787. oid: 1.3.6.1.2.1.2.2.1.2
  788. type: DisplayString
  789. - labels:
  790. - ifIndex
  791. labelname: ifName
  792. oid: 1.3.6.1.2.1.31.1.1.1.1
  793. type: DisplayString
  794. - name: ifHCOutUcastPkts
  795. oid: 1.3.6.1.2.1.31.1.1.1.11
  796. type: counter
  797. help: The total number of packets that higher-level protocols requested be transmitted,
  798. and which were not addressed to a multicast or broadcast address at this sub-layer,
  799. including those that were discarded or not sent - 1.3.6.1.2.1.31.1.1.1.11
  800. indexes:
  801. - labelname: ifIndex
  802. type: gauge
  803. lookups:
  804. - labels:
  805. - ifIndex
  806. labelname: ifAlias
  807. oid: 1.3.6.1.2.1.31.1.1.1.18
  808. type: DisplayString
  809. - labels:
  810. - ifIndex
  811. labelname: ifDescr
  812. oid: 1.3.6.1.2.1.2.2.1.2
  813. type: DisplayString
  814. - labels:
  815. - ifIndex
  816. labelname: ifName
  817. oid: 1.3.6.1.2.1.31.1.1.1.1
  818. type: DisplayString
  819. - name: ifHCOutMulticastPkts
  820. oid: 1.3.6.1.2.1.31.1.1.1.12
  821. type: counter
  822. help: The total number of packets that higher-level protocols requested be transmitted,
  823. and which were addressed to a multicast address at this sub-layer, including
  824. those that were discarded or not sent - 1.3.6.1.2.1.31.1.1.1.12
  825. indexes:
  826. - labelname: ifIndex
  827. type: gauge
  828. lookups:
  829. - labels:
  830. - ifIndex
  831. labelname: ifAlias
  832. oid: 1.3.6.1.2.1.31.1.1.1.18
  833. type: DisplayString
  834. - labels:
  835. - ifIndex
  836. labelname: ifDescr
  837. oid: 1.3.6.1.2.1.2.2.1.2
  838. type: DisplayString
  839. - labels:
  840. - ifIndex
  841. labelname: ifName
  842. oid: 1.3.6.1.2.1.31.1.1.1.1
  843. type: DisplayString
  844. - name: ifHCOutBroadcastPkts
  845. oid: 1.3.6.1.2.1.31.1.1.1.13
  846. type: counter
  847. help: The total number of packets that higher-level protocols requested be transmitted,
  848. and which were addressed to a broadcast address at this sub-layer, including
  849. those that were discarded or not sent - 1.3.6.1.2.1.31.1.1.1.13
  850. indexes:
  851. - labelname: ifIndex
  852. type: gauge
  853. lookups:
  854. - labels:
  855. - ifIndex
  856. labelname: ifAlias
  857. oid: 1.3.6.1.2.1.31.1.1.1.18
  858. type: DisplayString
  859. - labels:
  860. - ifIndex
  861. labelname: ifDescr
  862. oid: 1.3.6.1.2.1.2.2.1.2
  863. type: DisplayString
  864. - labels:
  865. - ifIndex
  866. labelname: ifName
  867. oid: 1.3.6.1.2.1.31.1.1.1.1
  868. type: DisplayString
  869. - name: ifLinkUpDownTrapEnable
  870. oid: 1.3.6.1.2.1.31.1.1.1.14
  871. type: gauge
  872. help: Indicates whether linkUp/linkDown traps should be generated for this interface
  873. - 1.3.6.1.2.1.31.1.1.1.14
  874. indexes:
  875. - labelname: ifIndex
  876. type: gauge
  877. lookups:
  878. - labels:
  879. - ifIndex
  880. labelname: ifAlias
  881. oid: 1.3.6.1.2.1.31.1.1.1.18
  882. type: DisplayString
  883. - labels:
  884. - ifIndex
  885. labelname: ifDescr
  886. oid: 1.3.6.1.2.1.2.2.1.2
  887. type: DisplayString
  888. - labels:
  889. - ifIndex
  890. labelname: ifName
  891. oid: 1.3.6.1.2.1.31.1.1.1.1
  892. type: DisplayString
  893. enum_values:
  894. 1: enabled
  895. 2: disabled
  896. - name: ifHighSpeed
  897. oid: 1.3.6.1.2.1.31.1.1.1.15
  898. type: gauge
  899. help: An estimate of the interface's current bandwidth in units of 1,000,000 bits
  900. per second - 1.3.6.1.2.1.31.1.1.1.15
  901. indexes:
  902. - labelname: ifIndex
  903. type: gauge
  904. lookups:
  905. - labels:
  906. - ifIndex
  907. labelname: ifAlias
  908. oid: 1.3.6.1.2.1.31.1.1.1.18
  909. type: DisplayString
  910. - labels:
  911. - ifIndex
  912. labelname: ifDescr
  913. oid: 1.3.6.1.2.1.2.2.1.2
  914. type: DisplayString
  915. - labels:
  916. - ifIndex
  917. labelname: ifName
  918. oid: 1.3.6.1.2.1.31.1.1.1.1
  919. type: DisplayString
  920. - name: ifPromiscuousMode
  921. oid: 1.3.6.1.2.1.31.1.1.1.16
  922. type: gauge
  923. help: This object has a value of false(2) if this interface only accepts packets/frames
  924. that are addressed to this station - 1.3.6.1.2.1.31.1.1.1.16
  925. indexes:
  926. - labelname: ifIndex
  927. type: gauge
  928. lookups:
  929. - labels:
  930. - ifIndex
  931. labelname: ifAlias
  932. oid: 1.3.6.1.2.1.31.1.1.1.18
  933. type: DisplayString
  934. - labels:
  935. - ifIndex
  936. labelname: ifDescr
  937. oid: 1.3.6.1.2.1.2.2.1.2
  938. type: DisplayString
  939. - labels:
  940. - ifIndex
  941. labelname: ifName
  942. oid: 1.3.6.1.2.1.31.1.1.1.1
  943. type: DisplayString
  944. enum_values:
  945. 1: "true"
  946. 2: "false"
  947. - name: ifConnectorPresent
  948. oid: 1.3.6.1.2.1.31.1.1.1.17
  949. type: gauge
  950. help: This object has the value 'true(1)' if the interface sublayer has a physical
  951. connector and the value 'false(2)' otherwise. - 1.3.6.1.2.1.31.1.1.1.17
  952. indexes:
  953. - labelname: ifIndex
  954. type: gauge
  955. lookups:
  956. - labels:
  957. - ifIndex
  958. labelname: ifAlias
  959. oid: 1.3.6.1.2.1.31.1.1.1.18
  960. type: DisplayString
  961. - labels:
  962. - ifIndex
  963. labelname: ifDescr
  964. oid: 1.3.6.1.2.1.2.2.1.2
  965. type: DisplayString
  966. - labels:
  967. - ifIndex
  968. labelname: ifName
  969. oid: 1.3.6.1.2.1.31.1.1.1.1
  970. type: DisplayString
  971. enum_values:
  972. 1: "true"
  973. 2: "false"
  974. - name: ifCounterDiscontinuityTime
  975. oid: 1.3.6.1.2.1.31.1.1.1.19
  976. type: gauge
  977. help: The value of sysUpTime on the most recent occasion at which any one or more
  978. of this interface's counters suffered a discontinuity - 1.3.6.1.2.1.31.1.1.1.19
  979. indexes:
  980. - labelname: ifIndex
  981. type: gauge
  982. lookups:
  983. - labels:
  984. - ifIndex
  985. labelname: ifAlias
  986. oid: 1.3.6.1.2.1.31.1.1.1.18
  987. type: DisplayString
  988. - labels:
  989. - ifIndex
  990. labelname: ifDescr
  991. oid: 1.3.6.1.2.1.2.2.1.2
  992. type: DisplayString
  993. - labels:
  994. - ifIndex
  995. labelname: ifName
  996. oid: 1.3.6.1.2.1.31.1.1.1.1
  997. type: DisplayString

 我使用的是docker-compose的方式运行snmp_exporter, docker-compose.yml如下:

  1. version: "3"
  2. services:
  3. snmp-exporter:
  4. image: prom/snmp-exporter:latest
  5. restart: always
  6. ports:
  7. - "9116:9116"
  8. volumes:
  9. - ./docker/snmp/snmp.yml:/etc/snmp_exporter/snmp.yml
  10. healthcheck:
  11. test: [ "CMD-SHELL", "ps aux | grep 'snmp_exporter' || exit 1" ]
  12. interval: 10s
  13. timeout: 10s
  14. retries: 3

  prometheus.yml配置文件如下:

  我采用文件发现的形式,将配置写在switch.json中, 这样以后修改关于交换机的信息,更改后直接热加载,如果直接写死在promeths.yml每次都要重启prometheus.

  1. - job_name: 'snmp' #交换机SNMP监控
  2. file_sd_configs:
  3. - files:
  4. - /etc/prometheus/customer_conf/switch.json
  5. refresh_interval: 1m
  6. metrics_path: /snmp
  7. params:
  8. auth: [public_v2]
  9. module: [if_mib]
  10. relabel_configs:
  11. - source_labels: [__address__]
  12. target_label: __param_target
  13. - source_labels: [__param_target]
  14. target_label: instance
  15. - target_label: __address__
  16. replacement: 10.23.30.2:9116 #这个换成snmp_exporter的ip:port

 switch.json内容如下:  默认填入交换机的IP地址

  1. [
  2. {
  3. "targets": ["10.23.0.253"],
  4. "labels": {}
  5. }
  6. ]

三.Grafana面板ID: 11169

  官方Grafana Dashbord面板: https://grafana.com/grafana/dashboards/11169-snmp-stats/

  接入面板就可以看到交换机各个口的流量(上行/下行)都可以一览无余了,哈哈哈。再配置告警即可。

  面板可以再自定义做一个监控连接防火墙/公网流量的出口即可监控整个机房的公网流量(上行和下行)。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/156610
推荐阅读
相关标签
  

闽ICP备14008679号