Skip to content

Repository files navigation

Virtual Capacity

A GLPI plugin that adds a rich resource capacity dashboard to Computer records — showing physical RAM, CPU cores, storage, and VM allocations side-by-side.

PHP Version GLPI Version License CI


Features

Section What it shows
Summary Cards Physical RAM, Allocated RAM, Available RAM, CPU Cores, Physical Storage, Storage Summary
Utilisation Bars RAM, CPU Core, and Disk utilisation — colour-coded green → amber → red
Physical Drives Drive model, type (SSD/HDD/NVMe badge), raw capacity, serial number
Logical Volumes Mount point, filesystem, total/free size, per-volume progress bar
VM Breakdown Per-VM RAM and vCPU allocation, storage, RAM share bar, totals and available rows
Print Report One-click Print Report button in the tab toolbar, or direct URL access

Highlights

  • Zero custom database tables — reads exclusively from GLPI core tables populated by GLPI Agent
  • Dual-source capacity merge — uses GREATEST(per_item_capacity, model_default) so RAID volumes always show a sensible capacity
  • Colour-coded thresholds — green < 60%, amber 60–79%, red ≥ 80% for instant visual triage
  • PSR-4 autoloadingGlpiPlugin\Virtualcapacity\ namespace
  • Three-layer architectureCapacity.php (data) · CapacityRenderer.php (controller) · Twig templates (view)
  • Twig-native rendering — all HTML lives in templates/ using GLPI 11's TemplateRenderer; no PHP echo in the presentation layer
  • Tab/Profile separationProfile.php owns tab registration; Capacity.php owns data; no cross-concern coupling
  • GLPI 11.x compatible with Bootstrap 5, Tabler Icons, Symfony HTTP exceptions, and Glpi\DBAL\QueryExpression

Requirements

Dependency Minimum version
GLPI 11.0.0
PHP 8.2
GLPI Agent (for inventory data) any

Installation

Method 1 — GLPI Marketplace (recommended)

  1. Go to Setup → Plugins → Marketplace
  2. Search for Virtual Capacity
  3. Click Install, then Enable

Method 2 — Manual Installation

# From your GLPI plugins directory
cd /path/to/glpi/plugins

# Download the latest release archive
wget https://github.com/tahir242/virtualcapacity/releases/latest/download/virtualcapacity.zip
unzip virtualcapacity.zip

# Set correct ownership
chown -R www-data:www-data virtualcapacity/

Then go to Setup → Plugins in GLPI, find Virtual Capacity, and click InstallEnable.

Method 3 — Git Clone (development)

cd /path/to/glpi/plugins
git clone https://github.com/tahir242/virtualcapacity.git
cd virtualcapacity
composer install --no-dev --optimize-autoloader

Usage

After activation, open any Computer record in GLPI:

  1. Navigate to Assets → Computers
  2. Open a Computer that has been inventoried by GLPI Agent
  3. Click the Resource Capacity tab

The full dashboard will appear. To generate a printable report, click the Print Report button in the tab toolbar (opens in a new tab), or navigate directly to:

https://your-glpi-instance/plugins/virtualcapacity/front/report.php?computers_id=<id>

On the report page, click Print / Export PDF to open your browser's print dialog (supports Save as PDF).


Architecture

plugins/virtualcapacity/
├── src/
│   ├── Capacity.php          # Data layer — DB queries only, no HTML
│   ├── CapacityRenderer.php  # Controller — pre-computes display values,
│   │                         #   calls TemplateRenderer; no echo/HTML
│   └── Profile.php           # Tab registration — CommonGLPI interface
├── templates/
│   ├── capacity_tab.html.twig         # Root wrapper + toolbar
│   └── partials/
│       ├── metric_cards.html.twig     # ROW 1: six summary cards
│       ├── progress_bars.html.twig    # ROW 2: RAM/CPU/Disk bars
│       ├── storage_tables.html.twig   # ROW 3: drives + volumes tables
│       └── vm_breakdown.html.twig     # ROW 4: VM breakdown table
├── front/
│   └── report.php            # Standalone printable report page
└── public/
    └── virtualcapacity.css   # Scoped CSS (.vc-tab prefix), no inline styles

Design decisions

Decision Rationale
Twig templates via TemplateRenderer GLPI 11 native; auto-registered under @virtualcapacity/ namespace
All derived values pre-computed in PHP Avoids a Twig extension; templates stay logic-free
Profile separate from Capacity Separation of concerns — tab plumbing vs. data access
Glpi\DBAL\QueryExpression Replaces deprecated root-namespace \QueryExpression
BadRequestHttpException Replaces deprecated Html::displayErrorAndDie()
CSS custom properties (:root) Single source of truth for heading/badge colours

Data Sources

The plugin reads these GLPI core tables (no writes):

Table Data
glpi_items_devicememories Physical RAM per memory stick
glpi_items_deviceprocessors Physical CPU sockets / cores
glpi_itemvirtualmachines VM definitions with RAM and vCPU allocations
glpi_items_deviceharddrives Physical hard drives with per-item capacity
glpi_deviceharddrives Drive model definitions with capacity_default
glpi_deviceharddrivetypes Drive type labels (SSD, HDD, NVMe, …)
glpi_items_disks Logical partitions / mount points
glpi_filesystems Filesystem labels (NTFS, ext4, …)

Screenshots

Resource Capacity Tab


Development

# Install dev dependencies
composer install

# Check code quality
composer run lint      # PHP parallel lint
composer run cs        # PHP-CS-Fixer dry run
composer run phpstan   # PHPStan static analysis
composer run qa        # All checks

# Fix coding standards automatically
composer run cs-fix

See CONTRIBUTING.md for full contribution guidelines.


Changelog

See CHANGELOG.md for a full list of changes between releases.


License

Released under the GNU General Public License v3+.


Support

About

A GLPI plugin that adds a rich resource capacity dashboard to Computer records showing physical RAM, CPU cores, storage, and VM allocations side-by-side.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages