announce.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 by 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.
  78. gluon-neighbour-info
  79. ~~~~~~~~~~~~~~~~~~~~
  80. A programm called `gluon-neighbour-info` has been developed to retrieve
  81. information from neighbours.
  82. ::
  83. gluon-neighbour-info -i wlan0 \
  84. -p 1001 -d ff02:0:0:0:0:0:2:1001 \
  85. -r nodeinfo
  86. On optional timeout may be specified, e.g. `-t 5` (default: 3 seconds).
  87. Adding a fact
  88. -------------
  89. To add a fact just add a file to either ``/lib/gluon/announce/nodeinfo.d/`` or
  90. ``/lib/gluon/announce/statistics.d/``.
  91. The file must contain a lua script and its name will become the key for the
  92. resulting JSON object. A simple script adding a ``hostname`` field might look
  93. like this:
  94. ::
  95. return uci:get_first('system', 'system', 'hostname')
  96. The directory structure will be converted to a JSON object, i.e. you may
  97. create subdirectories. So, if the directories look like this
  98. ::
  99. .
  100. ├── hardware
  101. │   └── model
  102. ├── hostname
  103. ├── network
  104. │   └── mac
  105. ├── node_id
  106. └── software
  107. └── firmware
  108. the resulting JSON would become:
  109. ::
  110. # /lib/gluon/announce/announce.lua nodeinfo
  111. {
  112. "hardware" : {
  113. "model" : "TP-Link TL-MR3420 v1"
  114. },
  115. "hostname" : "mr3420-test",
  116. "network" : {
  117. "mac" : "90:f6:52:82:06:02"
  118. },
  119. "node_id" : "90f652820602",
  120. "software" : {
  121. "firmware" : {
  122. "base" : "gluon-v2014.2-32-ge831099",
  123. "release" : "0.4.1+0-exp20140720"
  124. }
  125. }
  126. }