cern-eos / eos_exporter

3 stars 4 forks source link

Provide eos ns inspector queries: Allowing the KPI Volume per layout #24

Closed mariayh1 closed 10 months ago

mariayh1 commented 1 year ago

The current queries done with graphite are the following:

alias(sum(eos.$instance.inspector.layout..replica..volume), 'Replica') alias(sum(eos.$instance.inspector.layout..raid6..volume), 'Erasure Coding')

mariayh1 commented 1 year ago

The metric is: eos inspector -m And the attributes that we use for our plots are: layout, type, blocksize and volume.

This is the code from graphite:

# Inspector metrics
def get_inspector_metrics(prefix):
    output = []
    if not (is_inspector_enabled()): return output

    #eos -b inspector -m 2>/dev/null
    with open(os.devnull, 'w') as devnull:
        p = subprocess.Popen(['eos', '-b', 'inspector', '-m'],stdout=subprocess.PIPE, stderr=devnull)
        for line in p.stdout:
            matches = re.findall('([a-z][\w|.]*=[\w|:|.]+)\s+', line, re.MULTILINE)
            layout = None
            for match in matches:
                metric, value = match.split('=')
                if metric == 'layout':
                    layout = re.match('[\w-]+', value).group(0)
                if metric == 'type':
                    type = re.match('[\w-]+', value).group(0)
                if metric == 'blocksize':
                    blocksize = re.match('[\w-]+', value).group(0)
                if metric in inspector_metrics:
                    data = ('.'.join([prefix, 'inspector', 'layout', layout, type,blocksize,  metric]), (int(time.time()), float(value)))
                    output.append(data)
    return output