Refactor error handling for command execution
- Added try-catch block to handle exceptions during command execution.
This commit is contained in:
parent
e004a1002e
commit
439d658d14
@ -13,8 +13,12 @@ if(php_sapi_name() == 'cli' || $_SERVER["REQUEST_URI"] == '/metrics') {
|
|||||||
if (isset($submetric['command'])) {
|
if (isset($submetric['command'])) {
|
||||||
$output = null;
|
$output = null;
|
||||||
$retval = null;
|
$retval = null;
|
||||||
|
try {
|
||||||
exec($submetric['command'], $output, $retval);
|
exec($submetric['command'], $output, $retval);
|
||||||
$output = implode("\n", $output);
|
$output = implode("\n", $output);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$output = '';
|
||||||
|
}
|
||||||
} elseif (isset($submetric['http'])) {
|
} elseif (isset($submetric['http'])) {
|
||||||
$client = new GuzzleHttp\Client();
|
$client = new GuzzleHttp\Client();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user