getParsedJson(); } catch (JsonAppException $e) { echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message return; } $rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('cpu_usage', 'GAUGE', 0, 100) ->addDataset('pids', 'GAUGE', 0) ->addDataset('mem_perc', 'GAUGE', 0, 100) ->addDataset('mem_used', 'GAUGE', 0) ->addDataset('mem_limit', 'GAUGE', 0); $metrics = []; foreach ($docker_data as $data) { $container = $data['container']; $rrd_name = ['app', $name, $app_id, $container]; $fields = [ 'cpu_usage' => (float) $data['cpu'], 'pids' => $data['pids'], 'mem_perc' => (float) $data['memory']['perc'], 'mem_used' => convertToBytes($data['memory']['used']), 'mem_limit' => convertToBytes($data['memory']['limit']), ]; $metrics[$container] = $fields; $tags = ['name' => $container, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } update_application($app, $output, $metrics);