HOWTO: turn your FreeNAS embedded netdata into a central instance for your small network

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Hi all,

ever since I started to put more and more VMs in production (private projects, production nonetheless) I wanted to turn the various netdata installations on all the nodes into a collector-master setup. So the FreeNAS becomes the central instance and all the VMs just run headless collectors.

If you are in a simple LAN behind a firewall where all the machines trust each other, the configuration of the netdata service is dead easy, see:
https://docs.netdata.cloud/streaming/

Only problem: you cannot persistently configure netdata on FreeNAS (yet).

So I came up with this post-init task:
Code:
#!/bin/sh

NETDATA_CONF="/usr/local/etc/netdata/netdata.conf"
STREAM_CONF="/usr/local/etc/netdata/stream.conf"
GUID="047cf4d3-5170-11e9-a22c-0cc47afa3c72"
MYHOSTNAME="FreeNAS"

/usr/bin/sed -i '' "s/.*hostname =.*/    hostname = ${MYHOSTNAME}/" "${NETDATA_CONF}"
/usr/bin/sed -i '' "s/.*bind to =.*/    # bind to = 127.0.0.1/" "${NETDATA_CONF}"

/usr/bin/fgrep -q "${GUID}" "${STREAM_CONF}" || cat <<EOF >> "${STREAM_CONF}"

[${GUID}]
    enabled = yes
    default history = 86400
    default memory mode = save
    health enabled by default = auto
    allow from = *
EOF

/usr/sbin/service netdata restart


Then on the headless collectors add this to netdata.conf:
Code:
[global]
    memory mode = none
    web mode = none
    hostname = my fancy hostname for the UI

and this to stream.conf:
Code:
[stream]
    enabled = yes
    destination = 192.168.178.10:19999
    api key = 047cf4d3-5170-11e9-a22c-0cc47afa3c72


Insert a newly created GUID (uuidgen) for the api key and the correct local IP address for your FreeNAS.

Done :)

Kind regards,
Patrick
 
Last edited:

Meyers

Patron
Joined
Nov 16, 2016
Messages
211
Awesome, this is a great solution for this.
Only problem: you cannot persistently configure netdata on FreeNAS (yet).

I actually just experimented with this in another thread. You can edit both config locations and it will remain persistent between reboots (at least until you upgrade).

I use Ansible so I'd probably just push out a new config after each upgrade. Your solution is great if you don't have a config management system set up, or if you're like me and just haven't gotten around to adding your FreeNAS boxes to it.
 
Top