[icinga-checkins] icinga.org: icinga-vagrant/master: icinga2x: Fix grafana-setup timeout; add more logging

git at icinga.org git at icinga.org
Thu Aug 18 11:35:40 CEST 2016

Module: icinga-vagrant
Branch: master
Commit: b7bbd72d36e63e7dc54bf8a29044859a0834a57e
URL:    https://git.icinga.org/?p=icinga-vagrant.git;a=commit;h=b7bbd72d36e63e7dc54bf8a29044859a0834a57e

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu Aug 18 11:35:18 2016 +0200

icinga2x: Fix grafana-setup timeout; add more logging


 icinga2x/files/usr/local/bin/grafana-setup |   24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/icinga2x/files/usr/local/bin/grafana-setup b/icinga2x/files/usr/local/bin/grafana-setup
index c3bf7f3..091f01c 100755
--- a/icinga2x/files/usr/local/bin/grafana-setup
+++ b/icinga2x/files/usr/local/bin/grafana-setup
@@ -1,19 +1,33 @@
+START=$(date +%s)
 # wait until grafana-server is started
-until $(curl --output /dev/null --silent http://admin:admin@; do
+echo -e "Checking whether Grafana server is listening at $GRAFANA_DATASOURCES_URL"
+until $(curl --output /dev/null --silent $GRAFANA_DATASOURCES_URL); do
+  NOW=$(date +%s)
+  if [[ "$NOW" -gt "$REAL_TIMEOUT" ]]; then
+    echo "Cannot reach Grafana server at $GRAFANA_URL. Timeout reached."
+    exit 1
+  fi
   printf '.'
   sleep 1
 # configure graphite datasource
-curl 'http://admin:admin@' -X POST -H 'Content-Type: application/json;charset=UTF8' --data-binary '{ "name": "icinga2", "type": "graphite", "url": "", "access": "direkt", "isDefault": true }'
+echo -e "Adding Graphite datasource"
+curl "$GRAFANA_DATASOURCES_URL" -X POST -H 'Content-Type: application/json;charset=UTF8' --data-binary '{ "name": "icinga2", "type": "graphite", "url": "", "access": "direct", "isDefault": true }'
 # add default dashboards
 # exported dashboards require the 'dashboard' key including the payload in the http json body request
 # https://github.com/grafana/grafana/issues/2816
 # furthermore the 'id' field must be null in order to create a new dashboard
 # file is already patched
-curl 'http://admin:admin@' -X POST -H 'Content-Type: application/json;charset=UTF8' -d @/etc/icinga2/grafana-dashboard-icinga2.json
+echo -e "Adding Icinga 2 dashboard"
+curl "$GRAFANA_DASHBOARDS_URL" -X POST -H 'Content-Type: application/json;charset=UTF8' -d @/etc/icinga2/grafana-dashboard-icinga2.json

More information about the icinga-checkins mailing list