|
25 | 25 |
|
26 | 26 | define('CLI_SCRIPT', true); |
27 | 27 |
|
28 | | -require(__DIR__.'/../../../../config.php'); |
29 | | -require_once($CFG->libdir.'/clilib.php'); |
| 28 | +require(__DIR__ . '/../../../../config.php'); |
| 29 | +require_once($CFG->libdir . '/clilib.php'); |
30 | 30 | require_once($CFG->libdir . '/filelib.php'); |
31 | 31 |
|
32 | 32 |
|
33 | 33 | // Get cli options. |
34 | | -list($options, $unrecognized) = cli_get_params(['help' => false, |
| 34 | +[$options, $unrecognized] = cli_get_params( |
| 35 | + ['help' => false, |
35 | 36 | 'url' => null, |
36 | 37 | 'warning' => 80, |
37 | 38 | 'critical' => 90, ], |
38 | | - ['h' => 'help', |
| 39 | + ['h' => 'help', |
39 | 40 | 'u' => 'url', |
40 | 41 | 'w' => 'warning', |
41 | | - 'c' => 'critical', ]); |
| 42 | + 'c' => 'critical', |
| 43 | + ] |
| 44 | +); |
42 | 45 | if ($unrecognized) { |
43 | 46 | $unrecognized = implode("\n ", $unrecognized); |
44 | 47 | cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); |
|
60 | 63 | -h, --help Print out this help |
61 | 64 |
|
62 | 65 | Example: |
63 | | -\$ sudo -u www-data /usr/bin/php admin/tool/cli/check_opcache.php ". |
| 66 | +\$ sudo -u www-data /usr/bin/php admin/tool/cli/check_opcache.php " . |
64 | 67 | "--url=\"https://example.com/admin/tool/opcache/cli/check_opcache_web.php\" --warning=75 --critical=85 |
65 | 68 | "; |
66 | 69 | cli_writeln($help); |
|
117 | 120 | } |
118 | 121 |
|
119 | 122 | // Concatenate return string including performance data. |
120 | | -$out = $usedpct."% cache used | ". |
121 | | - "used_pct=".$usedpct."%;".$options['warning'].";".$options['critical']." hit_pct=".$hitspct."%; miss_pct=".$misspct."%;"; |
| 123 | +$out = $usedpct . "% cache used | " . |
| 124 | + "used_pct=" . $usedpct . "%;" . $options['warning'] . ";" . $options['critical'] . " hit_pct=" . $hitspct . |
| 125 | + "%; miss_pct=" . $misspct . "%;"; |
122 | 126 |
|
123 | 127 | // Echo return string. |
124 | 128 | if ($returnstatus == 0) { |
125 | | - cli_writeln('OK - '.$out); |
| 129 | + cli_writeln('OK - ' . $out); |
126 | 130 | } else if ($returnstatus == 1) { |
127 | | - cli_writeln('WARNING - '.$out); |
| 131 | + cli_writeln('WARNING - ' . $out); |
128 | 132 | } else { |
129 | | - cli_writeln('CRITICAL - '.$out); |
| 133 | + cli_writeln('CRITICAL - ' . $out); |
130 | 134 | } |
131 | 135 |
|
132 | 136 | // Exit with calculated return status. |
|
0 commit comments