2.8 KiB
2.8 KiB
Multi-Agent Sysadmin Assistant
A modular multi-agent system for system administration tasks using LangChain and LangGraph.
Architecture
The system is organized into several modules for better maintainability:
📁 Project Structure
multi-agent-supervisor/
├── main-multi-agent.py # Main entry point
├── config.py # Configuration and settings
├── supervisor.py # Supervisor orchestration
├── utils.py # Utility functions
├── requirements.txt # Dependencies
├── custom_tools/ # Custom tool implementations
│ ├── __init__.py
│ ├── log_tail_tool.py # Log reading tool
│ └── shell_tool_wrapper.py # Shell tool wrapper
└── agents/ # Agent definitions
├── __init__.py
├── system_agents.py # System monitoring agents
├── service_agents.py # Service-specific agents
├── network_agents.py # Network and security agents
└── analysis_agents.py # Analysis and remediation agents
Agents
System Agents
- System Info Worker: Gathers CPU, RAM, and disk usage
- Service Inventory Worker: Lists running services
Service Agents
- MariaDB Analyzer: Checks MariaDB configuration and logs
- Nginx Analyzer: Validates Nginx configuration and logs
- PHP-FPM Analyzer: Monitors PHP-FPM status and performance
Network Agents
- Network Diagnostics: Uses ping, traceroute, and dig
- Certificate Checker: Monitors TLS certificate expiration
Analysis Agents
- Risk Scorer: Aggregates findings and assigns severity levels
- Remediation Worker: Proposes safe fixes for issues
- Harmonizer Worker: Applies system hardening best practices
Benefits of Modular Architecture
- Separation of Concerns: Each module has a single responsibility
- Reusability: Tools and agents can be easily reused across projects
- Maintainability: Easy to update individual components
- Testability: Each module can be tested independently
- Scalability: Easy to add new agents or tools
- Code Organization: Clear structure makes navigation easier
Usage
from supervisor import create_sysadmin_supervisor
# Create supervisor with all agents
supervisor = create_sysadmin_supervisor()
# Run analysis
query = {
"messages": [
{
"role": "user",
"content": "Check if my web server is running properly"
}
]
}
result = supervisor.invoke(query)
Adding New Agents
- Create agent function in appropriate module under
agents/
- Import and add to supervisor in
supervisor.py
- Update supervisor prompt in
config.py
Adding New Tools
- Create tool class in
custom_tools/
- Export from
custom_tools/__init__.py
- Import and use in agent definitions