FreeNAS monitoring in Zabbix

In this post in a few quick steps, I describe how to connect FreeNAS server to Zabbix monitoring.

  • Download zabbix-agent for FreeBSD
wget https://www.zabbix.com/downloads/4.4.6/zabbix_agent-4.4.6-freebsd-11.2-amd64.tar.gz
  • Untar file
tar xvf zabbix_agent-4.4.6-freebsd-11.2-amd64.tar.gz
  • Copying
cp ./sbin/zabbix_agentd /usr/local/sbin/
  • Add user and group
pw groupadd zabbix
pw useradd zabbix -c "Daemon user for Zabbix agent" -d /nonexistent -s /usr/sbin/nologin -w no -g zabbix
  • Create file zabbix_agentd.conf and write as below
touch /etc/zabbix_agentd.conf
Server=zabbix.bnrs.local
ServerActive=zabbix.bnrs.local
Hostname=freenas.bnrs.local
LogFile=/tmp/zabbix_agentd.log
  • Add to rc.conf starting zabbix agent with system boot
echo 'zabbix_agentd_enable="YES"' >> /etc/rc.conf
  • Create file zabbix_agentd as below
touch /etc/rc.d/zabbix_agentd
#!/bin/sh
 
# PROVIDE: zabbix_agentd
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to
# enable zabbix_agentd:
#
# zabbix_agentd_enable (bool): Set to NO by default.  Set it to YES to
#         enable zabbix_agentd.
#
 
. /etc/rc.subr
 
name="zabbix_agentd"
rcvar=zabbix_agentd_enable
start_precmd="zabbix_precmd"
required_files="/etc/zabbix_agentd.conf"
 
# read configuration and set defaultsc
load_rc_config "$name"
: ${zabbix_agentd_enable="NO"}
#: ${zabbix_agentd_pre:=/etc/${name}.pre.sh}
 
zabbix_agentd_conf="/etc/zabbix_agentd.conf"
 
if [ ! -z "$zabbix_agentd_conf" ] ; then
  zabbix_agentd_flags="${zabbix_agentd_flags} -c ${zabbix_agentd_conf}"
  required_files=${zabbix_agentd_conf}
fi
 
zabbix_precmd()
{
  if [ ! -z "$zabbix_agentd_pre" ] ; then
    if [ -e $zabbix_agentd_pre ] ; then
      . $zabbix_agentd_pre
    fi
  fi
}
 
command="/usr/local/sbin/${name}"
 
run_rc_command "$1"  run_rc_command "$1"
  • Make file zabbix_agentd executable
chmod +x /etc/rc.d/zabbix_agentd
  • Running agent
/etc/rc.d/zabbix_agentd start
  • Coping files to proper directories to run zabbix agent after reboot
cp /etc/rc.conf /conf/base/etc/
cp /etc/rc.d/zabbix_agentd /conf/base/etc/rc.d/
cp /etc/zabbix_agentd.conf /conf/base/etc/

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 comments
Inline Feedbacks
View all comments