szepeviktor/magento-critical-site-health

Declarative YAML-based Magento 2 site health checks for n98-magerun2

Maintainers

Package info

github.com/szepeviktor/magento-critical-site-health

Type:magento2-module

pkg:composer/szepeviktor/magento-critical-site-health

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-08-20 20:04 UTC

This package is auto-updated.

Last update: 2026-08-20 20:13:31 UTC


README

Declarative YAML-based monitor command for Magento 2, packaged as a Magento module and exposed as an n98-magerun2 custom command.

n98-magerun2 site-health:check dev/tests/ok.yaml

Scope

The command is read-only. It collects warnings, exits with a non-zero status when any warning is found, and exits successfully when all checks pass.

Supported check types:

  • config
  • env
  • store
  • module
  • class
  • cache
  • indexer
  • db_query
  • shell
  • object_method
  • eval

Installation

Install the package into a Magento 2 project. n98-magerun2 discovers the bundled n98-magerun2.yaml file from vendor/ and registers the custom command.

Command

n98-magerun2 site-health:check <yaml-file>

The command fails fast if Magento cannot be detected or bootstrapped.

Configuration

Example:

config:
  web/secure/use_in_frontend: "1"
  - path: web/unsecure/base_url
    scope: stores
    scope_code: default
    expected: "https://example.com/"

env:
  crypt/key: "change-me"

store:
  default.is_active: true
  default.config:web/secure/base_url: "https://example.com/"

module:
  Magento_Catalog: true
  Vendor_DisabledModule: false

class:
  Magento\Catalog\Api\ProductRepositoryInterface: true

cache:
  config: true
  full_page: true

indexer:
  catalog_product_price: valid

db_query:
  - sql: "SELECT COUNT(*) FROM core_config_data WHERE path = 'web/secure/base_url'"
    expected: "1"
  - sql: "SELECT value FROM core_config_data WHERE path = 'web/secure/base_url' LIMIT 1"
    expected: "https://example.com/"

shell:
  - command: "test -f app/etc/env.php"
  - command: "test -d pub/static"
    expected_exit_code: 0

object_method:
  Magento\Framework\App\DeploymentConfig::getConfigData: true

eval:
  - "count($storeManager->getStores()) > 0"
  - "$deploymentConfig->get('install/date') !== null"

Notes

  • config values are read via ScopeConfigInterface.
  • env values are read from DeploymentConfig.
  • store supports store_code.field and store_code.config:path/to/value.
  • object_method resolves Magento services via the object manager for non-static methods.
  • eval expressions must return true. Parse errors and runtime exceptions are reported as warnings.

Magento Examples

config:
  web/secure/use_in_frontend: "1"
  web/seo/use_rewrites: "1"
  - path: design/theme/theme_id
    scope: stores
    scope_code: default
    expected: "3"

env:
  crypt/key: "your-crypt-key"
  db/connection/default/host: "mysql"

store:
  default.is_active: true
  default.base_url: "https://example.com/"
  default.config:web/secure/base_url: "https://example.com/"

module:
  Magento_Config: true
  Magento_Indexer: true

class:
  Magento\Framework\App\DeploymentConfig: true
  Magento\Store\Api\StoreRepositoryInterface: true

cache:
  config: true
  layout: true
  full_page: true

indexer:
  catalogrule_rule: valid
  catalog_product_price: valid
  catalogsearch_fulltext: valid

db_query:
  - sql: "SELECT COUNT(*) FROM core_config_data WHERE path = 'web/secure/base_url'"
    expected: "1"
  - sql: "SELECT value FROM core_config_data WHERE path = 'design/theme/theme_id' LIMIT 1"
    expected: "3"

shell:
  - command: "test -f app/etc/env.php"
  - command: "test -d generated/code"

object_method:
  Magento\Framework\App\DeploymentConfig::getConfigData: true

eval:
  - "count($storeManager->getStores()) >= 1"
  - "$scopeConfig->getValue('web/seo/use_rewrites') === '1'"
  - "$deploymentConfig->get('crypt/key') !== null"
  - "$moduleManager->isEnabled('Magento_Catalog')"
  - "$indexerRegistry->get('catalog_product_price')->getStatus() === 'valid'"