yats.git

ref: b6b35ac53b34cb4f1914a031532499400eaca0c8

clients/shell/postMetricTls


#! /bin/bash
#
CFG_FILE=$HOME/.draft.cfg
test -f $CFG_FILE && source $CFG_FILE
SECURE_CA_HOME=${SECURE_HOME}/CA
CA_CERTIFICATE=${SECURE_CA_HOME}/ca.crt
CERTIFICATE=${SECURE_HOME}/${SECURE_SERVICE}/certs/${SECURE_CLIENT}/${SECURE_CLIENT}.crt
PRIVATE_KEY=${SECURE_HOME}/${SECURE_SERVICE}/certs/${SECURE_CLIENT}/${SECURE_CLIENT}.key

test -f ${CA_CERTIFICATE} || echo "Missing CA file: ${CA_CERTIFICATE}"
test -f ${CERTIFICATE} || echo "Missing Certificate file: ${CERTIFICATE}"
test -f ${PRIVATE_KEY} || echo "Missing Private KEY file: ${PRIVATE_KEY}"

CURL_COMMAND="curl -s --cacert ${CA_CERTIFICATE} --cert ${CERTIFICATE} --key ${PRIVATE_KEY}  --cert-type PEM "

TSTAMP=$(date '+%s')
value=$1
${CURL_COMMAND} \
	-X POST\
	--header "Content-Type: application/json"\
	-d "{\"mtime\":${TSTAMP},\"name\":\"test-measure\",\"value\":\"${value}\"}"\
	https://kevwe.com:10003/metric