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