announce.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. Announcing Node Information
  2. ===========================
  3. Gluon is capable of announcing information about each node to the mesh
  4. and to neighbouring nodes. This allows nodes to learn each others hostname,
  5. IP addresses, location, software versions and various other information.
  6. Format of collected data
  7. ------------------------
  8. Information to be announced is currently split into two categories:
  9. nodeinfo
  10. In this category (mostly) static information is collected. If
  11. something is unlikely to change without human intervention it should be
  12. put here.
  13. statistics
  14. This category holds fast changing data, like traffic counters, uptime,
  15. system load or the selected gateway.
  16. Both categories will have a ``node_id`` key be default. It should be used to
  17. match data from *statistics* to *nodeinfo*.
  18. Accessing Node Information
  19. --------------------------
  20. There are two packages responsible for distribution of the information. For
  21. one, information is distributed across the mesh using alfred_. Information
  22. between neighbouring nodes is exchanged using `gluon-announced`.
  23. .. _alfred: http://www.open-mesh.org/projects/alfred
  24. alfred (mesh bound)
  25. ~~~~~~~~~~~~~~~~~~~
  26. The package ``gluon-alfred`` is required for this to work.
  27. Using alfred both categories are distributed within the mesh. In order to
  28. retrieve the data you'll need both a local alfred daemon and alfred-json_
  29. installed. Please note that at least one alfred daemon is required to run as
  30. `master`.
  31. .. _alfred-json: https://github.com/tcatm/alfred-json
  32. `nodeinfo` is distributed as alfred datatype `158`, while `statistics` uses
  33. `159`. Both are compressed using GZip (alfred-json can handle the decompression).
  34. In order to retrieve statistics data you could run:
  35. ::
  36. # alfred-json -z -r 159
  37. {
  38. "f8:d1:11:7e:97:dc": {
  39. "processes": {
  40. "total": 55,
  41. "running": 2
  42. },
  43. "idletime": 30632.290000000001,
  44. "uptime": 33200.07,
  45. "memory": {
  46. "free": 1660,
  47. "cached": 8268,
  48. "total": 29212,
  49. "buffers": 2236
  50. },
  51. "node_id": "f8d1117e97dc",
  52. "loadavg": 0.01
  53. },
  54. "90:f6:52:3e:b9:50": {
  55. "processes": {
  56. "total": 58,
  57. "running": 2
  58. },
  59. "idletime": 28047.470000000001,
  60. "uptime": 33307.849999999999,
  61. "memory": {
  62. "free": 2364,
  63. "cached": 7168,
  64. "total": 29212,
  65. "buffers": 1952
  66. },
  67. "node_id": "90f6523eb950",
  68. "loadavg": 0.34000000000000002
  69. }
  70. }
  71. You can find more information about alfred in its README_.
  72. .. _README: http://www.open-mesh.org/projects/alfred/repository/revisions/master/entry/README
  73. gluon-announced
  74. ~~~~~~~~~~~~~~~
  75. `gluon-announced` allows querying neighbouring nodes for their `nodeinfo`.
  76. It is a daemon listening on the multicast address ``ff02::2:1001`` on
  77. UDP port 1001 on the bare mesh interfaces. There is no client yet (but it's
  78. being developed), but you can query the information using tools like ``socat``:
  79. ::
  80. # socat - UDP6-DATAGRAM:[ff02::2:1001%wlan0-1]:1001
  81. nodeinfo
  82. This output is not compressed, but that is likely to change in the future. If
  83. you intent to use ``gluon-announced``, please contact `tcatm` in Gluon's IRC
  84. channel.
  85. Adding a fact
  86. -------------
  87. To add a fact just add a file to either ``/lib/gluon/announce/nodeinfo.d/`` or
  88. ``/lib/gluon/announce/statistics.d/``.
  89. The file must contain a lua script and its name will become the key for the
  90. resulting JSON object. A simple script adding a ``hostname`` field might look
  91. like this:
  92. ::
  93. return uci:get_first('system', 'system', 'hostname')
  94. The directory structure will be converted to a JSON object, i.e. you may
  95. create subdirectories. So, if the directories look like this
  96. ::
  97. .
  98. ├── hardware
  99. │   └── model
  100. ├── hostname
  101. ├── network
  102. │   └── mac
  103. ├── node_id
  104. └── software
  105. └── firmware
  106. the resulting JSON would become:
  107. ::
  108. # /lib/gluon/announce/announce.lua nodeinfo
  109. {
  110. "hardware" : {
  111. "model" : "TP-Link TL-MR3420 v1"
  112. },
  113. "hostname" : "mr3420-test",
  114. "network" : {
  115. "mac" : "90:f6:52:82:06:02"
  116. },
  117. "node_id" : "90f652820602",
  118. "software" : {
  119. "firmware" : {
  120. "base" : "gluon-v2014.2-32-ge831099",
  121. "release" : "0.4.1+0-exp20140720"
  122. }
  123. }
  124. }