Running ntopng as a Daemon

Ntopng can be run in daemon mode on Unix systems and optionally be run automatically on system startup. Daemon execution and status are controlled with systemd using the systemctl script. The systemd script is installed automatically on Unix systems as it is part of any standard ntopng installation procedure.

Daemon Configuration File

Ntopng configuration file is required when running it as a daemon. The configuration file has to be named ntopng.conf and must be placed under /etc/ntopng/. The interested reader can find above and example of a configuration file. A default configuration file is created by default when installing ntopng from any binary package.

Automatic Daemon Startup on Boot

In order to launch ntopng daemon automatically on system startup, an empty file ntopng.start must be created in the same directory of the configuration files. Therefore, the directory will contain both the configuration and the startup files

root@devel:/etc/ntopng$ ls -lha
total 28K
drwxr-xr-x   2 root root 4.0K Mar 17 15:44 .
drwxr-xr-x 117 root root  12K Mar 11 12:16 ..
-rw-r--r--   1 root root  211 Mar 15 17:54 ntopng.conf
-rw-r--r--   1 root root    0 Mar 17 15:44 ntopng.start

The existence of the ntopng.start file is no longer required on systems that have systemd. On those systems, automatic ntopng daemon startup is controlled by enabling/disabling the ntopng service as

systemctl enable ntopng
systemctl disable ntopng

Daemon Control

On Unix systems the ntopng daemon can be controlled with systemd using the systemctl tool. All the standard options are accepted. The options and the usage of the daemon control script are discussed below.

start

This option is used to start the ntopng daemon

systemctl start ntopng

stop

This option is used to stop an ntopng daemon instance. For example

systemctl stop ntopng

restart

This option causes the restart of the ntopng instance.

systemctl restart ntopng

status

This options prints the status of the ntopng daemon.

systemctl status ntopng

Running Multiple Daemons

Multiple ntopng daemons can be run on the same machine when systemd is available. In general, this is not necessary as a single ntopng is multi-tenant and can handle multiple interfaces. However, there are circumstances under which it is desirable to have multiple ntopng instances running.

To run multiple ntopng daemons, systemctl can be used. Each daemon is identified by a <name> so that systemctl can be used with this identifier when controlling the daemon. For example:

systemctl start ntopng@eno1
systemctl stop ntopng@eno1
systemctl start ntopng@lo
systemctl stop ntopng@lo

Each daemon must have its own configuration file under /etc/ntopng and the configuration file name must be named as ntopng-<name>.conf. The example above assumes two files ntopng-eno1.conf and ntopng-lo.conf exist under /etc/ntopng.

In order to run multiple daemons on the same machine, each daemon must be guaranteed to have its own Redis database (option -r), its own HTTP/HTTPS ports (options -w and -W), and its own data directory (option -d). Those options must be specified in each daemon’s configuration file.

In order to start daemons on boot, it is necessary to enable them as

systemctl enable ntopng@eno1
systemctl enable ntopng@eno1

Daemons which have been enable d, will be automatically restarted after each ntopng update. Note that backup and restore of ntopng configuration is not supported when multiple daemons are in use.