<commit_before>#!/bin/bash -eux

. /home/easydeploy/bin/env.sh

if [[ -f /home/easydeploy/project/ezd/etc/datadog-api-key.txt ]]
then
    DDOG=$( </home/easydeploy/project/ezd/etc/datadog-api-key.txt)
    DDOG=
fi
if [[ -f /home/easydeploy/project/ezd/etc/stathat-user.txt ]]
then
    STATHAT=$(< /home/easydeploy/project/ezd/etc/stathat-user.txt)
else
    STATHAT=
fi

if [[ -f /home/easydeploy/project/ezd/etc/librato-cred.txt ]]
then
    LIBRATO=$(< /home/easydeploy/project/ezd/etc/librato-cred.txt)
else
    LIBRATO=
fi

if [[ -f /home/easydeploy/project/ezd/etc/hg-key.txt ]]
then
    HG=$(< /home/easydeploy/project/ezd/etc/hg-key.txt)
else
    HG=
fi

if dig +short metrics.${PROJECT}.${DEPLOY_ENV}.comp.ezd
then
    STATSD=metrics.${PROJECT}.${DEPLOY_ENV}.comp.ezd
else
    STATSD=
fi


function sendVal() {
    [[ -z $HG ]] || echo "${HG}.${1}.${HOST} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $HG ]] ||  echo "${HG}.${1}.${IP} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $STATSD ]] || echo -n "sys.ezd.{$1}.${IP} $2" | nc $STATSD 8125
    [[ -z $LIBRATO ]] || curl -u ${LIBRATO} -d "measure_time=$(date +%s)&source=${HOST}&gauges[0][name]=${1}-agg&gauges[0][value]=${2}&gauges[1][name]=${1}&gauges[1][value]=${2}&gauges[1][source]=${IP}" -X POST https://metrics-api.librato.com/v1/metrics

    [[ -z $STATHAT ]] || curl -d "stat=${1}~${HOST},${IP}&email=${STATHAT}&value=${2}" http://api.stathat.com/ez
    
    if [[ ${DEPLOY_ENV} != "prod" ]]
    then
        [[ -z ${DDOG} ]]  || curl  -X POST -H "Content-type: application/json" -d "{ \"series\" : [{\"metric\":\"ezd.${1}\", \"points\":[[$(date +%s), $2]], \"type\":\"gauge\", \"host\":\"${HOST}-${IP}\", \"tags\":[\"environment:${DEPLOY_ENV}\",\"component:${COMPONENT}\", \"project:${PROJECT}\"]} ] }" "https://app.datadoghq.com/api/v1/series?api_key=${DDOG}"
    fi

}

function sendCount() {
    [[ -z $HG ]] || echo "${HG}.${1}.${HOST} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $HG ]] || echo "${HG}.${1}.${IP} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $STATSD ]] || echo -n "sys.ezd.{$1}.${IP} $2|c" | nc $STATSD 8125
<commit_msg>Health check<commit_after>#!/bin/bash -eux

. /home/easydeploy/bin/env.sh

if [[ -f /home/easydeploy/project/ezd/etc/datadog-api-key.txt ]]
then
    DDOG=$( </home/easydeploy/project/ezd/etc/datadog-api-key.txt)
    DDOG=
fi
if [[ -f /home/easydeploy/project/ezd/etc/stathat-user.txt ]]
then
    STATHAT=$(< /home/easydeploy/project/ezd/etc/stathat-user.txt)
else
    STATHAT=
fi

if [[ -f /home/easydeploy/project/ezd/etc/librato-cred.txt ]]
then
    LIBRATO=$(< /home/easydeploy/project/ezd/etc/librato-cred.txt)
else
    LIBRATO=
fi

if [[ -f /home/easydeploy/project/ezd/etc/hg-key.txt ]]
then
    HG=$(< /home/easydeploy/project/ezd/etc/hg-key.txt)
else
    HG=
fi

if dig +short metrics.${PROJECT}.${DEPLOY_ENV}.comp.ezd
then
    STATSD=metrics.${PROJECT}.${DEPLOY_ENV}.comp.ezd
else
    STATSD=
fi


function sendVal() {
    [[ -z $HG ]] || echo "${HG}.${1}.${HOST} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $HG ]] ||  echo "${HG}.${1}.${IP} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $STATSD ]] || echo -n "sys.ezd.{$1}.${IP}:$2|g" | nc $STATSD 8125
    [[ -z $LIBRATO ]] || curl -u ${LIBRATO} -d "measure_time=$(date +%s)&source=${HOST}&gauges[0][name]=${1}-agg&gauges[0][value]=${2}&gauges[1][name]=${1}&gauges[1][value]=${2}&gauges[1][source]=${IP}" -X POST https://metrics-api.librato.com/v1/metrics

    [[ -z $STATHAT ]] || curl -d "stat=${1}~${HOST},${IP}&email=${STATHAT}&value=${2}" http://api.stathat.com/ez
    
    if [[ ${DEPLOY_ENV} != "prod" ]]
    then
        [[ -z ${DDOG} ]]  || curl  -X POST -H "Content-type: application/json" -d "{ \"series\" : [{\"metric\":\"ezd.${1}\", \"points\":[[$(date +%s), $2]], \"type\":\"gauge\", \"host\":\"${HOST}-${IP}\", \"tags\":[\"environment:${DEPLOY_ENV}\",\"component:${COMPONENT}\", \"project:${PROJECT}\"]} ] }" "https://app.datadoghq.com/api/v1/series?api_key=${DDOG}"
    fi

}

function sendCount() {
    [[ -z $HG ]] || echo "${HG}.${1}.${HOST} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $HG ]] || echo "${HG}.${1}.${IP} $2" | nc carbon.hostedgraphite.com 2003
    [[ -z $STATSD ]] || echo -n "sys.ezd.{$1}.${IP}:$2|c" | nc $STATSD 8125

{'fraction_non_alphanumeric': 0.26777751701478525, 'fraction_numerical': 0.023938042712978173, 'mean_word_length': 3.4488517745302714, 'pattern_counts': {'":': 10, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3342544', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1819, 'n_words': 283}