# nvidia/nvidia-monitor-eventing architecture

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

- Interactive diagram: https://gitdiagram.com/nvidia/nvidia-monitor-eventing
- Repository: https://github.com/nvidia/nvidia-monitor-eventing

## Overview

##### Project type and purpose
- This is a C++-based Linux system daemon suite (“nvidia-monitor-eventing”) for device monitoring and eventing on OpenBMC platforms.
- It comprises two primary runtime services— the main Eventing Daemon and a Device Health Service—plus a rich ecosystem of support libraries, command-line tools, and build/deploy scripts.

##### File structure
- Top-level build and config:
- Dockerfile, buildenv scripts, Meson build files (meson.build, meson_options.txt)
- config/eventing_config.h.in
- Core services:
- src/ and include/ – implementation and headers for the Eventing Daemon
- device-health-service/ – standalone service with its own meson.build
- Third-party libraries (subprojects): googletest, phosphor-logging, sdbusplus, sdeventplus
- Documentation (doc/), examples/, and a huge suite of tools/ (Python, shell, C++ utilities)
- Automated tests under test/

##### README
- Environment setup (OpenBMC SDK, Cygwin, Docker) and Meson/Ninja build steps

##### Main components and their interactions
a. Build & Deployment Layer
- Meson/Ninja build system
- buildenv / Docker container for isolated builds
- OpenBMC SDK as external dependency
b. Core Eventing Daemon
- eventing_main: bootstrap & sdeventplus main loop
- config_parser: read JSON schemas & configs
- data_accessor / dat_traverse: load hardware Data Access Table (DAT)
- json_proc / json_schema: JSON validation & processing
- event_detection: monitor incoming raw events (MCTP, logs)
- event_instantiator: create internal event objects
- event_handler: apply rules, enrich or filter events
- message_composer: build DBus messages (using sdbusplus APIs)
- message_dispatcher: send messages over the system bus
- logging (phosphor-logging) and threadpool for concurrency
c. Device Health Service
- Similar modular design; listens on DBus, aggregates device health, publishes status
d. External Interfaces
- system dbus (sdbusplus)
- hardware message transports (MCTP, TAL)
- OpenBMC environment & diagnostic frameworks

##### Architectural patterns and design principles
- Modular “pipeline” of plugins: each stage (parse → detect → handle → compose → dispatch) is a separate component
- Publisher‐subscriber model using D-Bus as the event bus
- Dependency injection via singleton/accessor patterns (dbus_singleton, tal_singleton)
- Config-driven behavior with JSON schemas

- Rectangles for services/modules
- Parallelograms for scripts/tools
- Build (gray), Core Daemons (blue), Infrastructure (green), Tools/Tests (light orange)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Deployment Layer
    subgraph "Build & Deployment Layer"
        direction TB
        Meson["Meson/Ninja Build System"]:::build
        Docker["Docker/buildenv"]:::build
        SDK["OpenBMC SDK"]:::build
    end

    %% Core Eventing Daemon
    subgraph "Core Eventing Daemon Services"
        direction TB
        EM["eventing_main (src/eventing_main.cpp)"]:::core
        CP["config_parser (src/config_parser.cpp)"]:::core
        DT["dat_traverse (src/dat_traverse.cpp)"]:::core
        DA["data_accessor (src/data_accessor.cpp)"]:::core
        JP["json_proc (src/json_proc.cpp)"]:::core
        JS["json_schema (src/json_schema.cpp)"]:::core
        ED["event_detection (src/event_detection.cpp)"]:::core
        EI["event_instantiator (src/event_instantiator.cpp)"]:::core
        EH["event_handler (src/event_handler.cpp)"]:::core
        MC["message_composer (src/message_composer.cpp)"]:::core
        MD["message_dispatcher (src/message_dispatcher.cpp)"]:::core
        LG["log & threadpool (src/log.cpp)"]:::core
    end

    %% Device Health Service
    subgraph "Device Health Service"
        direction TB
        DHS["Device Health Service (device-health-service/device_health_service.cpp)"]:::core
        DBA["DBus Adapter (device-health-service/dbus.cpp)"]:::core
        DS["Data Structures (device-health-service/data_structures.cpp)"]:::core
    end

    %% Infrastructure & External
    subgraph "Infrastructure & External Interfaces"
        direction TB
        SE["sdeventplus Event Loop"]:::infra
        SB["sdbusplus / DBus System Bus"]:::infra
        HW["Hardware Transports (MCTP, TAL)"]:::infra
    end

    %% Utilities & Testing
    subgraph "Utilities & Testing"
        direction TB
        TO["Tools & Scripts (tools/)"]:::tools
        TE["Tests (test/)"]:::tools
        EX["Examples & Docs (doc/, examples/)"]:::tools
    end

    %% Build dependencies
    Docker -->|isolated build| Meson
    Meson -->|builds| EM
    Meson -->|builds| DHS

    %% Startup flow
    EM -->|"initialize"| CP
    CP -->|load DAT| DT
    CP -->|load DAT| DA
    EM -->|start loop| SE

    %% Runtime event flow
    HW -->|raw events| ED
    ED -->|"instantiate"| EI
    EI -->|"to handler"| EH
    EH -->|"compose"| MC
    MC -->|"dispatch"| MD
    MD -->|to DBus| SB

    %% Concurrency and Logging
    LG -->|logging & threads| EM
    LG -->|logging & threads| EH

    %% Device Health Service flow
    SB -->|listen| DBA
    DBA -->|health data| DHS
    DHS -->|publish| SB

    %% Utilities connections
    TO -.-> Meson
    TE -.-> Meson
    EX -.-> CP

    %% Click Events
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./meson.build"
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./meson_options.txt"
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./config/meson.build"
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./include/meson.build"
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/meson.build"
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./device-health-service/meson.build"
    click Meson "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./tools/meson.build"
    click Docker "https://github.com/nvidia/nvidia-monitor-eventing/tree/develop/./Dockerfile"
    click Docker "https://github.com/nvidia/nvidia-monitor-eventing/tree/develop/./buildenv/"
    click EM "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/eventing_main.cpp"
    click CP "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/config_parser.cpp"
    click DT "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/dat_traverse.cpp"
    click DA "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/data_accessor.cpp"
    click JP "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/json_proc.cpp"
    click JS "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/json_schema.cpp"
    click ED "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/event_detection.cpp"
    click EI "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/event_instantiator.cpp"
    click EH "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/event_handler.cpp"
    click MC "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/message_composer.cpp"
    click MD "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/message_dispatcher.cpp"
    click LG "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./src/log.cpp"
    click DHS "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./device-health-service/device_health_service.cpp"
    click DBA "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./device-health-service/dbus.cpp"
    click DS "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./device-health-service/data_structures.cpp"
    click SB "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./subprojects/sdbusplus.wrap"
    click SE "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./subprojects/sdeventplus.wrap"
    click EX "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./examples/event_info-schema.json"
    click EX "https://github.com/nvidia/nvidia-monitor-eventing/blob/develop/./doc/config_parser.md"

    %% Styles
    classDef build fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef core fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef infra fill:#90EE90,stroke:#333,stroke-width:1px
    classDef tools fill:#FFDAB9,stroke:#333,stroke-width:1px
```
