forked from AndreRenaud/PDFGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-stats.sh
More file actions
executable file
·32 lines (26 loc) · 1.07 KB
/
upload-stats.sh
File metadata and controls
executable file
·32 lines (26 loc) · 1.07 KB
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
#!/bin/sh
# Grabs information from valgrind logs and PDF output file and uploads
# them to corlysis for graphing
set -e
if [ ! -e valgrind.log ] ; then
echo "valgrind.log not found - please run tests" >&2
exit 1
fi
if [ ! -e output.pdf ] ; then
echo "output.pdf not found - please run tests" >&2
exit 1
fi
if [ -z "$CORLYSIS_TOKEN" ] ; then
echo "No API token for Corlysis available" >&2
exit 1
fi
ALLOCS=`sed -rn 's/^.* ([0-9,]+) allocs.*$/\1/gp' < valgrind.log | sed 's/,//g'`
FREES=`sed -rn 's/^.* ([0-9,]+) frees.*$/\1/gp' < valgrind.log | sed 's/,//g'`
ALLOCATED=`sed -rn 's/^.* ([0-9,]+) bytes allocated.*$/\1/gp' < valgrind.log | sed 's/,//g'`
XREFS=`grep -a "/Size" output.pdf | awk '{print $2}' | tr -d '[:space:]'`
FILESIZE=`du -b output.pdf | awk '{print $1}'`
LOC=`cloc --quiet --csv pdfgen.c | grep "^1," | cut -d , -f 5`
DATA="pdfgen_usage allocs=$ALLOCS,frees=$FREES,allocated=$ALLOCATED,xref_count=$XREFS,file_size=$FILESIZE,loc=$LOC"
echo data="$DATA"
curl -i -XPOST 'https://corlysis.com:8086/write?db=TestStats' \
-u token:$CORLYSIS_TOKEN --data-binary "$DATA"