services.json. The configuration supports multiple service types including web servers, databases, and system services.
Overview
Services are configured indata/services.json with check commands and running indicators. Sentinel AI periodically executes these commands to verify service health.
Default Monitor Interval: 30 seconds (configured via
MONITOR_INTERVAL in config.py)Service Configuration File
The services file is located atdata/services.json and is automatically loaded on startup:
Service Schema
Each service requires three properties:Shell command to check service status. Executed via SSH on the target server.Examples:
service nginx statussystemctl status postgresqldocker ps | grep my-container/usr/local/bin/check_custom_service.sh
String pattern to search for in command output that indicates the service is running.Examples:
is runningactive (running)onlineStatus: healthy
The check is case-sensitive and uses substring matching. If this string is found in the command output, the service is considered healthy.
Service category for organization and reporting.Common types:
web_server- Nginx, Apache, Caddydatabase- PostgreSQL, MySQL, MongoDBsystem- SSH, cron, systemd servicesapplication- Custom applicationscontainer- Docker containerscache- Redis, Memcached
Default Services
Sentinel AI includes three default services defined insrc/core/config.py:
Managing Services
Adding Services
Use theadd_service() method to add new services:
The
add_service() method automatically saves changes to data/services.json.Removing Services
Remove services using theremove_service() method:
Updating Services
To update a service, remove and re-add it:Service Examples
Web Servers
Databases
Docker Containers
Custom Applications
Service Types
Organize services by type for better reporting and management:Web Servers
Nginx, Apache, Caddy, Traefik
Databases
PostgreSQL, MySQL, MongoDB, Redis
System Services
SSH, cron, systemd, networking
Containers
Docker containers and services
Applications
Custom applications and APIs
Cache Services
Redis, Memcached, Varnish
Health Check Patterns
Service Command
Traditional service status check:is running, running, active
Systemctl Command
Systemd service manager:active (running), active, SubState=running
Docker Commands
Container status checks:Up, running, healthy
Custom Scripts
Use custom health check scripts:Best Practices
Use Specific Indicators
Choose unique running indicators that won’t appear in error messages. Use
active (running) instead of just active.Test Commands Manually
Test each check command via SSH before adding to services.json to ensure it works correctly.
Keep Commands Fast
Avoid slow commands that could delay monitoring. Aim for sub-second execution time.
Handle Edge Cases
Consider services that might be stopped intentionally. Use service types to group related checks.
Document Dependencies
Note service dependencies in your services.json comments (if using JSONC) or separate docs.
Version Control
Keep services.json in version control to track configuration changes over time.
Advanced Configuration
Multi-Host Services
Monitor the same service across multiple hosts:Service Dependencies
Track service dependencies for intelligent recovery:Custom Health Checks
Implement application-specific health checks:Monitoring and Alerts
Sentinel AI monitors services at regular intervals (default: 30 seconds):Monitoring Behavior
- Status Check: Execute
check_commandvia SSH - Pattern Match: Search output for
running_indicator - Health Decision: Service is healthy if indicator is found
- Recovery: If unhealthy, attempt automated remediation
- Retry Logic: Up to
MAX_RETRIESattempts with exponential backoff
Troubleshooting
Service Always Shows as Down
Service Always Shows as Down
Problem: Service health check always fails even when service is running.Solutions:
- Test the check command manually via SSH:
ssh user@host 'service nginx status' - Verify the
running_indicatorstring appears in the output - Check that the SSH user has permission to run the check command
- Look for case sensitivity issues in the indicator string
Services Not Loading
Services Not Loading
Problem: Services from services.json are not being monitored.Solutions:
- Verify
data/services.jsonexists and is valid JSON - Check file permissions:
ls -la data/services.json - Review startup logs for JSON parsing errors
- Test JSON validity:
python -m json.tool data/services.json
Permission Denied During Checks
Permission Denied During Checks
Problem: Health checks fail with “Permission denied” errors.Solutions:
- Configure sudoers to allow check commands without password
- Add SSH user to appropriate groups (docker, systemd-journal)
- See SSH Setup for details
Slow Health Checks
Slow Health Checks
Problem: Monitoring interval is delayed due to slow check commands.Solutions:
- Use faster status check methods (e.g.,
systemctl is-activeinstead ofsystemctl status) - Avoid commands that require DNS lookups or network calls
- Consider increasing
MONITOR_INTERVALif checks can’t be optimized - Use timeout flags:
timeout 5 service nginx status
API Reference
Configuration Methods
Next Steps
SSH Setup
Configure SSH authentication and permissions
AI Models
Customize AI model settings and behavior
Deployment
Deploy Sentinel AI with Docker
Monitoring
Learn about service monitoring features