# glpi-project/glpi-agent architecture

> Architecture diagram of the GitHub repository glpi-project/glpi-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/glpi-project/glpi-agent
- Repository: https://github.com/glpi-project/glpi-agent

## Overview

##### Project type and purpose
- This is an open-source, cross-platform management agent ("GLPI Agent") written primarily in Perl (with a small Go subcommand).
- Its purpose is to run on endpoints (Windows, Linux, macOS, Unix variants, ESX hosts), perform inventory/discovery/deployment tasks, and communicate results back to a GLPI server or act standalone via a local web interface (“Toolbox”).

##### High-level architecture and file-structure cues
- Top-level “bin/” holds CLI entry points (glpi-agent, glpi-inventory, glpi-netdiscovery, glpi-injector, etc.).
- “lib/GLPI/Agent” contains the agent core, scheduler, configuration loader, task runners, protocol handlers (HTTP client/server, SNMP, SOAP).
- “etc/” holds default configuration files.
- “share/html” provides HTML templates and static assets for the embedded web UI (Toolbox).
- “contrib/”, “debian/”, “snap/”, “contrib/windows/” house packaging and installer scripts.
- “t/” contains extensive unit and integration tests.
- “src/cmd” holds a Go-based injector tool.
- CI workflows are defined under “.github/workflows/”.

a. Agent Core
- Configuration Loader (reads etc/*.cfg)
- Scheduler/Plan Engine (determines when tasks run)
- Plugin/Task Manager (dynamically loads Task modules under lib/GLPI/Agent/Task)
b. Task Modules (group into logical tiers)
- Inventory Tasks (OS/hardware profiling across AIX, BSD, Linux, Windows, macOS, Solaris, Virtualization, ESX)
- Network Discovery Tasks
- Network Inventory Tasks
- Deploy Task (file copy, scripts, P2P)
- WakeOnLan Task
- Remote Inventory Task (SSH, WinRM)
c. Communication & Protocol Layers
- HTTP Client (GLPI protocol, FusionInventory, OCS)
- HTTP Server (optional web UI, plugins: BasicAuth, Inventory, Toolbox API)
- SNMP Client
- SOAP Client (VMware WS-Man)
d. External Tools & Programs
- dmidecode, lspci, hdparm, arp, ip, powercfg, SNMP utilities, etc.
e. CLI Interfaces
- bin/glpi-agent (main daemon/foreground runner)
- Other bin/ scripts invoking specific tasks or installers
- glpi-injector (Go tool)
f. Packaging & Deployment Pipelines
- snapcraft.yaml (Snap)
- debian/* (deb packages, postinst scripts)
- contrib/windows MSI toolchain
- MacOSX packaging scripts (munkipkg, hdiutil)
- GitHub Actions workflows (.github/workflows/*.yml)
g. Testing & CI
- t/ (Perl test suites)
- .github Actions badges and pipelines

##### Relationships & data flows
- The Agent Core reads config → schedules Tasks → invokes Task modules → each Task may call External Tools or use internal Perl library to collect data → collected data flows into Protocol layer → HTTP Client sends to the GLPI Server (or FusionInventory endpoint) over HTTP/HTTPS.
- SNMP and SOAP modules interact directly with network devices or ESX hosts.
- CLI scripts wrap Agent Core or specific Task calls for ad-hoc operations.
- Packaging pipelines consume the codebase and produce platform installers.

##### Architectural patterns & principles
- Modular/Plugin architecture: Task types are organized under namespace lib/GLPI/Agent/Task, auto-loaded via UNIVERSAL::require.
- Separation of concerns: distinct layers for configuration, scheduling, task execution, communication, and UI.
- Strategy pattern: each Task implements well-defined interfaces for collect/deploy/discovery.
- Extensibility: new Task modules or protocol handlers can be added without touching core scheduler.

##### Detail level
- Be explicit: include all Task categories, external dependencies, packaging targets, and CI pipelines.
- Configuration inputs (etc/*.cfg) and resource directories (resources/) feeding Tasks.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Agent Core"
        Config["Configuration Loader"]:::core
        Daemon["Scheduler / Daemon"]:::core
        CoreMain["Agent Core"]:::core
    end

    subgraph "Task Modules"
        Base["Task Base"]:::tasks
        Inventory["Inventory Tasks"]:::tasks
        NetDiscovery["Network Discovery Tasks"]:::tasks
        NetInventory["Network Inventory Tasks"]:::tasks
        Deploy["Deploy Task"]:::tasks
        WOL["WakeOnLan Task"]:::tasks
        Remote["Remote Inventory Task"]:::tasks
        ESX["ESX Task"]:::tasks
    end

    subgraph "Protocol Layers"
        HTTPClient["HTTP Client"]:::protocol
        HTTPServer["HTTP Server"]:::protocol
        SNMP["SNMP Client"]:::protocol
        SOAP["SOAP Client"]:::protocol
    end

    subgraph "External Tools"
        Tools["External Tools"]:::external
    end

    subgraph "CLI Interfaces"
        AgentCLI["bin/glpi-agent"]:::cli
        InventoryCLI["bin/glpi-inventory"]:::cli
        NetDiscoveryCLI["bin/glpi-netdiscovery"]:::cli
        NetInventoryCLI["bin/glpi-netinventory"]:::cli
        DeployCLI["bin/glpi-deploy"]:::cli
        WOLCLI["bin/glpi-wakeonlan"]:::cli
        RemoteCLI["bin/glpi-remote"]:::cli
        ESXCLI["bin/glpi-esx"]:::cli
        InjectCLI["glpi-injector (Go)"]:::cli
    end

    subgraph "Web UI (Toolbox)"
        HTML["share/html/"]:::webui
    end

    subgraph "Configuration Files"
        ConfigFiles["etc/*.cfg"]:::external
    end

    subgraph "Packaging & Deployment"
        Snap["snap/snapcraft.yaml"]:::devops
        Deb["debian/"]:::devops
        Mac["contrib/macosx/"]:::devops
        Win["contrib/windows/"]:::devops
    end

    subgraph "CI & Testing"
        Workflows[".github/workflows/"]:::ci
        Tests["t/"]:::ci
        Fake["t/lib/fake/"]:::ci
    end

    ConfigFiles -->|reads| Config
    CoreMain -->|loads config| Config
    CoreMain -->|starts| Daemon
    Daemon -->|initializes| Base

    CoreMain --> Base
    CoreMain --> Inventory
    CoreMain --> NetDiscovery
    CoreMain --> NetInventory
    CoreMain --> Deploy
    CoreMain --> WOL
    CoreMain --> Remote
    CoreMain --> ESX

    Inventory -->|invoke external tools| Tools
    NetDiscovery -->|invoke external tools| Tools
    NetInventory -->|SNMP query| SNMP
    Deploy -->|invoke external tools| Tools
    WOL -->|invoke external tools| Tools
    Remote -->|invoke external tools| Tools
    ESX -->|invoke external tools| Tools

    Inventory -->|HTTP POST data| HTTPClient
    NetDiscovery -->|HTTP POST data| HTTPClient
    NetInventory -->|HTTP POST data| HTTPClient
    Deploy -->|HTTP POST result| HTTPClient
    Remote -->|HTTP POST data| HTTPClient
    ESX -->|WS-Man calls| SOAP

    HTTPClient -->|sends data| GLPIServer["Remote GLPI Server"]:::external
    Browser["Browser"]:::external -->|HTTP UI| HTTPServer
    HTTPServer -->|UI API calls| CoreMain

    AgentCLI -->|runs agent| CoreMain
    InventoryCLI -->|runs task| Inventory
    NetDiscoveryCLI -->|runs task| NetDiscovery
    NetInventoryCLI -->|runs task| NetInventory
    DeployCLI -->|runs task| Deploy
    WOLCLI -->|runs task| WOL
    RemoteCLI -->|runs task| Remote
    ESXCLI -->|runs task| ESX
    InjectCLI -->|runs injector| CoreMain

    CoreMain --> Snap
    CoreMain --> Deb
    CoreMain --> Mac
    CoreMain --> Win
    CoreMain --> Workflows
    CoreMain --> Tests
    Tests --> Fake

    click Config "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Config.pm"
    click Daemon "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Daemon.pm"
    click CoreMain "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent.pm"
    click Base "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task.pm"
    click Inventory "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/Task/Inventory/"
    click NetDiscovery "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/NetDiscovery.pm"
    click NetDiscovery "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/Task/NetDiscovery/"
    click NetInventory "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/NetInventory.pm"
    click NetInventory "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/Task/NetInventory/"
    click Deploy "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/Deploy.pm"
    click Deploy "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/Task/Deploy/"
    click WOL "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/WakeOnLan.pm"
    click Remote "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/RemoteInventory.pm"
    click Remote "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/Task/RemoteInventory/"
    click ESX "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/ESX.pm"
    click ESX "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/Task/ESX/"
    click HTTPClient "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/HTTP/Client/"
    click HTTPServer "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/HTTP/Server/"
    click SNMP "https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/SNMP.pm"
    click SNMP "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/SNMP/"
    click SOAP "https://github.com/glpi-project/glpi-agent/tree/develop/lib/GLPI/Agent/SOAP/"
    click Tools "https://github.com/glpi-project/glpi-agent/tree/develop/resources/"
    click AgentCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-agent"
    click InventoryCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-inventory"
    click NetDiscoveryCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-netdiscovery"
    click NetInventoryCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-netinventory"
    click DeployCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-deploy"
    click WOLCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-wakeonlan"
    click RemoteCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-remote"
    click ESXCLI "https://github.com/glpi-project/glpi-agent/tree/develop/bin/glpi-esx"
    click InjectCLI "https://github.com/glpi-project/glpi-agent/blob/develop/src/cmd/glpi-injector/main.go"
    click HTML "https://github.com/glpi-project/glpi-agent/tree/develop/share/html/"
    click ConfigFiles "https://github.com/glpi-project/glpi-agent/blob/develop/etc/agent.cfg"
    click Snap "https://github.com/glpi-project/glpi-agent/blob/develop/snap/snapcraft.yaml"
    click Deb "https://github.com/glpi-project/glpi-agent/tree/develop/debian/"
    click Mac "https://github.com/glpi-project/glpi-agent/tree/develop/contrib/macosx/"
    click Win "https://github.com/glpi-project/glpi-agent/tree/develop/contrib/windows/"
    click Workflows "https://github.com/glpi-project/glpi-agent/tree/develop/.github/workflows/"
    click Tests "https://github.com/glpi-project/glpi-agent/tree/develop/t/"
    click Fake "https://github.com/glpi-project/glpi-agent/tree/develop/t/lib/fake/"

    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef tasks fill:#90EE90,stroke:#000,stroke-width:1px
    classDef protocol fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef cli fill:#D8BFD8,stroke:#000,stroke-width:1px
    classDef devops fill:#D8BFD8,stroke:#000,stroke-width:1px
    classDef webui fill:#AFEEEE,stroke:#000,stroke-width:1px
    classDef ci fill:#FFC0CB,stroke:#000,stroke-width:1px
```
