Skip to main content
Glama

run_system_health_check

Read-only

Run a comprehensive system health check on Arch Linux, diagnosing disk space, failed services, updates, orphan packages, and critical news.

Instructions

[MONITORING] Run a comprehensive system health check. Integrates multiple diagnostics to provide a complete overview of system status, including disk space, failed services, updates, orphan packages, and more. Only works on Arch Linux. Comprehensive check: Updates available, disk space, failed services, database freshness, orphans, and critical news.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function `run_system_health_check()` that executes the comprehensive system health check. It integrates multiple diagnostics: system info, disk space, failed services, pacman cache, updates, critical news, orphan packages, database freshness, and mirror health. Returns a dict with status, issues, suggestions, and a summary.
    async def run_system_health_check() -> Dict[str, Any]:
        """
        Run a comprehensive system health check.
        
        This function integrates multiple system diagnostics to provide a complete
        overview of the system's health status in a single call.
        
        Returns:
            Dict with comprehensive health check results
        """
        from .system import (
            get_system_info,
            check_disk_space,
            check_failed_services,
            get_pacman_cache_stats
        )
        from .pacman import (
            check_updates_dry_run,
            list_orphan_packages,
            check_database_freshness
        )
        from .news import check_critical_news
        from .mirrors import check_mirrorlist_health
        
        logger.info("Starting comprehensive system health check")
        
        health_report = {
            "status": "success",
            "system_info": {},
            "disk_space": {},
            "services": {},
            "pacman_cache": {},
            "updates": {},
            "news": {},
            "orphans": {},
            "database": {},
            "mirrors": {},
            "issues": [],
            "suggestions": []
        }
        
        try:
            # System information
            logger.info("Checking system information")
            system_info = await get_system_info()
            health_report["system_info"] = system_info
            
            # Disk space check
            logger.info("Checking disk space")
            disk_space = await check_disk_space()
            health_report["disk_space"] = disk_space
            
            # Check for low disk space
            if disk_space.get("status") == "success":
                for partition in disk_space.get("data", []):
                    if partition.get("used_percent", 0) > 90:
                        health_report["issues"].append({
                            "type": "critical",
                            "message": f"Low disk space on {partition['mount_point']}: {partition['used_percent']}% used",
                            "suggestion": "Clean up unnecessary files or resize the partition"
                        })
                    elif partition.get("used_percent", 0) > 80:
                        health_report["issues"].append({
                            "type": "warning",
                            "message": f"Disk space getting low on {partition['mount_point']}: {partition['used_percent']}% used",
                            "suggestion": "Consider cleaning up files to free up space"
                        })
            
            # Failed services check
            logger.info("Checking for failed services")
            failed_services = await check_failed_services()
            health_report["services"] = failed_services
            
            if failed_services.get("status") == "success" and failed_services.get("data"):
                health_report["issues"].append({
                    "type": "warning",
                    "message": f"{len(failed_services['data'])} failed systemd services detected",
                    "suggestion": "Check systemd journal logs for details about failed services"
                })
            
            # Pacman cache statistics
            logger.info("Checking pacman cache")
            cache_stats = await get_pacman_cache_stats()
            health_report["pacman_cache"] = cache_stats
            
            if cache_stats.get("status") == "success":
                cache_size = cache_stats.get("data", {}).get("total_size_mb", 0)
                if cache_size > 5000:  # 5GB
                    health_report["suggestions"].append({
                        "message": f"Pacman cache is large ({cache_size:.1f}MB)",
                        "action": "Run 'paccache -r' to clean old packages"
                    })
            
            # Updates check
            logger.info("Checking for available updates")
            updates = await check_updates_dry_run()
            health_report["updates"] = updates
            
            if updates.get("status") == "success":
                if updates.get("updates_available"):
                    count = updates.get("count", 0)
                    health_report["suggestions"].append({
                        "message": f"{count} updates available",
                        "action": "Run 'sudo pacman -Syu' to update the system"
                    })
            
            # Critical news check
            logger.info("Checking for critical news")
            critical_news = await check_critical_news()
            health_report["news"] = critical_news
            
            if critical_news.get("status") == "success" and critical_news.get("data"):
                health_report["issues"].append({
                    "type": "critical",
                    "message": f"{len(critical_news['data'])} critical news items require attention",
                    "suggestion": "Review the news items before updating"
                })
            
            # Orphan packages check
            logger.info("Checking for orphan packages")
            orphans = await list_orphan_packages()
            health_report["orphans"] = orphans
            
            if orphans.get("status") == "success":
                orphan_count = len(orphans.get("data", []))
                if orphan_count > 0:
                    health_report["suggestions"].append({
                        "message": f"{orphan_count} orphan packages detected",
                        "action": "Run 'sudo pacman -Rns $(pacman -Qtdq)' to remove orphans"
                    })
            
            # Database freshness
            logger.info("Checking database freshness")
            db_freshness = await check_database_freshness()
            health_report["database"] = db_freshness
            
            # Mirrorlist health
            logger.info("Checking mirrorlist health")
            mirror_health = await check_mirrorlist_health()
            health_report["mirrors"] = mirror_health
            
            if mirror_health.get("status") == "success":
                if not mirror_health.get("data", {}).get("healthy", True):
                    health_report["issues"].append({
                        "type": "warning",
                        "message": "Mirrorlist configuration has issues",
                        "suggestion": "Run 'reflector' to update your mirrorlist"
                    })
            
            # Overall health assessment
            issue_count = len(health_report["issues"])
            suggestion_count = len(health_report["suggestions"])
            
            health_report["summary"] = {
                "total_issues": issue_count,
                "critical_issues": len([i for i in health_report["issues"] if i["type"] == "critical"]),
                "warnings": len([i for i in health_report["issues"] if i["type"] == "warning"]),
                "suggestions": suggestion_count
            }
            
            logger.info(f"Health check completed: {issue_count} issues, {suggestion_count} suggestions")
            
            return health_report
            
        except Exception as e:
            logger.error(f"Health check failed: {e}")
            return {
                "status": "error",
                "error": str(e),
                "issues": [],
                "suggestions": [],
                "summary": {
                    "total_issues": 1,
                    "critical_issues": 1,
                    "warnings": 0,
                    "suggestions": 0
                }
            }
  • Tool registration in the MCP server's `call_tool()` handler. Maps the name 'run_system_health_check' to the actual async function. Includes Arch Linux platform check before execution.
    elif name == "run_system_health_check":
        if not IS_ARCH:
            return [TextContent(type="text", text=create_platform_error_message("run_system_health_check"))]
        
        result = await run_system_health_check()
        return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Tool definition in `list_tools()` – registers the tool with name 'run_system_health_check', description, empty inputSchema, and readOnly annotation.
    Tool(
        name="run_system_health_check",
        description="[MONITORING] Run a comprehensive system health check. Integrates multiple diagnostics to provide a complete overview of system status, including disk space, failed services, updates, orphan packages, and more. Only works on Arch Linux. Comprehensive check: Updates available, disk space, failed services, database freshness, orphans, and critical news.",
        inputSchema={
            "type": "object",
            "properties": {}
        },
        annotations=ToolAnnotations(readOnlyHint=True)
    ),
  • ToolMetadata definition for 'run_system_health_check' specifying category='monitoring', platform='arch', permission='read', workflow='diagnose', and related tools.
    "run_system_health_check": ToolMetadata(
        name="run_system_health_check",
        category="monitoring",
        platform="arch",
        permission="read",
        workflow="diagnose",
        related_tools=[
            "get_system_info",
            "analyze_storage",
            "check_failed_services",
            "check_updates_dry_run",
            "check_critical_news",
            "manage_orphans",
            "check_database_freshness",
            "optimize_mirrors"
        ],
        prerequisite_tools=[]
    ),
  • Import of `run_system_health_check` from the system_health_check module, making it available as a public API.
    from .system_health_check import run_system_health_check
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds context beyond the readOnlyHint annotation by listing the specific diagnostics included, but it does not disclose other behavioral traits such as potential performance impact or required permissions. The annotation already indicates no destructive side effects, so the description's added value is moderate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is relatively concise with three sentences, front-loading the purpose. The last sentence repeats some content, but overall it is efficient and structured appropriately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters or output schema, the description fully explains the tool's purpose, scope, and constraints. It covers all necessary context for a monitoring tool with read-only behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has no parameters, so the description does not need to explain them. The baseline for 0 parameters is 4, and the description is adequate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Run a comprehensive system health check' with a specific verb and resource. It distinguishes itself from sibling tools (e.g., analyze_storage, check_database_freshness) by being a combined diagnostic that integrates multiple checks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly notes 'Only works on Arch Linux' and lists the checks it performs (disk space, failed services, updates, etc.), which helps the agent decide when to use this comprehensive tool versus more specific sibling tools. However, it does not explicitly mention when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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-linux-mcp'

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