You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

prometheus-node-exporter-lua: add bmx6/7 scraper scrapes bmx6 status and connected links. example output: bmx6_status{id="qMp-LibreMesh-1706",version="BMX6-0.1-alpha",address="fd66:66:66:a:6670:2ff:fe3e:9d28"} 1 bmx6_link_rxRate{target="UPC-CN-C6-E104-Alix",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 bmx6_link_txRate{target="UPC-CN-C6-E104-Alix",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 bmx6_link_rxRate{target="UPC-CN-C6-E104-Alix-Paul",source="qMp-LibreMesh-1706",dev="wlan1-adhoc_12"} 100 bmx6_link_txRate{target="UPC-CN-C6-E104-Alix-Paul",source="qMp-LibreMesh-1706",dev="wlan1-adhoc_12"} 100 bmx6_link_rxRate{target="UPC-CN-C6-E104-Turoffner",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 97 bmx6_link_txRate{target="UPC-CN-C6-E104-Turoffner",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 node_scrape_collector_duration_seconds{collector="bmx6"} 0.0025260448455811 node_scrape_collector_success{collector="bmx6"} 1 scrapes bmx7 status and connected links. example output: bmx7_status{id="C68791D2",revision="3a52f89",name="smpl-18f4ce",address="fd70:c687:91d2:8ab3:1a88:6b14:bad0:2b18"} 1 bmx7_cpu_usage 0.7 bmx7_mem_usage 3204000 bmx7_link_rxRate{target="F48239CD",dev="wlan0-mesh_13",source="C68791D2",name="smpl-07889a"} 54000 bmx7_link_txRate{target="F48239CD",dev="wlan0-mesh_13",source="C68791D2",name="smpl-07889a"} 52729 node_scrape_collector_duration_seconds{collector="bmx7"} 0.0020999908447266 node_scrape_collector_success{collector="bmx7"} 1 prometheus-node-exporter-lua: bmx6/7 netjson format adds labels called source and target to links instead of only the target previously called "id". Retrieving all *links* from prometheus now makes it easier to create a valid netjson(.org) graph. It's not feasible to use *instance* as *source* as for instance likely the name is used for dns, instead of the ID. Using the *name* instead of *id* for netjson linking results in a bad graph when two devices have the same (default) hostname. Signed-off-by: Paul Spooren <spooren@informatik.uni-leipzig.de>
7 years ago
prometheus-node-exporter-lua: add bmx6/7 scraper scrapes bmx6 status and connected links. example output: bmx6_status{id="qMp-LibreMesh-1706",version="BMX6-0.1-alpha",address="fd66:66:66:a:6670:2ff:fe3e:9d28"} 1 bmx6_link_rxRate{target="UPC-CN-C6-E104-Alix",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 bmx6_link_txRate{target="UPC-CN-C6-E104-Alix",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 bmx6_link_rxRate{target="UPC-CN-C6-E104-Alix-Paul",source="qMp-LibreMesh-1706",dev="wlan1-adhoc_12"} 100 bmx6_link_txRate{target="UPC-CN-C6-E104-Alix-Paul",source="qMp-LibreMesh-1706",dev="wlan1-adhoc_12"} 100 bmx6_link_rxRate{target="UPC-CN-C6-E104-Turoffner",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 97 bmx6_link_txRate{target="UPC-CN-C6-E104-Turoffner",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 node_scrape_collector_duration_seconds{collector="bmx6"} 0.0025260448455811 node_scrape_collector_success{collector="bmx6"} 1 scrapes bmx7 status and connected links. example output: bmx7_status{id="C68791D2",revision="3a52f89",name="smpl-18f4ce",address="fd70:c687:91d2:8ab3:1a88:6b14:bad0:2b18"} 1 bmx7_cpu_usage 0.7 bmx7_mem_usage 3204000 bmx7_link_rxRate{target="F48239CD",dev="wlan0-mesh_13",source="C68791D2",name="smpl-07889a"} 54000 bmx7_link_txRate{target="F48239CD",dev="wlan0-mesh_13",source="C68791D2",name="smpl-07889a"} 52729 node_scrape_collector_duration_seconds{collector="bmx7"} 0.0020999908447266 node_scrape_collector_success{collector="bmx7"} 1 prometheus-node-exporter-lua: bmx6/7 netjson format adds labels called source and target to links instead of only the target previously called "id". Retrieving all *links* from prometheus now makes it easier to create a valid netjson(.org) graph. It's not feasible to use *instance* as *source* as for instance likely the name is used for dns, instead of the ID. Using the *name* instead of *id* for netjson linking results in a bad graph when two devices have the same (default) hostname. Signed-off-by: Paul Spooren <spooren@informatik.uni-leipzig.de>
7 years ago
prometheus-node-exporter-lua: add bmx6/7 scraper scrapes bmx6 status and connected links. example output: bmx6_status{id="qMp-LibreMesh-1706",version="BMX6-0.1-alpha",address="fd66:66:66:a:6670:2ff:fe3e:9d28"} 1 bmx6_link_rxRate{target="UPC-CN-C6-E104-Alix",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 bmx6_link_txRate{target="UPC-CN-C6-E104-Alix",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 bmx6_link_rxRate{target="UPC-CN-C6-E104-Alix-Paul",source="qMp-LibreMesh-1706",dev="wlan1-adhoc_12"} 100 bmx6_link_txRate{target="UPC-CN-C6-E104-Alix-Paul",source="qMp-LibreMesh-1706",dev="wlan1-adhoc_12"} 100 bmx6_link_rxRate{target="UPC-CN-C6-E104-Turoffner",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 97 bmx6_link_txRate{target="UPC-CN-C6-E104-Turoffner",source="qMp-LibreMesh-1706",dev="wlan0-mesh_12"} 100 node_scrape_collector_duration_seconds{collector="bmx6"} 0.0025260448455811 node_scrape_collector_success{collector="bmx6"} 1 scrapes bmx7 status and connected links. example output: bmx7_status{id="C68791D2",revision="3a52f89",name="smpl-18f4ce",address="fd70:c687:91d2:8ab3:1a88:6b14:bad0:2b18"} 1 bmx7_cpu_usage 0.7 bmx7_mem_usage 3204000 bmx7_link_rxRate{target="F48239CD",dev="wlan0-mesh_13",source="C68791D2",name="smpl-07889a"} 54000 bmx7_link_txRate{target="F48239CD",dev="wlan0-mesh_13",source="C68791D2",name="smpl-07889a"} 52729 node_scrape_collector_duration_seconds{collector="bmx7"} 0.0020999908447266 node_scrape_collector_success{collector="bmx7"} 1 prometheus-node-exporter-lua: bmx6/7 netjson format adds labels called source and target to links instead of only the target previously called "id". Retrieving all *links* from prometheus now makes it easier to create a valid netjson(.org) graph. It's not feasible to use *instance* as *source* as for instance likely the name is used for dns, instead of the ID. Using the *name* instead of *id* for netjson linking results in a bad graph when two devices have the same (default) hostname. Signed-off-by: Paul Spooren <spooren@informatik.uni-leipzig.de>
7 years ago
  1. #!/usr/bin/lua
  2. local json = require "cjson"
  3. local function interpret_suffix(rate)
  4. if rate ~= nil then
  5. local value = string.sub(rate, 1, -2)
  6. local suffix = string.sub(rate, -1)
  7. if suffix == "K" then return tonumber(value) * 10^3 end
  8. if suffix == "M" then return tonumber(value) * 10^6 end
  9. if suffix == "G" then return tonumber(value) * 10^9 end
  10. end
  11. return rate
  12. end
  13. local function scrape()
  14. local status = json.decode(get_contents("/var/run/bmx7/json/status")).status
  15. local labels = {
  16. id = status.shortId,
  17. name = status.name,
  18. address = status.primaryIp,
  19. revision = status.revision,
  20. }
  21. metric("bmx7_status", "gauge", labels, 1)
  22. metric("bmx7_cpu_usage", "gauge", nil, status.cpu)
  23. metric("bmx7_mem_usage", "gauge", nil, interpret_suffix(status.mem))
  24. local links = json.decode(get_contents("/var/run/bmx7/json/links")).links
  25. local metric_bmx7_rxRate = metric("bmx7_link_rxRate","gauge")
  26. local metric_bmx7_txRate = metric("bmx7_link_txRate","gauge")
  27. for _, link in pairs(links) do
  28. local labels = {
  29. source = status.shortId,
  30. target = link.shortId,
  31. name = link.name,
  32. dev = link.dev
  33. }
  34. metric_bmx7_rxRate(labels, interpret_suffix(link.rxRate))
  35. metric_bmx7_txRate(labels, interpret_suffix(link.txRate))
  36. end
  37. local metric_bmx7_tunIn = metric("bmx7_tunIn", "gauge")
  38. local parameters = json.decode(get_contents("/var/run/bmx7/json/parameters")).OPTIONS
  39. for _, option in pairs(parameters) do
  40. if option.name == "tunIn" then
  41. for _, instance in pairs(option.INSTANCES) do
  42. for _, child_instance in pairs(instance.CHILD_INSTANCES) do
  43. local labels = {
  44. name = instance.value,
  45. network = child_instance.value
  46. }
  47. metric_bmx7_tunIn(labels, 1)
  48. end
  49. end
  50. elseif option.name == "plugin" then
  51. local metric_bmx7_plugin = metric("bmx7_plugin", "gauge")
  52. for _, instance in pairs(option.INSTANCES) do
  53. metric_bmx7_plugin({ name = instance.value }, 1)
  54. end
  55. end
  56. end
  57. end
  58. return { scrape = scrape }