ssh_service_status
Check the operational status of specified services on a remote server to monitor system health and availability.
Instructions
Check status of services on remote server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | Server name | |
| services | Yes | Service names to check (e.g., nginx, mysql, docker) |
Implementation Reference
- src/tool-registry.js:31-38 (registration)'ssh_service_status' is registered in the monitoring tool group, used for conditional tool enablement based on user configuration.monitoring: [ 'ssh_health_check', 'ssh_service_status', 'ssh_process_manager', 'ssh_monitor', 'ssh_tail', 'ssh_alert_setup' ],
- src/health-monitor.js:171-191 (helper)Helper function to build shell command for checking service status, supporting both systemd and legacy sysv init systems.export function buildServiceStatusCommand(serviceName) { // Try systemd first, fallback to sysv return ` if command -v systemctl >/dev/null 2>&1; then systemctl is-active ${serviceName} 2>/dev/null >/dev/null && echo "ACTIVE" || echo "INACTIVE" systemctl is-enabled ${serviceName} 2>/dev/null >/dev/null && echo "ENABLED" || echo "DISABLED" systemctl status ${serviceName} 2>/dev/null | grep "Main PID" | awk '{print $3}' | cut -d'(' -f1 systemctl status ${serviceName} 2>/dev/null | grep "Active:" | sed 's/.*Active: //' | awk '{print $1,$2,$3}' elif command -v service >/dev/null 2>&1; then service ${serviceName} status >/dev/null 2>&1 && echo "ACTIVE" || echo "INACTIVE" echo "UNKNOWN" pgrep -f ${serviceName} | head -1 || echo "" echo "sysv" else echo "UNKNOWN" echo "UNKNOWN" echo "" echo "no-init-system" fi `.trim(); }
- src/health-monitor.js:196-208 (helper)Helper function to parse service status command output into structured data including status, enabled state, PID, and health assessment.export function parseServiceStatus(output, serviceName) { const lines = output.trim().split('\n'); const [status, enabled, pid, details] = lines; return { name: serviceName, status: status === 'ACTIVE' ? 'running' : 'stopped', enabled: enabled === 'ENABLED' ? 'yes' : enabled === 'DISABLED' ? 'no' : 'unknown', pid: pid && pid !== '' ? parseInt(pid) : null, details: details || 'unknown', health: status === 'ACTIVE' ? HEALTH_STATUS.HEALTHY : HEALTH_STATUS.CRITICAL }; }