Skip to content

Commit 0b1730e

Browse files
robkooperlmarini
andauthored
update script can now post to influxdb (#82)
Co-authored-by: Luigi Marini <[email protected]>
1 parent 5b51395 commit 0b1730e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- proxy will no correctly handle paths that end with a / at the end.
1515
- submitting an extraction will always return a 500 error, see [#84](https://github.com/clowder-framework/clowder/issues/84)
1616

17-
### CHanged
18-
- updated update-clowder script to work with migration to github
17+
### Changed
18+
- updated update-clowder script to work with migration to github. Has the ability now to push a message to MSTEAMS as well as influxdb.
1919

2020
## 1.11.0 - 2020-08-31
2121

scripts/ubuntu/update-clowder.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ SLACK_CHANNEL="#simpl-ops"
2727
# MSTeams Webhook
2828
MSTEAMS_URL=""
2929

30+
# INFLUXDB
31+
INFLUXDB_URL=""
32+
INFLUXDB_DATABASE=""
33+
INFLUXDB_USERNAME=""
34+
INFLUXDB_PASSWORD=""
35+
3036
# change to folder where script is installed
3137
cd /home/clowder
3238

@@ -106,10 +112,20 @@ if [ -s ${CLOWDER_ZIPFILE} ]; then
106112
payload="{\"title\": \"UPDATE CLOWDER\", \"text\": \"${txt}\" }"
107113
result=$(curl -s -X POST -H "Content-Type: application/json" -d "${payload}" $MSTEAMS_URL)
108114
fi
115+
if [ "${INFLUXDB_URL}" != "" -a "${INFLUXDB_DATABASE}" != "" -a "${INFLUXDB_USERNAME}" != "" -a "${INFLUXDB_PASSWORD}" != "" ]; then
116+
url="${INFLUXDB_URL}/api/v2/write?bucket=${INFLUXDB_DATABASE}&precision=ns"
117+
tags="host=${HOSTNAME}"
118+
timestamp="$(date -u +"%s%N")"
119+
values="version=\"$( grep '\-Dbuild.version' clowder/bin/clowder | sed 's/.*=\(.*\)"$/\1/' )\""
120+
values="${values},branch=\"$( grep '\-Dbuild.branch' clowder/bin/clowder | sed 's/.*=\(.*\)"$/\1/' )\""
121+
values="${values},build=\"$( grep '\-Dbuild.bamboo' clowder/bin/clowder | sed 's/.*=\(.*\)"$/\1/' )\""
122+
values="${values},gitsha1=\"$( grep '\-Dbuild.gitsha1' clowder/bin/clowder | sed 's/.*=\(.*\)"$/\1/' )\""
123+
auth="Authorization: Token ${INFLUXDB_USERNAME}:${INFLUXDB_PASSWORD}"
124+
result=$(curl -s -i -XPOST "$url" --header "$auth" --data "clowder_update,${tags} ${values} ${timestamp}")
125+
fi
109126
if [ "${STDOUT}" != "" ]; then
110127
cat /tmp/$$.txt >&3
111128
fi
112129
rm /tmp/$$.txt
113130
fi
114131
fi
115-

0 commit comments

Comments
 (0)