eole-prometheus/postservice/88_grafana

35 lines
915 B
Plaintext
Raw Normal View History

2018-06-04 17:01:42 +02:00
#!/usr/bin/env bash
2018-06-04 13:59:45 +02:00
2018-06-04 17:01:42 +02:00
grafanaHost=$(CreoleGet srvGrafanaIP 192.168.30.57)
grafanaPort=$(CreoleGet srvGrafanaPort 3000)
grafanaUser="admin"
grafanaPasswd=$(CreoleGet grafana_admin_passwd admin)
grafanaURL="http://${grafanaUser}:${grafanaPasswd}@${grafanaHost}:${grafanaPort}"
datasource_name=$(CreoleGet promDataSource "prometheus")
promHost=$(CreoleGet adresse_ip_eth0)
promPort='9090'
2018-06-04 13:59:45 +02:00
2018-06-04 17:01:42 +02:00
cmd="curl"
url="${grafanaURL}/api/datasources"
2018-06-04 13:59:45 +02:00
2018-06-04 17:01:42 +02:00
data=$(cat <<__EOF__
{"name":"${datasource_name}","type":"prometheus","url":"http://${promHost}:${promPort}","access":"direct"}
__EOF__
2018-06-04 13:59:45 +02:00
)
2018-06-04 17:01:42 +02:00
echo -ne "\tCreating datasource for Prometheus "
res=$(${cmd} "${url}" -H "Content-Type: application-json" --data-binary "${data}" 2>&1 )
excode=${?}
case $res in
*"already exists"*)
echo " ... [Exists]"
;;
*"Datasource added"*)
echo " ... [OK]"
;;
esac
2018-06-04 13:59:45 +02:00
2018-06-04 17:01:42 +02:00
echo -ne "\tImporting Node Exporter Full Dashboard "
2018-06-04 13:59:45 +02:00