Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors spawned by agent.py on Alpine linux #3665

Open
dirkmoors opened this issue Feb 8, 2018 · 2 comments
Open

Errors spawned by agent.py on Alpine linux #3665

dirkmoors opened this issue Feb 8, 2018 · 2 comments

Comments

@dirkmoors
Copy link

, data, cpu_m, filter_value=110)
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 627, in get_value
    value = to_float(data[legend.index(name)])
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 30, in <lambda>
    to_float = lambda s: float(s.replace(",", "."))
ValueError: invalid literal for float(): 1.00
2018-02-08 20:25:28,542 | ERROR | dd.collector | checks.collector(unix.py:220) | Cannot extract IO statistics
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 139, in check
    io.update(self._parse_linux2(stdout))
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 42, in _parse_linux2
    recentStats = output.split('Device:')[2].split('\n')
IndexError: list index out of range
2018-02-08 20:25:28,592 | INFO | dd.collector | checks.collector(collector.py:830) | gohai file not found
2018-02-08 20:25:28,835 | INFO | dd.collector | checks.collector(collector.py:543) | Finished run #4. Collection time: 4.21s. Emit time: 0.13s
2018-02-08 20:25:46,877 | ERROR | dd.collector | checks.collector(unix.py:781) | Cannot compute CPU stats
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 676, in check
    cpu_metrics[cpu_m] = get_value(headers, data, cpu_m, filter_value=110)
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 627, in get_value
    value = to_float(data[legend.index(name)])
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 30, in <lambda>
    to_float = lambda s: float(s.replace(",", "."))
ValueError: invalid literal for float(): 1.05
2018-02-08 20:25:47,906 | ERROR | dd.collector | checks.collector(unix.py:220) | Cannot extract IO statistics
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 139, in check
    io.update(self._parse_linux2(stdout))
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 42, in _parse_linux2
    recentStats = output.split('Device:')[2].split('\n')
IndexError: list index out of range
2018-02-08 20:25:48,144 | INFO | dd.collector | checks.collector(collector.py:543) | Finished run #5. Collection time: 4.17s. Emit time: 0.11s
2018-02-08 20:25:48,150 | INFO | dd.collector | checks.collector(collector.py:546) | First flushes done, next flushes will be logged every 10 flushes.
2018-02-08 20:26:06,186 | ERROR | dd.collector | checks.collector(unix.py:781) | Cannot compute CPU stats
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 676, in check
    cpu_metrics[cpu_m] = get_value(headers, data, cpu_m, filter_value=110)
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 627, in get_value
    value = to_float(data[legend.index(name)])
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 30, in <lambda>
    to_float = lambda s: float(s.replace(",", "."))
ValueError: invalid literal for float(): 0.51
2018-02-08 20:26:07,218 | ERROR | dd.collector | checks.collector(unix.py:220) | Cannot extract IO statistics
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 139, in check
    io.update(self._parse_linux2(stdout))
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 42, in _parse_linux2
    recentStats = output.split('Device:')[2].split('\n')
IndexError: list index out of range
2018-02-08 20:26:25,486 | ERROR | dd.collector | checks.collector(unix.py:781) | Cannot compute CPU stats
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 676, in check
    cpu_metrics[cpu_m] = get_value(headers, data, cpu_m, filter_value=110)
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 627, in get_value
    value = to_float(data[legend.index(name)])
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 30, in <lambda>
    to_float = lambda s: float(s.replace(",", "."))
ValueError: invalid literal for float(): 0.76
2018-02-08 20:26:26,516 | ERROR | dd.collector | checks.collector(unix.py:220) | Cannot extract IO statistics
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 139, in check
    io.update(self._parse_linux2(stdout))
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 42, in _parse_linux2
    recentStats = output.split('Device:')[2].split('\n')
IndexError: list index out of range
2018-02-08 20:26:44,778 | ERROR | dd.collector | checks.collector(unix.py:781) | Cannot compute CPU stats
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 676, in check
    cpu_metrics[cpu_m] = get_value(headers, data, cpu_m, filter_value=110)
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 627, in get_value
    value = to_float(data[legend.index(name)])
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 30, in <lambda>
    to_float = lambda s: float(s.replace(",", "."))
ValueError: invalid literal for float(): 0.25
2018-02-08 20:26:45,808 | ERROR | dd.collector | checks.collector(unix.py:220) | Cannot extract IO statistics
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 139, in check
    io.update(self._parse_linux2(stdout))
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 42, in _parse_linux2
    recentStats = output.split('Device:')[2].split('\n')
IndexError: list index out of range
2018-02-08 20:26:45,859 | INFO | dd.collector | checks.collector(collector.py:830) | gohai file not found
@dirkmoors
Copy link
Author

dirkmoors commented Feb 12, 2018

My guess is that these checks have not been tested on Alpine Linux at all.

First of all, I would rewrite

to_float = lambda s: float(s.replace(",", "."))

to something like this:

def to_float(s):
    FLOAT = re.compile(r'[0-9]+\.[0-9]+')
    matches = FLOAT.findall(s)
    if not matches:
        return -1.0
    return float(matches[0])

This is needed because the current "get_subprocess_output" will append strange byte-chars to the values, like '�'.

Secondly, I would update the "IO._parse_linux2" function to something like this:

class IO(Check):
    ...
    def _parse_linux2(self, output):        
        TABLE_RE = re.compile(r'([a-zA-Z0-9([a-zA-Z0-9\%\/\._-]+)')

        iostats = {}
        header = []
        lines = output.split('\n')
        for i, line in enumerate(lines):
            if line.startswith('Device'):
                header = TABLE_RE.findall(lines[i])
                assert header[0] == 'Device'
            elif line.strip() == '':
                header = []
                continue

            values = TABLE_RE.findall(lines[i + 1])
            if values and len(values) == len(header):
                device = values[0]
                iostats[device] = {}
                for i, key in enumerate(header[1:]):
                    iostats[device][key] = float(values[i + 1])
        return iostats
    ...

This will parse the table more robustly imho.

This approach is still not providing all required statistics, but it might help in the right direction.

Bottom line: please add better support for Alpine Linux :)

@farzadanooshah
Copy link

any update on the reported issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants