yats.git

ref: 6da05809d41b4d336c9da0f6b68c4ca41c7810b3

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