Compare commits
2 Commits
e004a1002e
...
fd8a67c23c
Author | SHA1 | Date | |
---|---|---|---|
fd8a67c23c | |||
439d658d14 |
14
index.php
14
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;
|
||||||
|
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();
|
||||||
|
|
||||||
@ -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') {
|
||||||
|
if ($hasresponse) {
|
||||||
$output = $res->getBody()->getContents();
|
$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