Document toolboxDocument toolbox

MrMiyagi

The MrMiyagi test and recovery script

The MrMiyagi (MM) test and recovery script is placed in /job/mrmiyagi/mrmiyagi.php and runs every minute to test and ensure server health.


Get a warning when a test fails

Either add a phone number or a mail address to the script in the $warntosms or $warntomail variables.


Add a new test to the MM script

First extend the $tests variable. This is an array of arrays, where the outer array must be hashed by an unique value, called the test id. The inner array is used to configure the test. Currently the following parameters exists:

canrecoverIf this is set to true, the test will continue to run even when failing. If it passes at a later time a recovery message is sent. If this is set to false, the test will not run anymore if it first failed, and must be cleared manually.


Next extends the runtest() function to include your test case. This function takes the test id as a parameter, and must return true if the test passes. Otherwise it must return an appropriate warning.

At last it is possible (and optional) to also extend the recover() function. This function is intended to try to recover from the error and is called once, when a test fails. It takes the test id as a parameter, and doesn't need to return anything.


Manually clear an error

An error can be cleared manually, by editing the triggeredwarnings.txt along the MM script and removing the line containing the test ID.


Save/restore status

A test may save a status by calling savestatus($testid, $status), and may retrieve a previously saved status by calling loadstatus($testid, $default).


Be aware

The MM script runs in root user space, and therefore have great powers.