Systemd for voipmonitor service management

From VoIPmonitor.org
Revision as of 15:39, 30 July 2025 by Festr (talk | contribs)
Jump to navigation Jump to search

systemd

This is valid only for system that use systemd as manager for services.

beware of use the service command

We don't recommend to use the service command in systemd environment for manage the sniffer service state!! The systemd can lose track of the sensor daemon.

systemd's service file for voipmonitor

Create file /etc/systemd/system/voipmonitor.service [Unit] Description=VoIPmonitor sniffer After=syslog.target After=network.target After=mysql.service

[Service] Type=forking Restart=no TimeoutSec=5min IgnoreSIGPIPE=no KillMode=process GuessMainPID=no RemainAfterExit=yes SuccessExitStatus=5 6 ExecStart=/etc/init.d/voipmonitor start ExecStop=/etc/init.d/voipmonitor stop

  1. Place temp files in a secure directory, not /tmp?

PrivateTmp=false [Install] WantedBy=multi-user.target

service file and db host

NOTICE: line 'After=mysql.service' gives a sense only if your mysql is installed locally.

service file and napatech drivers

Add into service file follwing lines to make sure napatech drivers are initialized before start of the sniffer service. Before=network-pre.target Wants=network-pre.target After=ntservice.service Requires=ntservice.service

reload systemd

Don't forget systemd reload after change. systemctl daemon-reload

toto je puvodni wikimedia stranka

a toto je nova wikimedia stranka


This guide provides the modern, recommended method for managing the VoIPmonitor sensor service using systemd. A properly configured systemd unit file ensures that the sensor starts correctly on boot and can be managed reliably with standard system commands.

Overview

Modern Linux distributions (including recent versions of Debian, Ubuntu, CentOS, RHEL, and AlmaLinux) use systemd as the primary service manager. While the legacy /etc/init.d/voipmonitor script may still work, creating a dedicated systemd unit file is a more robust and reliable approach. It provides better dependency management, process tracking, and integration with system logging.

Warning: It is strongly recommended to use the systemctl command exclusively to manage the service. Using the older service command (e.g., service voipmonitor start) can cause systemd to lose track of the process's state.

Step 1: Create the systemd Unit File

Create a new service file for VoIPmonitor using a text editor:

sudo nano /etc/systemd/system/voipmonitor.service


Copy and paste the following content into the file. This template is a modern replacement for the old init.d script and calls the binary directly.

[Unit]
Description=VoIPmonitor Sniffer Service
Wants=network-online.target
After=network-online.target syslog.target

# --- Optional: Add dependencies below if needed ---
# After=mysql.service mariadb.service       # If the database is on the same server
# After=ntservice.service                   # If you use Napatech cards

[Service]
Type=simple
User=root
Group=root

# The command to start the sniffer.
# The -f flag is important to keep the process in the foreground for systemd.
ExecStart=/usr/local/sbin/voipmonitor -f -c /etc/voipmonitor.conf

# Restart the service automatically if it fails
Restart=on-failure
RestartSec=5s

# It's good practice to define a clean stop command
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target


Step 2: Optional Customizations

The provided template should work for most installations. However, if you have a special setup, you may need to uncomment or add dependency lines in the [Unit] section.

If the database runs on the same server
Uncommenting After=mysql.service mariadb.service ensures that VoIPmonitor will only start after the database service is fully up and running.
If you use Napatech hardware acceleration cards
Uncommenting After=ntservice.service ensures the Napatech driver service is started before VoIPmonitor attempts to use the card.

Step 3: Reload systemd and Enable the Service

After creating or modifying the unit file, you must tell systemd to reload its configuration.

sudo systemctl daemon-reload


Next, enable the service to ensure it starts automatically every time the server boots.

sudo systemctl enable voipmonitor.service


Step 4: Managing the Service

You can now manage the VoIPmonitor sensor using the standard systemctl commands.

To start the service
sudo systemctl start voipmonitor


To stop the service
sudo systemctl stop voipmonitor


To restart the service after a configuration change
sudo systemctl restart voipmonitor


To check the current status and view recent logs
sudo systemctl status voipmonitor


To disable the service from starting on boot
sudo systemctl disable voipmonitor


AI Summary for RAG

Summary: This guide provides a best-practice tutorial for managing the VoIPmonitor sensor service using systemd on modern Linux distributions. It explains why using systemctl is superior to the legacy service command and init.d scripts. The core of the article is a modern, recommended voipmonitor.service unit file template that calls the sniffer binary directly with the -f flag to run it in the foreground. The guide is structured as a step-by-step process: 1) Creating the /etc/systemd/system/voipmonitor.service file. 2) Explaining optional customizations, such as adding dependencies for a local MySQL/MariaDB database or Napatech drivers. 3) Reloading the systemd daemon and enabling the service to start on boot with systemctl daemon-reload and systemctl enable. 4) Listing and explaining the standard systemctl commands (start, stop, restart, status) for day-to-day service management. Keywords: systemd, systemctl, service, daemon, init.d, unit file, voipmonitor.service, start on boot, enable, restart, status, dependency, After=, Wants=, ExecStart, Type=simple Key Questions:

How do I manage the VoIPmonitor sniffer service on a modern Linux system?

What is the correct systemd unit file for VoIPmonitor?

How do I make the VoIPmonitor sensor start automatically on boot?

Why shouldn't I use the service voipmonitor start command?

How can I make the VoIPmonitor service wait for the MySQL database to be ready before starting?

What is the difference between an init.d script and a systemd service file?

How do I check the status and logs of the sniffer service with systemctl?

a pise mi kolega:

Ahoj, tenhle service file mi funguje na almaliux 9.5 ten novy (upraveny) nespusti sluzbu: (overil jsem a svem almalinux 9.5)

potrebuju, abys mi tu wikimedia stranku opravil tak, aby se to drzelo toho puvodniho, ktery fungoval - dej mi to opet ve wikimedia formatu