TrueNas/telegraf
(→Final steps) |
(→Final steps) |
||
Line 69: | Line 69: | ||
==Final steps== | ==Final steps== | ||
+ | make the init executable | ||
+ | <nowiki>~$ chmod +x /usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.init</nowiki> | ||
create a symlink for telegraf.init | create a symlink for telegraf.init | ||
− | <nowiki>~ ln -s /usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.init /usr/local/etc/rc.d/telegraf</nowiki> | + | <nowiki>~$ ln -s /usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.init /usr/local/etc/rc.d/telegraf</nowiki> |
test the service | test the service | ||
<nowiki>~$ service telegraf start</nowiki> | <nowiki>~$ service telegraf start</nowiki> | ||
Add the following lines to /etc/rc.conf to enable telegrafb: | Add the following lines to /etc/rc.conf to enable telegrafb: | ||
<nowiki>telegraf_enable="YES"</nowiki> | <nowiki>telegraf_enable="YES"</nowiki> |
Revision as of 02:05, 11 September 2022
Contents |
Overview
reference: https://blog.victormendonca.com/2020/10/28/how-to-install-telegraf-on-freenas/
Setup and configure telegraf for TrueNAS (and probably any other FreeBSD OS)
Download and extract telegraf tar.gz
Find the latest telegraf release here
https://github.com/influxdata/telegraf/releases
Download and extract it on a vm with GNUtar (ubuntu, centos, etc) as tar included with FreeBSD will not unpack it.
Copy files over
You only need (2) files, the binary and conf file. Copy them over to TrueNAS.
~$ ./telegraf-[version]/usr/bin/telegraf ./telegraf-[version]/etc/telegraf/telegraf.conf
TrueNAS telegraf setup
Create the directory your files will live in. I chose /usr/local/telegraf-[version]_freebsd_amd64
because /usr/local/
is the closest thing to /opt/
in freebsd
~$ sudo mkdir /usr/local/telegraf-[version]_freebsd_amd64 ~$ cp /tmp/telegraf* /usr/local/telegraf-[version]_freebsd_amd64
Create the init script
Modify the telegraf conf and bin dir vars.
~$ sudo vim /usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.init #!/bin/sh # $FreeBSD$ # PROVIDE: telegraf # REQUIRE: DAEMON NETWORKING # BEFORE: LOGIN # KEYWORD: shutdown # Add the following lines to /etc/rc.conf to enable telegrafb: # telegraf_enable="YES" # # telegraf_enable (bool): Set to YES to enable telegraf # Default: NO # telegraf_conf (str): telegraf configuration file # Default: ${PREFIX}/etc/telegraf.conf # telegraf_flags (str): Extra flags passed to telegraf . /etc/rc.subr name="telegraf" rcvar=telegraf_enable load_rc_config "${name}" : ${telegraf_enable:="YES"} : ${telegraf_flags:="-quiet"} : ${telegraf_conf:="/usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.conf"} : ${telegraf_bindir:="/usr/local/telegraf-1.23.4_freebsd_amd64"} pidfile="/var/run/${name}.pid" command=/usr/sbin/daemon command_args="-crP ${pidfile} ${telegraf_bindir}/${name} ${telegraf_flags} -config=${telegraf_conf}" telegraf_prestart() { # Have to empty rc_flags so they don't get passed to daemon(8) touch $pidfile rc_flags="" } telegraf_start() { ${command} ${command_args} ${rc_arg} >> /var/log/telegraf.log 2>&1 } start_precmd="${name}_prestart" start_cmd="${name}_start" run_rc_command "$1"
Final steps
make the init executable
~$ chmod +x /usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.init
create a symlink for telegraf.init
~$ ln -s /usr/local/telegraf-1.23.4_freebsd_amd64/telegraf.init /usr/local/etc/rc.d/telegraf
test the service
~$ service telegraf start
Add the following lines to /etc/rc.conf to enable telegrafb:
telegraf_enable="YES"