Class exec_monitor

Description

A monitor class to exec a script/program on the OS. This allows you

to hook up an external script or program to the monitoring system with the flexibility to determine success/failure by return value or by comparing output with an expected (regex) pattern. The default test is to test the output of the script/program and if it is nullstring (''), then the check is deemed to be successful, otherwise not. There is also a flag, in the constructor ($publish_output) which, if true, directs the monitor to include any script output in the email or SMS messages. This can sometimes be useful for providing extra information in error reports.

Located in /monitor-defs.php (line 198)

generic_monitor
   |
   --exec_monitor
Variable Summary
Method Summary
 exec_monitor exec_monitor (string $exec, [string $success_regex = ""], [boolean $publish_output = false])
 integer check ()
 void set_success_regex (mixed $success_regex, string $regex)
 void set_success_value ([mixed $success = ""], integer $code)
Variables
mixed $execparms = "" (line 200)
mixed $execpath = "" (line 199)
mixed $publish_output = false (line 203)
mixed $success_regex = "" (line 202)
mixed $success_value = "" (line 201)
Methods
Constructor exec_monitor (line 211)

Define a new exec check object.

exec_monitor exec_monitor (string $exec, [string $success_regex = ""], [boolean $publish_output = false])
  • string $exec: Script/program to execute, including any parameters
  • string $success_regex: Regex to match with the output of script/program
  • boolean $publish_output: Publish script/program output in all messages
check (line 252)

Make the check by executing the script/program which has been

specified. We check that this exists and is executable, and raise warnings if not. The success/failure of the check is determined by the settings, but is either done via return code or by returned output matching.

  • return: Condition determined by this check
integer check ()
set_success_regex (line 241)

Allows you to specify a regular expression which will be applied to the output of the executed script/program and if matched will be taken to mean the check was successful. If specified, this takes the place of the default behaviour of checking the return code.

void set_success_regex (mixed $success_regex, string $regex)
  • string $regex: Regular expression to match on output for success
set_success_value (line 230)

Allows you to specify a string value which, if returned as output by the called script/program, will indicate success.

The default value for success is already nullstring, so no need to specify it in that particular case.

void set_success_value ([mixed $success = ""], integer $code)
  • integer $code: Return value which indicates success

Documentation generated by phpDocumentor 1.3.0RC3