← All guides

Check Service Dependency Health with systemctl

Updated:

Check Service Dependency Health with systemctl

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

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

Why Checking Service Dependency Health Matters

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

Method 1: Check Dependency Status

Check dependency status to verify dependencies are available:

View Service Dependencies

# Show service dependencies
systemctl list-dependencies service-name

# Show reverse dependencies
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

Verify Dependency Health

# 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'

Method 2: Detect Dependency Failures

Detect dependency failures to identify problematic dependencies:

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 3: Monitor Dependency Health

Monitor dependency health to ensure dependencies remain healthy:

Track Dependency Status

# 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

Verify Dependency Configuration

# 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

# View dependency tree
systemctl list-dependencies service-name --tree

Method 4: Automated Dependency Health Monitoring with Zuzia.app

Manual checks work while you are looking. To keep running them without you, Zuzia uses its agent and scheduled tasks.

How it works in Zuzia

  • Install the Zuzia agent on the server with one command. CPU, RAM, disk, load and network metrics start reporting on their own, with alerts on a threshold, on drift from the server's normal, or on a disk fill-up forecast.
  • Save the commands from this guide as a scheduled task and choose how often it runs, from every minute to once a year. The agent runs it on every host you pick.
  • 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).
  • The output of every run is kept, so you can look back at what changed. On paid plans, AI can read the output and alert you only when it spots a problem.

Setting it up

  1. Add the server in the Zuzia dashboard and install the agent.
  2. Create a scheduled task with the check commands below, then choose the hosts and how often it runs.
  3. Choose your notification channels. Turn on maintenance mode during planned work so it doesn't trigger alerts.

Custom Dependency Health 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 Dependency Health Continuously

Use Zuzia.app for continuous dependency health 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 dependency health?

For production servers, check dependency health 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.