Systemd for voipmonitor service management: Difference between revisions
(Add troubleshooting for multiple VoIPmonitor instances (init.d vs systemd conflict causing duplicate packets and corrupted RRD)) |
(Add section on controlling verbose statistics output (removing -v 1 from init.d)) |
||
| Line 103: | Line 103: | ||
systemctl status voipmonitor | systemctl status voipmonitor | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Controlling Verbose Statistics Output == | |||
By default, the VoIPmonitor sensor outputs detailed performance statistics to the system log every 10 seconds. This is controlled by the <code>-v 1</code> argument in the init.d startup script. | |||
=== Reducing Syslog Spam with Log Filtering (Recommended) === | |||
Instead of disabling statistics entirely (which removes valuable diagnostic information), redirect VoIPmonitor logs to a dedicated log file: | |||
Edit <code>/etc/rsyslog.conf</code> and add at the top: | |||
<syntaxhighlight lang="rsyslog"> | |||
# Send all messages from the 'voipmonitor' program to a dedicated file | |||
if $programname == 'voipmonitor' then /var/log/voipmonitor.log | |||
# Stop processing these messages further to avoid duplication | |||
& ~ | |||
</syntaxhighlight> | |||
Restart rsyslog: | |||
<syntaxhighlight lang="bash"> | |||
systemctl restart rsyslog | |||
</syntaxhighlight> | |||
=== Disabling Periodic Statistics Output === | |||
To completely disable the periodic statistics output, modify the init.d script: | |||
{{Warning|Disabling verbose output removes important real-time performance metrics. Only do this if absolutely necessary for log management reasons.}} | |||
1. Edit the init.d script: | |||
<syntaxhighlight lang="bash"> | |||
nano /etc/init.d/voipmonitor | |||
</syntaxhighlight> | |||
2. Locate the <code>ARGS=</code> line and remove the <code>-v 1</code> argument: | |||
<syntaxhighlight lang="text"> | |||
# Before: | |||
ARGS="-v 1 --config-file /etc/voipmonitor.conf" | |||
# After: | |||
ARGS="--config-file /etc/voipmonitor.conf" | |||
</syntaxhighlight> | |||
3. Reload systemd and restart the service: | |||
<syntaxhighlight lang="bash"> | |||
systemctl daemon-reload | |||
systemctl restart voipmonitor | |||
</syntaxhighlight> | |||
You can also remove <code>v 1</code> (with space instead of dash) if that is the format in your script. | |||
For detailed information about interpreting the performance statistics, see the '''VoIPmonitor Sensor Performance Monitoring''' documentation in your support resources. | |||
== Troubleshooting == | == Troubleshooting == | ||
| Line 313: | Line 365: | ||
== AI Summary for RAG == | == AI Summary for RAG == | ||
'''Summary:''' Guide for managing VoIPmonitor sensor with systemd by wrapping the init.d script in a unit file. Configuration uses <code>Type=forking</code> with <code>RemainAfterExit=yes</code>. Key dependencies: <code>After=mysql.service</code> for local DB, <code>After=ntservice.service</code> with <code>Requires=ntservice.service</code> for Napatech. Always use <code>systemctl</code> commands (not legacy <code>service</code>) for reliable process tracking. For watchdog integration, set <code>watchdog_run_command = systemctl restart voipmonitor</code> to prevent systemd from incorrectly reporting failed status after watchdog-triggered restarts. For multiple instance conflicts (duplicate packets, corrupted RRD), remove execute permission from <code>/etc/init.d/voipmonitor</code> (<code>chmod -x</code>) to prevent systemd from auto-starting the init.d wrapper, then delete corrupted RRD files and restart with <code>systemctl start voipmonitor</code>. | '''Summary:''' Guide for managing VoIPmonitor sensor with systemd by wrapping the init.d script in a unit file. Configuration uses <code>Type=forking</code> with <code>RemainAfterExit=yes</code>. Key dependencies: <code>After=mysql.service</code> for local DB, <code>After=ntservice.service</code> with <code>Requires=ntservice.service</code> for Napatech. Always use <code>systemctl</code> commands (not legacy <code>service</code>) for reliable process tracking. For watchdog integration, set <code>watchdog_run_command = systemctl restart voipmonitor</code> to prevent systemd from incorrectly reporting failed status after watchdog-triggered restarts. For multiple instance conflicts (duplicate packets, corrupted RRD), remove execute permission from <code>/etc/init.d/voipmonitor</code> (<code>chmod -x</code>) to prevent systemd from auto-starting the init.d wrapper, then delete corrupted RRD files and restart with <code>systemctl start voipmonitor</code>. For controlling verbose periodic statistics output (which prints to syslog every 10 seconds by default), redirect logs using rsyslog filtering or edit <code>/etc/init.d/voipmonitor</code> to remove <code>-v 1</code> or <code>v 1</code> from the ARGS line, then run <code>systemctl daemon-reload</code> and <code>systemctl restart voipmonitor</code>. | ||
'''Keywords:''' systemd, systemctl, voipmonitor.service, init.d wrapper, unit file, Type=forking, RemainAfterExit, After=mysql.service, Napatech, daemon-reload, watchdog, watchdog_run_command, service management, multiple instances, duplicate packets, corrupted RRD | '''Keywords:''' systemd, systemctl, voipmonitor.service, init.d wrapper, unit file, Type=forking, RemainAfterExit, After=mysql.service, Napatech, daemon-reload, watchdog, watchdog_run_command, service management, multiple instances, duplicate packets, corrupted RRD, verbose output, statistics, syslog, period status line, rsyslog, log filtering, -v 1, disable verbose, ARGS line | ||
'''Key Questions:''' | '''Key Questions:''' | ||
| Line 328: | Line 380: | ||
* Multiple voipmonitor processes running - how to fix duplicate packets and corrupted RRD? | * Multiple voipmonitor processes running - how to fix duplicate packets and corrupted RRD? | ||
* How do I stop init.d and systemd from conflicting and starting multiple VoIPmonitor instances? | * How do I stop init.d and systemd from conflicting and starting multiple VoIPmonitor instances? | ||
* How do I disable the periodic verbose statistics output to syslog? | |||
* How do I stop VoIPmonitor from printing status lines every 10 seconds? | |||
* How do I reduce syslog spam from voipmonitor statistics? | |||
Revision as of 19:43, 7 January 2026
This guide provides the recommended method for managing the VoIPmonitor sensor service using systemd on modern Linux distributions.
Overview
Modern Linux distributions (Debian, Ubuntu, CentOS, RHEL, AlmaLinux) use systemd as the primary service manager. The recommended approach is to create a systemd unit file that wraps the reliable /etc/init.d/voipmonitor script, ensuring compatibility across various distributions.
⚠️ Warning: Always use systemctl commands to manage the service. Do not use the legacy service command (e.g., service voipmonitor start) as systemd may lose track of the process state.
Unit File Configuration
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
PrivateTmp=false
[Install]
WantedBy=multi-user.target
Dependency Customization
MySQL/MariaDB
The line After=mysql.service is only required if the database is installed locally on the same server. If your database runs on a remote server, you can remove this line.
Napatech Cards
If you use Napatech hardware acceleration cards, add the following lines to the [Unit] section to ensure drivers load before VoIPmonitor starts:
Before=network-pre.target
Wants=network-pre.target
After=ntservice.service
Requires=ntservice.service
Activation and Management
Reload systemd after changes
systemctl daemon-reload
Enable start on boot
systemctl enable voipmonitor
Standard management commands
# Start the service
systemctl start voipmonitor
# Stop the service
systemctl stop voipmonitor
# Restart the service
systemctl restart voipmonitor
# Check status and view recent logs
systemctl status voipmonitor
Controlling Verbose Statistics Output
By default, the VoIPmonitor sensor outputs detailed performance statistics to the system log every 10 seconds. This is controlled by the -v 1 argument in the init.d startup script.
Reducing Syslog Spam with Log Filtering (Recommended)
Instead of disabling statistics entirely (which removes valuable diagnostic information), redirect VoIPmonitor logs to a dedicated log file:
Edit /etc/rsyslog.conf and add at the top:
# Send all messages from the 'voipmonitor' program to a dedicated file
if $programname == 'voipmonitor' then /var/log/voipmonitor.log
# Stop processing these messages further to avoid duplication
& ~Restart rsyslog:
systemctl restart rsyslog
Disabling Periodic Statistics Output
To completely disable the periodic statistics output, modify the init.d script:
⚠️ Warning: Disabling verbose output removes important real-time performance metrics. Only do this if absolutely necessary for log management reasons.
1. Edit the init.d script:
nano /etc/init.d/voipmonitor
2. Locate the ARGS= line and remove the -v 1 argument:
# Before:
ARGS="-v 1 --config-file /etc/voipmonitor.conf"
# After:
ARGS="--config-file /etc/voipmonitor.conf"
3. Reload systemd and restart the service:
systemctl daemon-reload
systemctl restart voipmonitor
You can also remove v 1 (with space instead of dash) if that is the format in your script.
For detailed information about interpreting the performance statistics, see the VoIPmonitor Sensor Performance Monitoring documentation in your support resources.
Troubleshooting
Service Not Starting vs Connection Failures
Before troubleshooting systemd issues, identify whether the problem is with the systemd service OR with network connectivity:
| Problem Type | Symptoms | Solution |
|---|---|---|
| Service fails to start | systemctl start voipmonitor returns error, service shows failed status |
Continue with this guide |
| Service starts but cannot connect | Service shows active (running) but logs show "cannot connect to server" |
See Distributed Architecture Troubleshooting |
Unit File Syntax Errors
If you encounter errors like:
Error: Assignment outside of section. Ignoring.
Job for voipmonitor.service failed because the control process exited with error code.
This indicates syntax errors in the unit file. To bypass and fix:
# 1. Identify existing processes
ps aux | grep voipmonitor
# 2. Kill the watchdog process first (find its PID from ps output)
kill <PID_WATCHDOG>
# 3. Kill the main voipmonitor process
kill -9 <PID_VOIPMONITOR>
# 4. Stop using init.d script
/etc/init.d/voipmonitor stop
# 5. Start using init.d script (bypasses broken systemd unit)
/etc/init.d/voipmonitor start
Common Unit File Errors
- Missing
[Unit],[Service], or[Install]section headers - Assignments placed outside of their proper sections
- Typos in directive names (e.g.,
ExecStarinstead ofExecStart) - Missing equals (
=) signs between directive and value
After fixing the unit file:
systemctl daemon-reload
systemctl start voipmonitor
Multiple VoIPmonitor Processes Running
If you see multiple voipmonitor processes running simultaneously, or if the GUI shows duplicate SIP packets and corrupted RRD (Round-Robin Database) statistics, you may have a service manager conflict. This commonly occurs when both the legacy init.d script and the systemd service attempt to start VoIPmonitor at the same time.
⚠️ Warning: Multiple VoIPmonitor instances writing to the same RRD files simultaneously will immediately corrupt the statistics data. Do not ignore this problem until RRD graphs display correctly.
Symptoms
- Duplicate SIP packets appearing in the GUI for the same call
- RRD graphs showing errors or missing data
- Multiple
voipmonitorprocesses inps aux | grep voipmonitor - GUI may show higher-than-expected call counts or inconsistent statistics
Root Cause
On modern systems (Ubuntu 20.04+, Debian 10+), systemd is the default init system. However, systemd automatically generates services for existing /etc/init.d scripts. If both a native systemd unit file (/etc/systemd/system/voipmonitor.service) and the init.d wrapper service are enabled, both attempt to start VoIPmonitor simultaneously.
Step 1: Stop All Running Processes
First, stop all voipmonitor processes to prevent ongoing RRD corruption:
# Force-kill all voipmonitor processes
sudo killall -9 voipmonitor
# Verify no processes remain
ps aux | grep voipmonitor
Step 2: Identify Conflicting Services
Determine which services are enabled and conflicting:
# Check for systemd unit files
systemctl list-unit-files | grep voipmonitor
# Check for init.d script existence
ls -l /etc/init.d/voipmonitor
# Check enabled systemd services
systemctl is-enabled voipmonitor.service
Step 3: Disable the Redundant init.d Wrapper
The recommended approach is to use the native systemd unit file (documented above). To prevent the init.d wrapper from starting VoIPmonitor automatically while keeping the script available for manual use, remove the execute permission:
# Remove execute permission from init.d script (prevents systemd from auto-starting it)
sudo chmod -x /etc/init.d/voipmonitor
# Verify permissions are now removed
ls -l /etc/init.d/voipmonitor
ℹ️ Note: This disables the SysV compatibility service generated by systemd from the /etc/init.d/voipmonitor script. The script remains available for manual execution if needed, but systemd will no longer attempt to start it automatically.
Step 4: Corrupted RRD Files
Multiple instances writing to the same RRD files simultaneously cause immediate corruption. The corrupted RRD files must be deleted so the single, correctly-running instance can regenerate them with clean data.
See RRD Graph Errors Troubleshooting for complete instructions. The short version:
# Stop the service first if it's still running
systemctl stop voipmonitor
# Delete all corrupted RRD files (safe operation - files will be regenerated)
sudo rm -f /var/spool/voipmonitor/rrd/*
# Restart the service
systemctl start voipmonitor
Step 5: Restart with systemd
Now start the service using the correct systemd method:
# Enable systemd service (ensures it starts on boot)
sudo systemctl enable voipmonitor
# Start the service
sudo systemctl start voipmonitor
# Verify it's running correctly
sudo systemctl status voipmonitor
Step 6: Verify Single Instance
# Check that only one main process is running (ignore grep output and threads)
ps aux | grep "[v]oipmonitor"
You should see only a single main process (possibly with multiple threads/worker processes), not multiple independent instances.
💡 Tip: After fixing the service conflict, always use systemctl commands (start, stop, restart, status) to manage VoIPmonitor. Do not use the legacy service voipmonitor start or direct /etc/init.d/voipmonitor start commands, as this may cause systemd to lose track of the process and create conflicts.
Verification Steps
1. Make a test SIP call and verify only ONE CDR record appears in the GUI
2. Navigate to Settings > Sensor and confirm status shows "Active (running)" with green indicator
3. Check RRD graphs after a few minutes - data should be displaying without errors
4. Monitor process count with ps aux | grep "[v]oipmonitor" to ensure only one instance persists
Internal Watchdog and SystemD
When using SystemD to manage the VoIPmonitor service, there is a potential issue if the internal watchdog restarts the VoIPmonitor process. By default, the internal watchdog may attempt to restart the binary directly. When this happens, the main process ID (PID) tracked by SystemD exits, causing SystemD to mark the service as "failed" or "dead," even though a new process has been spawned.
⚠️ Warning: If the internal watchdog is enabled but not configured to use SystemD for restarts, the SystemD service status will incorrectly show the service as failed after a watchdog-triggered restart.
Configuring the Watchdog to Use SystemD
To ensure that SystemD correctly tracks the service status after a watchdog-triggered restart, edit the /etc/voipmonitor.conf file:
- Enable the watchdog (if not already enabled):
watchdog = yes
- Add the following line to make the watchdog use SystemD for restarts:
watchdog_run_command = systemctl restart voipmonitor
Why This Works
Setting watchdog_run_command forces the watchdog to hand over the restart process to SystemD via systemctl restart. This ensures that SystemD manages the entire stop/start cycle, keeps its internal state tracking consistent, and correctly reports the service as active (running) after a watchdog-triggered restart.
Verification
After configuration, you can verify that SystemD correctly tracks the service:
# Check service status
systemctl status voipmonitor
# Service should show "active (running)" not "failed" or "dead"
AI Summary for RAG
Summary: Guide for managing VoIPmonitor sensor with systemd by wrapping the init.d script in a unit file. Configuration uses Type=forking with RemainAfterExit=yes. Key dependencies: After=mysql.service for local DB, After=ntservice.service with Requires=ntservice.service for Napatech. Always use systemctl commands (not legacy service) for reliable process tracking. For watchdog integration, set watchdog_run_command = systemctl restart voipmonitor to prevent systemd from incorrectly reporting failed status after watchdog-triggered restarts. For multiple instance conflicts (duplicate packets, corrupted RRD), remove execute permission from /etc/init.d/voipmonitor (chmod -x) to prevent systemd from auto-starting the init.d wrapper, then delete corrupted RRD files and restart with systemctl start voipmonitor. For controlling verbose periodic statistics output (which prints to syslog every 10 seconds by default), redirect logs using rsyslog filtering or edit /etc/init.d/voipmonitor to remove -v 1 or v 1 from the ARGS line, then run systemctl daemon-reload and systemctl restart voipmonitor.
Keywords: systemd, systemctl, voipmonitor.service, init.d wrapper, unit file, Type=forking, RemainAfterExit, After=mysql.service, Napatech, daemon-reload, watchdog, watchdog_run_command, service management, multiple instances, duplicate packets, corrupted RRD, verbose output, statistics, syslog, period status line, rsyslog, log filtering, -v 1, disable verbose, ARGS line
Key Questions:
- What is the recommended systemd unit file for VoIPmonitor?
- Why should I use
systemctlinstead of theservicecommand? - How do I configure systemd dependencies for MySQL and Napatech?
- How do I make VoIPmonitor start automatically on boot?
- How do I bypass a broken systemd unit file?
- What causes "Assignment outside of section" error in systemd?
- Why does systemd show service as failed after watchdog restart?
- What should I set
watchdog_run_commandto when using systemd? - Multiple voipmonitor processes running - how to fix duplicate packets and corrupted RRD?
- How do I stop init.d and systemd from conflicting and starting multiple VoIPmonitor instances?
- How do I disable the periodic verbose statistics output to syslog?
- How do I stop VoIPmonitor from printing status lines every 10 seconds?
- How do I reduce syslog spam from voipmonitor statistics?