Compare commits
2 Commits
e004a1002e
...
fd8a67c23c
Author | SHA1 | Date | |
---|---|---|---|
fd8a67c23c | |||
439d658d14 |
20
index.php
20
index.php
@ -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;
|
||||||
exec($submetric['command'], $output, $retval);
|
try {
|
||||||
$output = implode("\n", $output);
|
exec($submetric['command'], $output, $retval);
|
||||||
|
$output = implode("\n", $output);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$output = '';
|
||||||
|
}
|
||||||
} elseif (isset($submetric['http'])) {
|
} elseif (isset($submetric['http'])) {
|
||||||
$client = new GuzzleHttp\Client();
|
$client = new GuzzleHttp\Client();
|
||||||
|
|
||||||
@ -43,9 +47,17 @@ if(php_sapi_name() == 'cli' || $_SERVER["REQUEST_URI"] == '/metrics') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($submetric['http']['data']) && $submetric['http']['data'] == 'responsebody') {
|
if (isset($submetric['http']['data']) && $submetric['http']['data'] == 'responsebody') {
|
||||||
$output = $res->getBody()->getContents();
|
if ($hasresponse) {
|
||||||
|
$output = $res->getBody()->getContents();
|
||||||
|
} else {
|
||||||
|
$output = '';
|
||||||
|
}
|
||||||
} elseif ((isset($submetric['http']['statuscode'])) && (isset($submetric['http']['data']) && $submetric['http']['data'] == 'hasresponse')) {
|
} elseif ((isset($submetric['http']['statuscode'])) && (isset($submetric['http']['data']) && $submetric['http']['data'] == 'hasresponse')) {
|
||||||
$output = (int)in_array($res->getStatusCode(), $submetric['http']['statuscode']);
|
if ($hasresponse) {
|
||||||
|
$output = $output = (int)in_array($res->getStatusCode(), $submetric['http']['statuscode']);;
|
||||||
|
} else {
|
||||||
|
$output = 0;
|
||||||
|
}
|
||||||
} elseif (isset($submetric['http']['data']) && $submetric['http']['data'] == 'hasresponse') {
|
} elseif (isset($submetric['http']['data']) && $submetric['http']['data'] == 'hasresponse') {
|
||||||
$output = (int)$hasresponse;
|
$output = (int)$hasresponse;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user