mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
json-app-tool fix (#9593)
* add insert the metrics stuff into the right place now * properly exit now when -l is given or -k, -m or -s is not given * Update json-app-tool.php
This commit is contained in:
@@ -100,7 +100,11 @@ if (!isset($json['error'], $json['data'], $json['errorString'], $json['version']
|
||||
}
|
||||
|
||||
//successfully loaded and tested the file, just exit now if asked to
|
||||
if (isset($options['l'])) {
|
||||
if ((isset($options['l']))||(
|
||||
(!isset($options['t']))&&
|
||||
(!isset($options['s']))&&
|
||||
(!isset($options['m']))
|
||||
)) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -151,38 +155,40 @@ if (isset($options['s'])) {
|
||||
}
|
||||
|
||||
// prints the json test data file if asked to
|
||||
if (isset($options['j'])) {
|
||||
$test_data=array(
|
||||
'applications' => array (
|
||||
"discovery" => array(
|
||||
"applications" => array(
|
||||
if (isset($options['t'])) {
|
||||
$test_data = [
|
||||
'applications' => [
|
||||
"discovery" => [
|
||||
"applications" => [
|
||||
"app_type" => $options['a'],
|
||||
"app_state" => "UNKNOWN",
|
||||
"discovered" => "1",
|
||||
"app_state_prev" => null,
|
||||
"app_status" => "",
|
||||
"app_instance" => "",),
|
||||
"application_metrics" => array(),
|
||||
),
|
||||
"poller" => array(
|
||||
"applications" => array(
|
||||
"app_instance" => "",
|
||||
],
|
||||
"application_metrics" => [],
|
||||
],
|
||||
"poller" => [
|
||||
"applications" => [
|
||||
"app_type" => $options['a'],
|
||||
"app_state" => "OK",
|
||||
"discovered" => "1",
|
||||
"app_state_prev" => "UNKNOWN",
|
||||
"app_status" => "",
|
||||
"app_instance" => "",),
|
||||
"application_metrics" => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
"app_instance" => "",
|
||||
],
|
||||
"application_metrics" => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
foreach ($metrics_keys as $key) {
|
||||
$test_data[poller][application_metrics][]=array(
|
||||
$test_data['applications']['poller']['application_metrics'][] = [
|
||||
"metric" => $key,
|
||||
"value" => $metrics[$key],
|
||||
"value_prev" => null,
|
||||
"app_type" => $options['a'],
|
||||
);
|
||||
];
|
||||
}
|
||||
echo json_encode($test_data, JSON_PRETTY_PRINT)."\n";
|
||||
exit(0);
|
||||
|
Reference in New Issue
Block a user