Browse Source

add state yanic

Karsten Böddeker 7 years ago
parent
commit
c7d72c0b32
4 changed files with 159 additions and 0 deletions
  1. 5 0
      top.sls
  2. 68 0
      yanic/init.sls
  3. 77 0
      yanic/yanic.conf.tmpl
  4. 9 0
      yanic/yanic@.service

+ 5 - 0
top.sls

@@ -70,3 +70,8 @@ base:
   nodes:{{ grains['id'] }}:roles:influxdb:
     - match: pillar
     - influxdb
+
+  # yanic
+  nodes:{{ grains['id'] }}:roles:yanic:
+    - match: pillar
+    - yanic

+ 68 - 0
yanic/init.sls

@@ -0,0 +1,68 @@
+#
+# yanic
+#
+
+# add yanic directory
+/srv/yanic/data:
+  file.directory:
+    - makedirs: True
+
+# copy yanic binary to destination
+# the binary needs to be provided by the salt-master
+yanic:
+  file.managed:
+   - name: /srv/yanic/yanic
+   - source: salt://yanic/yanic
+   - mode: 755
+   - require:
+     - file: /srv/yanic/data
+
+# copy systemd yanic@.service
+/etc/systemd/system/yanic@.service:
+  file.managed:
+    - source: salt://yanic/yanic@.service
+    - require:
+      - file: yanic
+
+# the internal webserver should be enabled
+{% set webserver = "true" %}
+
+# get loopback IPv6 for binding the webserver to it
+{% set node_config = salt['pillar.get']('nodes:' ~ grains['id']) %}
+{% set bind_ip = salt['ffho_net.get_loopback_ip'](node_config, grains['id'], 'v6') %}
+
+# for each site
+{% for site in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':sites', []) %}
+# add webserver directory
+/srv/yanic/data/{{site}}:
+  file.directory:
+    - require:
+      - file: /srv/yanic/data
+
+# add configuration file
+/srv/yanic/{{site}}.conf:
+  file.managed:
+    - source: salt://yanic/yanic.conf.tmpl
+    - template: jinja
+    - defaults:
+      iface: "br-{{site}}"
+      site: "{{site}}"
+      webserver: "{{webserver}}"
+      bind_ip: {{bind_ip}}
+  # the webserver should only be enabled once
+  {% set webserver = "false" %}
+    - require:
+      - file: /srv/yanic/data/{{site}}
+
+# enable the yanic service
+# and restart if configuration or binary has changed
+yanic@{{site}}:
+  service.running:
+    - enable: True
+    - require:
+      - file: /srv/yanic/{{site}}.conf
+      - file: /etc/systemd/system/yanic@.service
+    - watch:
+      - file: /srv/yanic/{{site}}.conf
+      - file: yanic
+{% endfor %}

+ 77 - 0
yanic/yanic.conf.tmpl

@@ -0,0 +1,77 @@
+# Send respondd request to update information
+[respondd]
+enable           = true
+# how oftern request per multicast
+collect_interval = "1m"
+# on which interface
+interface        = "{{iface}}"
+# define a port to listen
+# (no or 0 would choose at port at his own)
+#port = 10001
+
+
+# A little build-in webserver, which statically serves a directory.
+# This is useful for testing purposes or for a little standalone installation.
+[webserver]
+enable  = {{webserver}}
+bind    = "[{{bind_ip}}]:8080"
+webroot = "/srv/yanic/data"
+
+
+[nodes]
+enable         = true
+# state-version of nodes.json to store cached data,
+#  these is the directly collected respondd data
+state_path     = "/srv/yanic/{{site}}.state"
+
+# Export nodes and graph periodically
+save_interval = "1m"
+
+# Set node to offline if not seen within this period
+offline_after = "10m"
+
+# Prune offline nodes after a time of inactivity
+{%- if site == 'legacy' %}
+prune_after = "14d"
+{%- else %}
+prune_after = "30d"
+{%- endif %}
+
+[meshviewer]
+# structur of nodes.json, which to support
+# version 1 is to support legacy meshviewer (which are in master branch)
+#    i.e. https://github.com/ffnord/meshviewer/tree/master
+# version 2 is to support new version of meshviewer (which are in legacy develop branch or newer)
+#    i.e. https://github.com/ffnord/meshviewer/tree/dev
+#         https://github.com/ffrgb/meshviewer/tree/develop
+version  = 2
+# path where to store nodes.json
+nodes_path     = "/srv/yanic/data/{{site}}/nodes.json"
+# path where to store graph.json
+graph_path     = "/srv/yanic/data/{{site}}/graph.json"
+
+[database]
+# cleaning data of measurement node,
+#   which are older than 7d
+delete_after = "30d"
+#   how often run the cleaning
+delete_interval = "1d"
+
+# Save collected data to InfluxDB
+# there would be the following measurments:
+#  node: store node spezific data i.e. clients memory, airtime
+#  global: store global data, i.e. count of clients and nodes
+#  firmware: store count of nodes tagged with firmware
+#  model: store count of nodes tagged with hardware model
+[[database.connection.influxdb]]
+enable   = true
+address  = "https://db01.in.ffho.net:8086/"
+database = "mesh"
+username = "yanic"
+password = "p4KWLDs3hd%qVdVz"
+# tag the data with an optional job tag
+job = "{{site}}"
+
+[[database.connection.logging]]
+enable   = false
+path     = "/var/log/yanic.log"

+ 9 - 0
yanic/yanic@.service

@@ -0,0 +1,9 @@
+[Unit]
+Description=yanic (Site %I)
+After=network.service
+
+[Service]
+ExecStart=/srv/yanic/yanic -config /srv/yanic/%i.conf
+
+[Install]
+WantedBy=multi-user.target