[Aether-1482] - Add the new helm chart to install the telegraf external daemon of ONOS controller

- Use the servicemonitor to work with Prometheus instead of Rancher's annotation

Change-Id: Icabfb43b1dbf5f86bfdbd4117cf550770d3418a7
diff --git a/apps/tost-telegraf/templates/configmap-config.yaml b/apps/tost-telegraf/templates/configmap-config.yaml
new file mode 100644
index 0000000..13c1548
--- /dev/null
+++ b/apps/tost-telegraf/templates/configmap-config.yaml
@@ -0,0 +1,31 @@
+{{/*
+# Copyright 2021-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: "tost-telegraf-config-script"
+  labels:
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    app: tost-telegraf
+data:
+  tost_telegraf.sh: |
+    #!/bin/sh
+    set -x
+
+    while IFS= read -r LINE; do
+        ACTIVE_LINKS=$(curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} --noproxy {{ .Values.onos.server }} -X GET -H 'Accept: application/json' \
+        http://{{ .Values.onos.server }}:{{ .Values.onos.port }}/onos/v1/links | json_pp | grep "\"state\" : \"ACTIVE\"" | wc -l)
+
+        ENABLE_DEVICE_PORTS=$(curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} --noproxy {{ .Values.onos.server }} -X GET -H 'Accept: application/json' \
+        http://{{ .Values.onos.server }}:{{ .Values.onos.port }}/onos/v1/devices/ports | json_pp | grep "\"isEnabled\" : true" | wc -l)
+
+        DEVICES=$(curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} --noproxy {{ .Values.onos.server }} -X GET -H 'Accept: application/json' \
+        http://{{ .Values.onos.server }}:{{ .Values.onos.port }}/onos/v1/devices | json_pp | grep "\"type\" : \"SWITCH\"" | wc -l)
+
+        echo "onos_telegraf active_links=${ACTIVE_LINKS},enable_device_ports=${ENABLE_DEVICE_PORTS},devices=${DEVICES}"
+    done