Adding a tool for remote collection of node and cluster diagnostics.

- Includes 'onos-diagnostics', 'onos-node-diagnostics'
- Includes REST API /onos/v1/diagnostics

Change-Id: Ife0a15627b14238d0fce52b01b72d56e6a1fe40f
diff --git a/tools/package/runtime/bin/onos-node-diagnostics b/tools/package/runtime/bin/onos-node-diagnostics
new file mode 100755
index 0000000..1cb18b5
--- /dev/null
+++ b/tools/package/runtime/bin/onos-node-diagnostics
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+#
+# Copyright 2015-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# -----------------------------------------------------------------------------
+# Tool to collect node-specific diagnostics into a single tar stream.
+# -----------------------------------------------------------------------------
+
+# If ONOS_HOME is set, respect its value.
+# If ONOS_HOME is not set (e.g. in the init or service environment),
+# set it based on this script's path.
+ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
+
+diag=/tmp/diag$$
+mkdir -p $diag; cd $diag
+
+# Collect application state
+ls -l $ONOS_HOME/apps/* > apps-dir.txt
+
+# Collect the karaf logs
+cp $ONOS_HOME/apache-karaf-*/data/log/* .
+
+# Tar-up the collected information
+tar zcf ../onos-node-diags.tar.gz *
+rm -fr $diag
+
+