Brian Freeman | 48d3054 | 2019-08-20 13:13:58 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ "$#" -ne 3 ]; then |
| 4 | echo "$0 <onap-pods.json> <job> <build>" |
| 5 | exit 1 |
| 6 | fi |
| 7 | JSON_OUTPUT=$1 |
| 8 | JOB=$2 |
| 9 | BUILD=$3 |
| 10 | |
| 11 | INFLUX_ENDPOINT='http://10.145.123.16:8086/write?db=robot' |
| 12 | |
| 13 | |
| 14 | TIME=$(date -r $JSON_OUTPUT +%s%N) |
| 15 | |
| 16 | POINTS_FILE=/tmp/points-$JOB-$BUILD-pods.txt |
| 17 | rm -f $POINTS_FILE |
| 18 | |
| 19 | cat $JSON_OUTPUT | jq -r '.items[] | ( (.status.containerStatuses[] | ( " "+.image + " " + (.restartCount | tostring) + " " + (.ready | tostring) ) ) ) + " " + .metadata.name ' | grep -e 'onap/' -e 'openecomp/' | sort | while read CONTAINER; do |
| 20 | IMAGE=$(echo $CONTAINER | cut -d ' ' -f 1 | sed -r 's#.*/(onap|openecomp)/##g') |
| 21 | RESTART_COUNT=$(echo $CONTAINER | cut -d ' ' -f 2) |
| 22 | READY=$(echo $CONTAINER | cut -d ' ' -f 3) |
| 23 | POD=$(echo $CONTAINER | cut -d ' ' -f 4) |
| 24 | |
| 25 | if [ "$READY" = "true" ] && [ "$RESTART_COUNT" -eq 0 ]; then |
| 26 | PASS=1 |
| 27 | FAIL=0 |
| 28 | else |
| 29 | PASS=0 |
| 30 | FAIL=1 |
| 31 | fi |
| 32 | |
| 33 | # currently assumes that no onap pod contains multiple containers of with the same image |
| 34 | echo container,job=$JOB,image=$IMAGE,pod=$POD build=$BUILD,restartCount=$RESTART_COUNT,ready=$READY,pass=$PASS,fail=$FAIL $TIME | tee -a $POINTS_FILE |
| 35 | done |
| 36 | |
| 37 | curl -i $INFLUX_ENDPOINT --data-binary @$POINTS_FILE |