installing zabbix-sender or zabbix-agent for monitoring jobs and system status?

nktech1135

Dabbler
Joined
Feb 26, 2021
Messages
18
Hi all.
I'm wondering what the proper way is to install a monitoring agent like zabbix-agent on truenas scale?
I get the impression from browsing the forums that one should avoid using apt for package management because things get over written on upgrades. I could install the .deb file of zabbix-agent but don't know if that will get overwritten as well?
Can someone comment on this?

Thanks.
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
Best solution would be an App or container.
This solution should work:

It's added to the TrueCharts App request list right away, if anyone would be interested in adding it:
 

Janus0006

Dabbler
Joined
Mar 27, 2021
Messages
46
I was able to install and make it works permanently, but ... I forgot the solution.
You have my vote to create an app for easy usage of zabbix-agent
 

tumpanaios

Cadet
Joined
Dec 7, 2018
Messages
5
I have done the following on my truenas core installation (freebsd):

- Build zabbix agent to produce zabbix agent binaries for freebsd 12.2 because there are no binaries prebuilt or i could not find any
- Create a dataset for zabbix config and binaries like zfs create tank/Zabbix
- Copy the built binaries and config to subfolders of the above dataset, like bin,sbin,conf
- Edit configuration of zabbix agent with correct options
- Add a post init init/shutdown script with command /mnt/tank/Zabbix/sbin/zabbix_agentd -c /mnt/tank/Zabbix/conf/zabbix_agentd.conf
- Run /mnt/tank/Zabbix/sbin/zabbix_agentd -c /mnt/tank/Zabbix/conf/zabbix_agentd.conf to start the agent service without having to restart the server

I do not know which debian version is used for truenas scale. You can check by running cat /etc/debian_version. If it is 10.xx it is running on buster, if it is 11.xx is running on bullseye. You have to either build zabbix agent for that release or maybe you can find those binaries if you apt install zabbix-agent to a debian machine and copy them over. You can add the zabbix repo to /etc/apt/sources.list.d/zabbixXX.list and run apt update if you want specific version of zabbix-agent(5.4 is the latest). If you opt for the 2nd approach the binaries should be on /usr/sbin/zabbix_agent and /usr/bin/zabbix_sender.

I have not used truenas scale , so maybe there is a better way to add custom repositories and packages that persist reboots.
 

Dunuin

Contributor
Joined
Mar 7, 2013
Messages
110
I'm also interested in how to run a zabbix agent on TrueNAS SCALE or Core. Right now I'm running a TrueNAS-12.0-U8.1 and I use a modified zabbix template that fetches most metrics like pool status, free space and so on using SNMP so running a zabbix agent isn't required.
But the second most important metric I want to monitor is the disk health and for that my zabbix somehow needs access to the SMART stats of all disks and these aren't included when using SNMP. For all my other hosts I run the zabbix agent with a template that runs a script that calls smartctl for autodiscovery of disks and querying SMART stats.
On TrueNAS Core I tried to run the zabbix agent inside a jail (because nothing should be changed directly on the host) but never got that working allowing the jail to access the SMART stats.
Would there be a way on TrueNAS SCALE to run a zabbix agent with full access to all the hosts hardware so that fetching SMART stats and so on would be possible without screwing up the appliance?

@tumpanaios:
Sounds like that would be a good option. How did you compile it? Zabbix now got a FreeSD 13.0 binary but I don't want to switch to TrueNAS Core 13.0 yet to be able to test it.
 
Last edited:

tumpanaios

Cadet
Joined
Dec 7, 2018
Messages
5
I'm also interested in how to run a zabbix agent on TrueNAS SCALE or Core. Right now I'm running a TrueNAS-12.0-U8.1 and I use a modified zabbix template that fetches most metrics like pool status, free space and so on using SNMP so running a zabbix agent isn't required.
But the second most important metric I want to monitor is the disk health and for that my zabbix somehow needs access to the SMART stats of all disks and these aren't included when using SNMP. For all my other hosts I run the zabbix agent with a template that runs a script that calls smartctl for autodiscovery of disks and querying SMART stats.
On TrueNAS Core I tried to run the zabbix agent inside a jail (because nothing should be changed directly on the host) but never got that working allowing the jail to access the SMART stats.
Would there be a way on TrueNAS SCALE to run a zabbix agent with full access to all the hosts hardware so that fetching SMART stats and so on would be possible without screwing up the appliance?

@tumpanaios:
Sounds like that would be a good option. How did you compile it? Zabbix now got a FreeSD 13.0 binary but I don't want to switch to TrueNAS Core 13.0 yet to be able to test it.
Hello, i compiled it long time ago using freebsd ports in a jail. I do not remember the options i used. It might be easier for your use case to set it up in a jail if you are still interested.

  1. Create a script, for example smart_devfs_rules.sh with the following content on a zfs dataset. Source . Check /etc/default/devfs.rules to see the definitions of the included devfs rules.
    Code:
    #!/usr/bin/env sh
    cat >>/etc/devfs.rules << 'EOF'
    
    [devfsrules_bpfjail=101]
    add path 'bpf*' unhide
    
    [disk_ada4=110]
    add include $devfsrules_hide_all
    add include $devfsrules_unhide_basic
    add include $devfsrules_unhide_login
    add include $devfsrules_jail
    add include $devfsrules_bpfjail
    add path 'ada*' unhide
    add path 'xpt*' unhide
    add path 'pass*' unhide
    
    EOF
    
    service devfs restart
    
  2. Make the script executable and run it.
  3. Create the jail like:
    Code:
     iocage create -T -n smartmon -r 12.3-RELEASE bpf=on vnet=on interfaces="vnet0:bridge0" ip4_addr="vnet0|192.168.1.80" defaultrouter=192.168.1.1 securelevel=0 devfs_ruleset=110
  4. Install smartmontools and zabbix-agent(2) inside the jail with pkg or ports.
  5. You can use this zabbix template if you like or create your own
  6. Add the script to run every time on boot by setting to run as a postinit task.
  7. Optionally read xpt pass devfs and securelevel man pages
I do not know how to do this on scale. Probably there must be a similar way using docker
 
Top