Create the firmware image

Use the OpenWrt ImageBuilder to create the base firmware image for monitoring using Zabbix Server and frontend on an OpenWrt host. We do this as the default OpenWrt images do no have a large enough root filesystem for all the required packages.

Get and Prepare the OpenWrt ImageBuilder

  1. Download the ImageBuilder for your Zabbix host.
  2. Extract the Imagebuilder (on Windows remember you need to be in WSL2). Example for a Debian-based environment:
    • sudo apt install zstd
    • mkdir -p ~/Build
    • cd ~/Build
    • tar --zstd -xvf <the-tar.zst-you-downloaded>
  3. Make sure you have the required packages for the ImageBuilder installed: OpenWrt ImageBuilder docs

Prepare a list of packages to include in the firmware

And place in your imagebuilder directory as e.g. zabbix-packages.lst

It is not required to include the default packages or device-specific packages in this list. They are added automatically. To see which packages will be added automatically use the make info command.

apache
apache-error
apache-mod-deflate
apache-mod-http2
apache-mod-php8
apache-mod-ssl
apache-utils
block-mount
ca-certificates
coreutils-who
blkid
e2fsprogs
f2fs-tools
fping
getrandom
ip-bridge
logrotate
luci-light
luci-proto-ipv6
luci-ssl
oniguruma
parted
pgsql-cli
pgsql-cli-extra
pgsql-server
php8-cgi
php8-cli
php8-mod-bcmath
php8-mod-ctype
php8-mod-curl
php8-mod-dom
php8-mod-filter
php8-mod-gd
php8-mod-gettext
php8-mod-gmp
php8-mod-ldap
php8-mod-mbstring
php8-mod-openssl
php8-mod-pgsql
php8-mod-session
php8-mod-simplexml
php8-mod-sockets
php8-mod-xmlreader
php8-mod-xmlwriter
zabbix-agentd-openssl
zabbix-extra-network
zabbix-get-openssl
zabbix-server-frontend
zabbix-server-openssl

Other packages you may wish to add

luci-app-lldpd
luci-app-nlbwmon
nano-full
owut
tmux

Make sure you have any drivers for storage you wish to use

For example if using USB storage:

kmod-usb-storage
kmod-usb-storage-uas

Create a file to initialize the network configuration

This step is optional.

  1. umask 0002
  2. mkdir -p extra_files/etc/uci-defaults
  3. Open your favourite editor and create and edit the extra_files/etc/uci-defaults/70-configure-lan file.

For example, when using a network on VLAN 33, which servers DHCP to clients like your Zabbix host.

#!/bin/sh

uci -q get network.eth0_vlan.vlan 2>/dev/null || uci -q batch <<-EOT >>/dev/null
        delete network.lan
        set network.globals.ula=""
        set network.globals.packet_steering=1
        set network.lan="interface"
        set network.lan.proto="dhcp"
        set network.lan.device="br-lan.33"
        delete network.@device[-1]
        add network device
        set network.@device[-1].name="br-lan"
        set network.@device[-1].type="bridge"
        add_list network.@device[-1].ports="eth0"
        set network.eth0_vlan="bridge-vlan"
        set network.eth0_vlan.device="br-lan"
        set network.eth0_vlan.vlan=33
        add_list network.eth0_vlan.ports="eth0:t*"
        commit network
EOT

Create a build script

E.g. build-zabbix-openwrt-firmware.sh

This most important new bit in this file is ROOTFS_PARTSIZE="300". This sets the root partition size at 300 MB which is much larger than required for the root filesystem and packages. The default is around 80 MB, which is too small.

#!/bin/sh

mkdir -p bin

export PROFILE=<profile-from-make-info-you-wish-to-use>

make image FILES="$(dirname $0)/extra_files" PACKAGES="$(cat $(dirname $0)zabbix-packages.lst | tr $'\n' ' ')" DISABLED_SERVICES="dnsmasq odhcpd" ROOTFS_PARTSIZE="300" EXTRA_IMAGE_NAME="yourservername"

Use the script

sh build-zabbix-openwrt-firmware.sh

Deploy the factory image to the device

A subdirectory of ./bin should have the resulting firmware. You need to write it to the boot/root disk of the system you will use.

Details of this are outside the scope of this guide.

The OpenWrt Factory Install: First Time Installation guide may help you with this.