PHP code example of cytopia / check_php

1. Go to this page and download the library: Download cytopia/check_php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cytopia / check_php example snippets

javascript
/*
 * PHP Health
 */
apply Service "php-" for (php => config in host.vars.php) {
  check_command = "php"
  // Assuming your PHP setup doesn't change too often, we don't
  // bother to check twice a day only.
  check_interval = 12h

  display_name = "PHP " + php
  notes = "Checks currently installed PHP " + php + " health."

  // Service variables from php definition.
  vars += config
  vars.php_delimiter = "|"
  if ( config.php_modules ) {
    vars.php_modules = []
    for (key => value in config.php_modules) {
      vars.php_modules += [ key + vars.php_delimiter + value ]
    }
  }
  if ( config.php_blacklist ) {
    vars.php_blacklist = []
    for (key => value in config.php_blacklist) {
      vars.php_blacklist += [ key + vars.php_delimiter + value ]
    }
  }
  if ( config.php_config ) {
    vars.php_config = []
    for (key => value in config.php_config) {
      vars.php_config += [ key + vars.php_delimiter + value["default"] + vars.php_delimiter + value["severity"] ]
    }
  }

  // Application rules.
  assign where host.name = NodeName && host.vars.php
}
javascript
object Host "node.example.com" {

  // Other settings.
  vars.php[ "7.1" ] = {
    php_binary = "/opt/php/7.1/bin/php"
    php_updates = "w"
    php_startup = "e"
    php_modules = {
      intl = "w"
      mbstring = "w"
      soap = "w"
      apcu = "w"
      memcached = "w"
      geoip = "w"
      mongodb = "w"
      imagick = "w"
      redis = "w"
      openssl = "w"
      xml = "w"
      json = "w"
      curl = "w"
    }
    php_blacklist = {
      mcrypt = "w"
    }
    php_config = {
      "date.timezone" = {
        "default" = "Europe/Berlin"
        "severity" = "w"
      }
    }
  }
}
bash
$ check_php -u e
[OK] PHP 5.6.16 is healthy | 'OK'=1;;;; 'Errors'=0;;;; 'Warnings'=0;;;; 'Unknown'=0;;;;
[OK]       No PHP startup errors
[OK]       PHP Version 5.6.14 up to date.
bash
$ check_php -u e
[ERR] PHP 5.6.13 has errors: Updates available | 'OK'=0;;;; 'Errors'=1;;;; 'Warnings'=-;;;; 'Unknown'=0;;;;
[OK]       No PHP startup errors
[CRITICAL] PHP Version 5.6.13 too old. Latest: 5.6.14.
bash
$ check_php -u e
[ERR] PHP 5.5.1 has errors: Updates available | 'OK'=0;;;; 'Errors'=1;;;; 'Warnings'=0;;;; 'Unknown'=0;;;;
[OK]       No PHP startup errors
[CRITICAL] PHP Version 5.5.1 too old. Latest: 5.5.30.