← All guides

Show systemd Dependency Tree: systemctl list-dependencies

Updated:

Show systemd Dependency Tree: systemctl list-dependencies

Need to monitor systemd service dependencies on your Linux server? Want to track service dependencies, verify dependency health, and detect dependency failures automatically? This guide shows you how to monitor systemd service dependencies using built-in commands and automated monitoring with Zuzia.app.

For comprehensive service monitoring strategies, see Systemd Services & Dependencies Monitoring with systemctl. For troubleshooting dependency issues, see Systemd Service Dependency Failures.

Why Monitoring Service Dependencies Matters

Service dependencies determine which services must be running for other services to function correctly. When dependencies fail, dependent services can fail to start or become unstable. Monitoring service dependencies helps you detect dependency failures, prevent cascading service failures, maintain service reliability, and ensure critical services have their required dependencies available.

Method 1: List Service Dependencies

View service dependencies to understand service relationships:

View Service Dependencies

# Show service dependencies
systemctl list-dependencies service-name

# Show reverse dependencies (what depends on this service)
systemctl list-dependencies service-name --reverse

# Show all dependencies including inactive
systemctl list-dependencies service-name --all

# Show dependencies in tree format
systemctl list-dependencies service-name --tree

Check Dependency Status

# Check if required services are running
systemctl list-dependencies service-name --state=active

# View dependency requirements
systemctl show service-name -p Requires

# Check dependency wants
systemctl show service-name -p Wants

# Verify all dependencies are satisfied
systemctl check service-name

Method 2: Monitor Dependency Health

Monitor dependency health to ensure dependencies are available:

Check Dependency Status

# Check all dependencies for a service
for dep in $(systemctl show service-name -p Requires --value); do
  systemctl is-active $dep && echo "$dep: active" || echo "$dep: inactive"
done

# Verify dependency health
systemctl list-dependencies service-name --state=active | grep -v "service-name"

# Check for failed dependencies
systemctl list-dependencies service-name --state=failed

# Monitor dependency status continuously
watch -n 1 'systemctl list-dependencies service-name --state=active'

Track Dependency Changes

# Save current dependency list
systemctl list-dependencies service-name > /tmp/deps-$(date +%Y%m%d).txt

# Compare with previous dependencies
diff /tmp/deps-previous.txt /tmp/deps-current.txt

# Monitor dependency modifications
systemctl show service-name -p Requires,Wants,After

Method 3: Detect Dependency Failures

Detect dependency failures to prevent service issues:

Identify Failed Dependencies

# Check for failed dependencies
systemctl list-dependencies service-name --state=failed

# View dependency errors
systemctl status service-name | grep -A 10 "Dependency"

# Check dependency logs
journalctl -u service-name | grep -i "depend\|require"

# Verify dependency availability
for dep in $(systemctl show service-name -p Requires --value); do
  if ! systemctl is-active $dep > /dev/null; then
    echo "CRITICAL: Dependency $dep is not active"
  fi
done

Monitor Dependency Issues

# Check dependency health for critical services
for service in nginx mysql postgresql; do
  echo "Checking $service dependencies:"
  systemctl list-dependencies $service --state=active
done

# Verify all dependencies are running
systemctl list-dependencies service-name --state=active | wc -l

Method 4: Automated Dependency Monitoring with Zuzia.app

Checking services by hand works while you are logged in. Zuzia's agent keeps an eye on them when you are not.

How it works in Zuzia

  • Install the Zuzia agent on the server with one command. Zuzia discovers the systemd services on the host and shows their state.
  • Start, stop or restart any discovered service from the panel, without opening an SSH session.
  • Pick the services that matter and choose what happens when one stops: Zuzia only notifies you, or Autopilot (paid plans) restarts it and checks it came back. You can run Autopilot in dry-run first, or approve each restart from a link in your email.
  • For checks beyond systemd, save the commands from this guide as a scheduled task. If a command fails, you get an alert right away by email, Slack, Discord, push (through your Pushover account) or SMS (through your Vonage account).

Setting it up

  1. Add the server in the Zuzia dashboard and install the agent.
  2. Open the host's Services tab, pick the services to watch and choose notify or Autopilot.
  3. Choose your notification channels. Turn on maintenance mode during planned work so it doesn't trigger alerts.

Custom Dependency Monitoring Commands

Add these commands as scheduled tasks:

# Check service dependencies
systemctl list-dependencies service-name --state=active

# Verify critical dependencies
for dep in $(systemctl show nginx -p Requires --value); do
  systemctl is-active $dep && echo "$dep: OK" || echo "$dep: FAIL"
done

# Monitor dependency health
systemctl list-dependencies service-name --state=active | grep -v "^service-name"

Best Practices

1. Monitor Dependencies Continuously

Use Zuzia.app for continuous dependency monitoring. Set up alerts before dependency issues become critical. Review dependency status regularly.

2. Prioritize Critical Dependencies

Focus monitoring on business-critical services. Set up dedicated monitoring for critical dependencies. Configure immediate alerts for critical dependency failures.

3. Track Dependency Changes

Monitor dependency modifications over time. Compare current dependencies with baselines. Alert on dependency configuration changes.

Troubleshooting

Dependency Not Available

When dependencies are unavailable:

  1. Check dependency status: systemctl status dependency-name
  2. Start dependency if needed: systemctl start dependency-name
  3. Verify dependency health: systemctl is-active dependency-name

Service Fails Due to Dependencies

When services fail due to dependencies:

  1. Check dependency status: systemctl list-dependencies service-name --state=failed
  2. Review dependency logs: journalctl -u dependency-name
  3. Fix dependency issues before starting dependent service

FAQ

How often should I check service dependencies?

For production servers, check dependencies every 5-10 minutes. Zuzia.app can check dependencies automatically and alert when issues are detected.

What dependencies should I monitor?

Monitor dependencies for all production services, especially business-critical services. Focus on dependencies that affect service availability.

Can Zuzia.app detect dependency failures automatically?

Yes, Zuzia.app can detect dependency failures by checking dependency status, verifying dependency health, and alerting when dependencies are unavailable.

Related guides, recipes, and problems

We use cookies to ensure the proper functioning of our website.