Skip to main content
Glama

check_failed_services

Identify and diagnose failed systemd services to troubleshoot system issues on systemd-based systems.

Instructions

[MONITORING] Check for failed systemd services. Useful for diagnosing system issues. Works on systemd-based systems.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that implements the tool logic: checks if systemctl exists, runs 'systemctl --failed --no-pager', parses the output to extract failed services, and returns a structured dictionary with count, list of services, and all_ok flag.
    async def check_failed_services() -> Dict[str, Any]: """ Detect failed systemd services. Returns: Dict with list of failed services """ if not check_command_exists("systemctl"): return create_error_response( "NotSupported", "systemctl not available (systemd-based system required)" ) logger.info("Checking for failed services") try: exit_code, stdout, _ = await run_command( ["systemctl", "--failed", "--no-pager"], timeout=10, check=False ) # Parse output failed_services = [] lines = stdout.strip().split('\n') for line in lines: # Skip header and footer lines if line.startswith('ā—') or line.startswith('UNIT'): continue if 'loaded units listed' in line.lower(): continue # Parse service line parts = line.split() if parts and parts[0].endswith('.service'): failed_services.append({ "unit": parts[0], "load": parts[1] if len(parts) > 1 else "", "active": parts[2] if len(parts) > 2 else "", "sub": parts[3] if len(parts) > 3 else "", }) logger.info(f"Found {len(failed_services)} failed services") return { "failed_count": len(failed_services), "failed_services": failed_services, "all_ok": len(failed_services) == 0 } except Exception as e: logger.error(f"Failed to check services: {e}") return create_error_response( "ServiceCheckError", f"Failed to check failed services: {str(e)}" )
  • MCP tool registration defining the tool name, description, and input schema (empty object since no parameters). This makes the tool discoverable via list_tools().
    name="check_failed_services", description="[MONITORING] Check for failed systemd services. Useful for diagnosing system issues. Works on systemd-based systems.", inputSchema={ "type": "object", "properties": {} } ),
  • Tool dispatch handler in call_tool() that invokes the check_failed_services function and returns the result as formatted JSON text content.
    elif name == "check_failed_services": result = await check_failed_services() return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Input schema definition: empty properties object indicating the tool takes no parameters.
    "type": "object", "properties": {} } ),
  • Tool metadata providing categorization, platform requirements, permissions, workflow context, and related tools for better tool discovery and usage guidance.
    "check_failed_services": ToolMetadata( name="check_failed_services", category="monitoring", platform="systemd", permission="read", workflow="diagnose", related_tools=["get_boot_logs", "get_system_info"], prerequisite_tools=[]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nihalxkumar/arch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server