Skip to content

centos6/RHEL6 incompatible  #406

Closed
Closed
@tommygod3

Description

@tommygod3

Describe the bug:
After installing successfully and changing my Django settings.py, python manage.py runserver fails.
Stack trace:

 File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/contrib/django/apps.py", line 30, in ready
    self.client = get_client()
  File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/contrib/django/client.py", line 53, in get_client
    instance = client_class()
  File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/contrib/django/client.py", line 69, in __init__
    super(DjangoClient, self).__init__(config, **inline)
  File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/base.py", line 148, in __init__
    self._metrics.register(path)
  File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/metrics/base_metrics.py", line 38, in register
    self._metricsets[class_path] = class_obj()
  File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/metrics/sets/cpu_linux.py", line 30, in __init__
    self.previous.update(self.read_system_stats())
  File "/home/vagrant/miniconda3/envs/download-stats/lib/python3.7/site-packages/elasticapm/metrics/sets/cpu_linux.py", line 59, in read_system_stats

    int, whitespace_re.split(line)[1:-1]
ValueError: not enough values to unpack (expected 10, got 9)

I have looked into it and the `cpu_linux.py' expects the system stats file to have 10 fields:

if line.startswith("cpu "):
                    user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice = map(
                        int, whitespace_re.split(line)[1:-1]
                    )

However when I look at /proc/stat which is where cpu_linux.py is looking, I see it has only 9 fields:

cpu  162679 114 68061 7260831 1061 1237 1080 0 0

This has been tested on various centos6 VMs and they all had 9 fields in the system stats file. The fields are different to what cpu_linux.py expects and can be found here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-stat.

To Reproduce

  1. pip install elastic-apm on a centos6/rhel6 machine.
  2. Configure settings.py appropriately.
  3. Run python manage.py runserver.
  4. Error.

Expected behavior:

Should work on centos/rhel machines and not assume all system stats files look the same.

Environment

  • OS: centos6
  • Python version: 3.7.1
  • Framework and version: Django 2.1.2
  • APM Server version: 6.6.0
  • Agent version: 4.1.0

Additional context

My current workaround: override the decision to use cpu_linux.py in cpu.py by setting the environment variable ELASTIC_APM_FORCE_PSUTIL_METRICS. This uses cpu_psutil.py instead which requires you have installed psutil.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions