Systemd for voipmonitor service management: Difference between revisions
(Review: zkrácení AI Summary sekce) |
(Rewrite: konsolidace a vylepšení struktury - zjednodušeno z 384 na 177 řádků) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
[[Category:Installation]] | [[Category:Installation]] | ||
'''This guide | '''This guide covers managing the VoIPmonitor sensor service using systemd on modern Linux distributions.''' | ||
{{Warning|1='''Always use <code>systemctl</code> commands.''' Do not use the legacy <code>service</code> command as systemd may lose track of the process state.}} | |||
{{Warning|1='''Always use <code>systemctl</code> commands | |||
== Unit File Configuration == | == Unit File Configuration == | ||
Create | Create <code>/etc/systemd/system/voipmonitor.service</code>: | ||
<syntaxhighlight lang="ini"> | <syntaxhighlight lang="ini"> | ||
[Unit] | [Unit] | ||
Description=VoIPmonitor sniffer | Description=VoIPmonitor sniffer | ||
After=syslog.target | After=syslog.target network.target | ||
# Add mysql.service only if DB is local (see Dependencies below) | |||
[Service] | [Service] | ||
Type=forking | Type=forking | ||
RemainAfterExit=yes | |||
TimeoutSec=5min | TimeoutSec=5min | ||
KillMode=process | KillMode=process | ||
GuessMainPID=no | GuessMainPID=no | ||
IgnoreSIGPIPE=no | |||
SuccessExitStatus=5 6 | SuccessExitStatus=5 6 | ||
ExecStart=/etc/init.d/voipmonitor start | ExecStart=/etc/init.d/voipmonitor start | ||
| Line 39: | Line 33: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | === Dependencies === | ||
{| class="wikitable" | |||
|- | |||
! Scenario !! Add to [Unit] section | |||
|- | |||
| '''Local MySQL/MariaDB''' || <code>After=mysql.service</code> | |||
|- | |||
| '''Napatech SmartNIC''' || <code>After=ntservice.service</code><br/><code>Requires=ntservice.service</code><br/><code>Wants=network-pre.target</code><br/><code>Before=network-pre.target</code> | |||
|} | |||
< | |||
</ | |||
== | == Basic Commands == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# After any unit file changes | |||
systemctl daemon-reload | systemctl daemon-reload | ||
# Enable auto-start on boot | |||
systemctl enable voipmonitor | systemctl enable voipmonitor | ||
# Start/Stop/Restart | |||
# Start | |||
systemctl start voipmonitor | systemctl start voipmonitor | ||
systemctl stop voipmonitor | systemctl stop voipmonitor | ||
systemctl restart voipmonitor | systemctl restart voipmonitor | ||
# Check status | # Check status | ||
systemctl status voipmonitor | systemctl status voipmonitor | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == Watchdog Integration == | ||
When using the internal watchdog with systemd, configure it to restart via systemctl. Otherwise, systemd will incorrectly report the service as "failed" after a watchdog-triggered restart. | |||
Add to <code>/etc/voipmonitor.conf</code>: | |||
=== | <syntaxhighlight lang="ini"> | ||
watchdog = yes | |||
watchdog_run_command = systemctl restart voipmonitor | |||
</syntaxhighlight> | |||
== Controlling Verbose Output == | |||
By default, VoIPmonitor outputs statistics to syslog every 10 seconds (controlled by <code>-v 1</code> in the init.d script). | |||
=== | === Option 1: Redirect to Dedicated Log (Recommended) === | ||
Add to <code>/etc/rsyslog.conf</code>: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="rsyslog"> | ||
if $programname == 'voipmonitor' then /var/log/voipmonitor.log | |||
& ~ | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Then: <code>systemctl restart rsyslog</code> | |||
=== Option 2: Disable Statistics Entirely === | |||
{{Warning|This removes valuable diagnostic metrics. Only use if necessary.}} | |||
Edit <code>/etc/init.d/voipmonitor</code>, find the <code>ARGS=</code> line, and remove <code>-v 1</code> (or <code>v 1</code>): | |||
# | <syntaxhighlight lang="text"> | ||
/etc/ | # Before: | ||
ARGS="-v 1 --config-file /etc/voipmonitor.conf" | |||
# | # After: | ||
/etc/ | ARGS="--config-file /etc/voipmonitor.conf" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | Then: <code>systemctl daemon-reload && systemctl restart voipmonitor</code> | ||
== Troubleshooting == | |||
=== Unit File Syntax Errors === | |||
'''Symptom:''' "Assignment outside of section" or "control process exited with error code" | |||
'''Fix:''' Check unit file for: | |||
* Missing section headers (<code>[Unit]</code>, <code>[Service]</code>, <code>[Install]</code>) | |||
* Typos in directive names | |||
* Missing <code>=</code> signs | |||
'''Emergency bypass:''' | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl daemon-reload | killall -9 voipmonitor | ||
systemctl start voipmonitor | /etc/init.d/voipmonitor start | ||
# Fix unit file, then: | |||
systemctl daemon-reload && systemctl start voipmonitor | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | === Multiple Instances Running (Duplicate Packets, Corrupted RRD) === | ||
'''Symptom:''' Duplicate SIP packets in GUI, broken RRD graphs, multiple voipmonitor processes | |||
'''Cause:''' Both systemd unit and init.d wrapper trying to start VoIPmonitor | |||
'''Fix:''' | |||
<syntaxhighlight lang="bash"> | |||
# 1. Kill all instances | |||
sudo killall -9 voipmonitor | |||
# 2. Disable init.d wrapper (keeps script but prevents auto-start) | |||
sudo chmod -x /etc/init.d/voipmonitor | |||
# 3. Delete corrupted RRD files | |||
sudo rm -f /var/spool/voipmonitor/rrd/* | |||
# 4. Start via systemd | |||
sudo systemctl enable voipmonitor | |||
sudo systemctl start voipmonitor | |||
# 5. Verify single instance | |||
ps aux | grep "[v]oipmonitor" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Note|1=The <code>chmod -x</code> disables the SysV compatibility service that systemd auto-generates from init.d scripts.}} | |||
=== | === Connection Failures (Service Running but Not Connecting) === | ||
If <code>systemctl status voipmonitor</code> shows "active (running)" but logs show connection errors, the problem is not systemd-related. See [[Sniffer_distributed_architecture#Troubleshooting|Distributed Architecture Troubleshooting]]. | |||
== See Also == | |||
* [[Sniffer_configuration]] - Full configuration reference | |||
* [[Sniffer_installation]] - Installation guide | |||
* [[Multiple_sniffer_instancies]] - Running multiple sensors on one host | |||
== AI Summary for RAG == | == AI Summary for RAG == | ||
'''Summary:''' Guide for managing VoIPmonitor sensor with systemd | '''Summary:''' Guide for managing VoIPmonitor sensor with systemd. Create unit file at <code>/etc/systemd/system/voipmonitor.service</code> with <code>Type=forking</code> and <code>RemainAfterExit=yes</code>. Key dependencies: add <code>After=mysql.service</code> for local DB only, add <code>After=ntservice.service</code> with <code>Requires=ntservice.service</code> for Napatech cards. Always use <code>systemctl</code> commands (not legacy <code>service</code>). For watchdog integration, set <code>watchdog_run_command = systemctl restart voipmonitor</code> to prevent systemd from showing failed status after watchdog restarts. For multiple instance conflicts (duplicate packets, corrupted RRD), run <code>chmod -x /etc/init.d/voipmonitor</code> to disable the init.d wrapper, delete RRD files, and restart via systemd. For verbose log spam (every 10 seconds), either redirect via rsyslog or remove <code>-v 1</code> from the init.d ARGS line. | ||
'''Keywords:''' systemd, systemctl, voipmonitor.service | '''Keywords:''' systemd, systemctl, voipmonitor.service, unit file, Type=forking, RemainAfterExit, After=mysql.service, Napatech, ntservice, daemon-reload, watchdog, watchdog_run_command, multiple instances, duplicate packets, corrupted RRD, chmod -x, verbose output, syslog spam, -v 1, rsyslog | ||
'''Key Questions:''' | '''Key Questions:''' | ||
* What is the recommended systemd unit file for VoIPmonitor? | * What is the recommended systemd unit file for VoIPmonitor? | ||
* How do I configure systemd dependencies for MySQL and Napatech? | * How do I configure systemd dependencies for MySQL and Napatech? | ||
* How do I make VoIPmonitor start automatically on boot? | * How do I make VoIPmonitor start automatically on boot? | ||
* Why does systemd show service as failed after watchdog restart? | * Why does systemd show service as failed after watchdog restart? | ||
* | * How do I fix multiple voipmonitor processes running (duplicate packets, corrupted RRD)? | ||
* How do I stop init.d and systemd from conflicting? | |||
* How do I disable or redirect the verbose statistics output to syslog? | |||
Latest revision as of 16:48, 8 January 2026
This guide covers managing the VoIPmonitor sensor service using systemd on modern Linux distributions.
⚠️ Warning: Always use systemctl commands. Do not use the legacy service command as systemd may lose track of the process state.
Unit File Configuration
Create /etc/systemd/system/voipmonitor.service:
[Unit]
Description=VoIPmonitor sniffer
After=syslog.target network.target
# Add mysql.service only if DB is local (see Dependencies below)
[Service]
Type=forking
RemainAfterExit=yes
TimeoutSec=5min
KillMode=process
GuessMainPID=no
IgnoreSIGPIPE=no
SuccessExitStatus=5 6
ExecStart=/etc/init.d/voipmonitor start
ExecStop=/etc/init.d/voipmonitor stop
PrivateTmp=false
[Install]
WantedBy=multi-user.target
Dependencies
| Scenario | Add to [Unit] section |
|---|---|
| Local MySQL/MariaDB | After=mysql.service
|
| Napatech SmartNIC | After=ntservice.serviceRequires=ntservice.serviceWants=network-pre.targetBefore=network-pre.target
|
Basic Commands
# After any unit file changes
systemctl daemon-reload
# Enable auto-start on boot
systemctl enable voipmonitor
# Start/Stop/Restart
systemctl start voipmonitor
systemctl stop voipmonitor
systemctl restart voipmonitor
# Check status
systemctl status voipmonitor
Watchdog Integration
When using the internal watchdog with systemd, configure it to restart via systemctl. Otherwise, systemd will incorrectly report the service as "failed" after a watchdog-triggered restart.
Add to /etc/voipmonitor.conf:
watchdog = yes
watchdog_run_command = systemctl restart voipmonitor
Controlling Verbose Output
By default, VoIPmonitor outputs statistics to syslog every 10 seconds (controlled by -v 1 in the init.d script).
Option 1: Redirect to Dedicated Log (Recommended)
Add to /etc/rsyslog.conf:
if $programname == 'voipmonitor' then /var/log/voipmonitor.log
& ~Then: systemctl restart rsyslog
Option 2: Disable Statistics Entirely
⚠️ Warning: This removes valuable diagnostic metrics. Only use if necessary.
Edit /etc/init.d/voipmonitor, find the ARGS= line, and remove -v 1 (or v 1):
# Before:
ARGS="-v 1 --config-file /etc/voipmonitor.conf"
# After:
ARGS="--config-file /etc/voipmonitor.conf"
Then: systemctl daemon-reload && systemctl restart voipmonitor
Troubleshooting
Unit File Syntax Errors
Symptom: "Assignment outside of section" or "control process exited with error code"
Fix: Check unit file for:
- Missing section headers (
[Unit],[Service],[Install]) - Typos in directive names
- Missing
=signs
Emergency bypass:
killall -9 voipmonitor
/etc/init.d/voipmonitor start
# Fix unit file, then:
systemctl daemon-reload && systemctl start voipmonitor
Multiple Instances Running (Duplicate Packets, Corrupted RRD)
Symptom: Duplicate SIP packets in GUI, broken RRD graphs, multiple voipmonitor processes
Cause: Both systemd unit and init.d wrapper trying to start VoIPmonitor
Fix:
# 1. Kill all instances
sudo killall -9 voipmonitor
# 2. Disable init.d wrapper (keeps script but prevents auto-start)
sudo chmod -x /etc/init.d/voipmonitor
# 3. Delete corrupted RRD files
sudo rm -f /var/spool/voipmonitor/rrd/*
# 4. Start via systemd
sudo systemctl enable voipmonitor
sudo systemctl start voipmonitor
# 5. Verify single instance
ps aux | grep "[v]oipmonitor"
ℹ️ Note: The chmod -x disables the SysV compatibility service that systemd auto-generates from init.d scripts.
Connection Failures (Service Running but Not Connecting)
If systemctl status voipmonitor shows "active (running)" but logs show connection errors, the problem is not systemd-related. See Distributed Architecture Troubleshooting.
See Also
- Sniffer_configuration - Full configuration reference
- Sniffer_installation - Installation guide
- Multiple_sniffer_instancies - Running multiple sensors on one host
AI Summary for RAG
Summary: Guide for managing VoIPmonitor sensor with systemd. Create unit file at /etc/systemd/system/voipmonitor.service with Type=forking and RemainAfterExit=yes. Key dependencies: add After=mysql.service for local DB only, add After=ntservice.service with Requires=ntservice.service for Napatech cards. Always use systemctl commands (not legacy service). For watchdog integration, set watchdog_run_command = systemctl restart voipmonitor to prevent systemd from showing failed status after watchdog restarts. For multiple instance conflicts (duplicate packets, corrupted RRD), run chmod -x /etc/init.d/voipmonitor to disable the init.d wrapper, delete RRD files, and restart via systemd. For verbose log spam (every 10 seconds), either redirect via rsyslog or remove -v 1 from the init.d ARGS line.
Keywords: systemd, systemctl, voipmonitor.service, unit file, Type=forking, RemainAfterExit, After=mysql.service, Napatech, ntservice, daemon-reload, watchdog, watchdog_run_command, multiple instances, duplicate packets, corrupted RRD, chmod -x, verbose output, syslog spam, -v 1, rsyslog
Key Questions:
- What is the recommended systemd unit file for VoIPmonitor?
- How do I configure systemd dependencies for MySQL and Napatech?
- How do I make VoIPmonitor start automatically on boot?
- Why does systemd show service as failed after watchdog restart?
- How do I fix multiple voipmonitor processes running (duplicate packets, corrupted RRD)?
- How do I stop init.d and systemd from conflicting?
- How do I disable or redirect the verbose statistics output to syslog?