blob: fada454192d56fa696ffdcf6404e161918cec1a7 [file] [log] [blame]
Brian Freeman48d30542019-08-20 13:13:58 -05001#!/bin/bash
2
3if [ "$#" -ne 3 ]; then
4 echo "$0 <onap-pods.json> <job> <build>"
5 exit 1
6fi
7JSON_OUTPUT=$1
8JOB=$2
9BUILD=$3
10
11INFLUX_ENDPOINT='http://10.145.123.16:8086/write?db=robot'
12
13
14TIME=$(date -r $JSON_OUTPUT +%s%N)
15
16POINTS_FILE=/tmp/points-$JOB-$BUILD-pods.txt
17rm -f $POINTS_FILE
18
19cat $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
35done
36
37curl -i $INFLUX_ENDPOINT --data-binary @$POINTS_FILE