Skip to content
Snippets Groups Projects
exec.php 6.29 KiB
<?php
/**
 * ____________________________________________________________________________
 * 
 *  _____ _____ __                   _____         _ _           
 * |     |     |  |      ___ ___ ___|     |___ ___|_| |_ ___ ___ 
 * |-   -| | | |  |__   | .'| . | . | | | | . |   | |  _| . |  _|
 * |_____|_|_|_|_____|  |__,|  _|  _|_|_|_|___|_|_|_|_| |___|_|  
 *                          |_| |_|                              
 *                           _ _         _                                            
 *                       ___| |_|___ ___| |_                                          
 *                      |  _| | | -_|   |  _|                                         
 *                      |___|_|_|___|_|_|_|   
 *                                                               
 * ____________________________________________________________________________
 * 
 * CUSTOM CHECK BASED ON SHELL COMMANDS
 * 
 * Execute a shell command.
 * ____________________________________________________________________________
 * 
 * 2022-09-19  <axel.hahn@iml.unibe.ch>
 * 2024-07-23  <axel.hahn@unibe.ch>      php 8 only: use typed variables
 * 2025-03-19  <axel.hahn@unibe.ch>      add validation rules and parameter description
 */
class checkExec extends appmonitorcheck
{

    /**
     * Self documentation and validation rules
     * @var array
     */
    protected array $_aDoc = [
        'name' => 'Plugin Exec',
        'description' => 'Execute a shell command.',
        'parameters' => [
            'command' => [
                'type' => 'string',
                'required' => true,
                'description' => 'Command line',
                'default' => null,
                'regex'=>'/./',
                'example' => '[command] [parameters] 2>&1',
            ],
            'output' => [
                'type' => 'bool',
                'required' => false,
                'description' => 'size for warning level',
                'default' => 21,
                'example' => "1.25GB",
            ],
            'exitOk' => [
                'type' => 'array',
                'required' => false,
                'description' => 'array of integers for ok exitcodes',
                'default' => null,
                'example' => "",
            ],
            'exitWarn' => [
                'type' => 'array',
                'required' => false,
                'description' => 'array of integers for warning exitcodes',
                'default' => null,
                'example' => "",
            ],
            'exitCritical' => [
                'type' => 'array',
                'required' => false,
                'description' => 'array of integers for critical exitcodes',
                'default' => null,