Search code examples
serverraspberry-pizabbixnixnixos

Install Zabbix Server on NixOS


What I have

I have a server (raspberry pi connected to a fritzbox-router via ethernet) with a fresh nixos installation on it. I can connect to it via ssh (ssh [email protected]). I already have some experience with nixos, but not much.

What I want

I would like it to run a zabbix server on it and connect have a web interface to connect to (for example at nixos.fritz.box/zabbix, but I don't really care where).

What I tried

I found that there are multiple packages for zabbix on https://github.com/NixOS/nixpkgs:

Also nix search zabbix gave me hints on zabbix-cli and zabbixctl, which I belive are there for managing an existing zabbix installation and therefore not helpfull for my problem.

I looked up zabbix in the options for configuration.nix and found a lot. Most promissing looking was services.zabbixServer.enable. I set that to true in my config and rebuilt it. This seems to have worked:

systemctl status zabbix-server.service

● zabbix-server.service - Zabbix Server
     Loaded: loaded (/nix/store/dxm7imx0ryfxdyqq5bj42klprycnpzna-unit-zabbix-server.service/zabbix-server.service; enab>
     Active: active (running) since Sat 2020-10-31 17:45:59 UTC; 17h ago
    Process: 14883 ExecStartPre=/nix/store/1py4ma02cnarrnx2yhz1gnjgpv4m9v06-unit-script-zabbix-server-pre-start/bin/zab>
   Main PID: 14896 (zabbix_server)
         IP: 41.4K in, 62.1K out
      Tasks: 38 (limit: 4481)
     Memory: 33.0M
...
sudo netstat  -nap | grep zabbix
[sudo] password for admin: 
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      14896/zabbix_server
...

But I still don't know how to connect to a web interface.

I tried to enable zabbix-web (services.zabbixWeb.enable to true) but ran into an error and I don't know how to resolve it:

sudo nixos-rebuild switch
building Nix...
building the system configuration...
error: The option `services.zabbixWeb.virtualHost' is used but not defined.

I looked through hints on zabbix in the following manuals, but didn't find any hints on zabbix there.:

What I wish for

I would like to have a minimal configuration.nix that allows to run zabbix server and connect to its webinterface with a browser.

Thanks a lot in advance


Solution

  • The error message indicates that services.zabbixWeb.virtualHost is used but not defined. The solution to this is most likely to define a value for that option. You can find the documentation for services.zabbixWeb.virtualHost here:

    https://github.com/NixOS/nixpkgs/blob/be1c62932fc9889f91055f13311cc3789c197565/nixos/modules/services/web-apps/zabbix.nix#L115

    In that file you will see many other options are defined, and you will probably need to set many of them too.