<commit_before>#!/usr/bin/python
import sys
import json
import subprocess
from threading import Thread


# Group
group = "Remote latency"

# Description of metrics
description = "Latency of remote hosts"

# Amount of times to ping each host
count = 3

# Hosts to ping
hosts = {
    # "{{name of the host}}": "{{hostname/ip}}",
    # ex "coscale": "coscale.com",
    "google": "google.com",
    "pingdom": "pingdom.com",
    "coscale": "app.coscale.com"
}

#
# DONT CHANGE ANYTHING BELOW THIS LINE
#
def execute(metricId, host, count):
    pingtime = subprocess.check_output("ping -c %s %s | tail -1 | awk '{print $4}' | cut -d '/' -f 2" % (count, host), shell=True)
    sys.stdout.write("M%s %s\n" % (metricId, pingtime.rstrip()))

def config():<commit_msg>Always return number on ping => 0 on fail<commit_after>#!/usr/bin/python
import sys
import json
import subprocess
from threading import Thread


# Group
group = "Remote latency"

# Description of metrics
description = "Latency of remote hosts"

# Amount of times to ping each host
count = 3

# Hosts to ping
hosts = {
    # "{{name of the host}}": "{{hostname/ip}}",
    # ex "coscale": "coscale.com",
    "google": "goasdfsadfasdfasdfsdfsafsogle.com",
    "pingdom": "pingdom.com",
    "coscale": "app.coscale.com"
}

#
# DONT CHANGE ANYTHING BELOW THIS LINE
#
def execute(metricId, host, count):
    pingtime = subprocess.check_output("ping -c %s %s | tail -1 | awk '{print $4}' | cut -d '/' -f 2" % (count, host), shell=True).rstrip()

    if pingtime == '':
        pingtime = 0

    sys.stdout.write("M%s %s\n" % (metricId, pingtime))

def config():
{'fraction_non_alphanumeric': 0.15766604593420236, 'fraction_numerical': 0.006207324643078833, 'mean_word_length': 3.658959537572254, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '3547834', 'n_tokens_mistral': 607, 'n_tokens_neox': 569, 'n_words': 176}