ntopng

I have compiled and installed ntopng with ndpi. I am able to run ntopng as -

/usr/local/bin/ntopng /usr/local/etc/ntopng/ntopng.conf -r 0.0.0.0:6379

I want to know how to properly create the service file for ntopng, Here is my template -

[Unit]
Description=ntopng - Network Monitoring System
After=network.target syslog.target redis.service
Requires=

[Service]
Type=oneshot
ExecStart=/bin/sh -c /usr/local/etc/ntopng/ntopng.sh

[Install]
WantedBy=graphical.target multi-user.target


When I start the program via systemctl I see this -

[Wed Jul 24 21:52:52 root@linux-ayti /home/flux] 
# systemctl status ntopng
● ntopng.service - ntopng - Network Monitoring System
   Loaded: loaded (/usr/lib/systemd/system/ntopng.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Jul 24 21:46:56 linux-ayti sh[17926]: 24/Jul/2019 21:46:56 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
Jul 24 21:46:56 linux-ayti sh[17926]: 24/Jul/2019 21:46:56 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
Jul 24 21:46:57 linux-ayti sh[17926]: 24/Jul/2019 21:46:57 [Ntop.cpp:1849] Parent process is exiting (this is normal)
Jul 24 21:52:51 linux-ayti systemd[1]: Starting ntopng - Network Monitoring System...
Jul 24 21:52:51 linux-ayti sh[18022]: 24/Jul/2019 21:52:51 [Prefs.cpp:1110] ntopng will use redis 0.0.0.0@0
Jul 24 21:52:51 linux-ayti sh[18022]: 24/Jul/2019 21:52:51 [Ntop.cpp:1909] Setting local networks to 172.17.0.0/16
Jul 24 21:52:51 linux-ayti sh[18022]: 24/Jul/2019 21:52:51 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
Jul 24 21:52:51 linux-ayti sh[18022]: 24/Jul/2019 21:52:51 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
Jul 24 21:52:52 linux-ayti sh[18022]: 24/Jul/2019 21:52:52 [Ntop.cpp:1849] Parent process is exiting (this is normal)
Jul 24 21:52:52 linux-ayti systemd[1]: Started ntopng - Network Monitoring System.

The program doesn’t work and the journald doesn’t show any error -

Jul 24 21:46:56 linux-ayti systemd[1]: Started ntopng - Network Monitoring System.
Jul 24 21:46:56 linux-ayti sh[17926]: 24/Jul/2019 21:46:56 [Prefs.cpp:1110] ntopng will use redis 0.0.0.0@0
Jul 24 21:46:56 linux-ayti sh[17926]: 24/Jul/2019 21:46:56 [Ntop.cpp:1909] Setting local networks to 172.17.0.0/16
Jul 24 21:46:56 linux-ayti sh[17926]: 24/Jul/2019 21:46:56 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
Jul 24 21:46:56 linux-ayti sh[17926]: 24/Jul/2019 21:46:56 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
Jul 24 21:46:57 linux-ayti sh[17926]: 24/Jul/2019 21:46:57 [Ntop.cpp:1849] Parent process is exiting (this is normal)


# ps aux | grep ntopng
root     17881  0.0  0.0   8688   832 pts/1    S+   21:45   0:00 grep --color=auto ntopng

When I run the script from terminal it works -

[Wed Jul 24 22:37:20 root@linux-ayti /home/flux] 
# /bin/sh -c /usr/local/etc/ntopng/ntopng.sh
24/Jul/2019 22:37:24 [Prefs.cpp:1110] ntopng will use redis 0.0.0.0@0
24/Jul/2019 22:37:24 [Ntop.cpp:1909] Setting local networks to 172.17.0.0/16
24/Jul/2019 22:37:24 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
24/Jul/2019 22:37:24 [Redis.cpp:152] Successfully connected to redis 0.0.0.0:6379@0
24/Jul/2019 22:37:24 [Ntop.cpp:1849] Parent process is exiting (this is normal)

[Wed Jul 24 22:37:24 root@linux-ayti /home/flux] 
# ps aux | grep ntopng
ntopng   18940 20.1  2.7 1646528 225996 ?      Ssl  22:37   0:02 /usr/local/bin/ntopng /usr/local/etc/ntopng/ntopng.conf -r 0.0.0.0:6379
root     18999  0.0  0.0   8688   808 pts/1    S+   22:37   0:00 grep --color=auto ntopng

There is ntopng & ntopng-data package available but it is too complex, it doesn’t offer much configuration option & installs ‘redis@ntopng.service’ assuming user doesn’t have redis-server up & running. That recipe made simple things trivial.

Please let me know how to get service running, at the moment I am using crontab @reboot but that is not a proper approach.

Thanks.

I configured a root crontab and got ntopng working.