Support Questions

Find answers, ask questions, and share your expertise

ambari-metrics-monitor not starting. ImportError: cannot import name _common

avatar
New Contributor

I have 7 nodes configured as follows: 3 MasterNodes, 1 AdminNode 3 DataNodes. The ambari-metrics-monitor is starting fine in the DataNodes but for the rest of nodes is throwing the following error:

 from metric_collector import MetricsCollector
  File "/usr/lib/python2.6/site-packages/resource_monitoring/core/metric_collector.py", line 23, in <module>
    from host_info import HostInfo
  File "/usr/lib/python2.6/site-packages/resource_monitoring/core/host_info.py", line 22, in <module>
    import psutil
  File "/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build/lib.linux-x86_64-2.6/psutil/__init__.py", line 89, in <module>
    import psutil._pslinux as _psplatform
  File "/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build/lib.linux-x86_64-2.6/psutil/_pslinux.py", line 20, in <module>
    from psutil import _common
ImportError: cannot import name _common

I have uninstalled and installed again the ambari-metrics-monitor with no success. Any thoughts or alternatives to solve this problem??

I have a single Python v2.2.6 in all nodes. HDP 2.4. Ambari 2.2.1

1 ACCEPTED SOLUTION

avatar
Master Guru

I saw this, and I think it's fixed in latest Ambari versions. Can you try:

cd /usr/lib/python2.6/site-packages/resource_monitoring/
python psutil/build.py

and restart metrics monitors.

View solution in original post

6 REPLIES 6

avatar
Master Guru

I saw this, and I think it's fixed in latest Ambari versions. Can you try:

cd /usr/lib/python2.6/site-packages/resource_monitoring/
python psutil/build.py

and restart metrics monitors.

avatar
New Contributor

This worked just fine!! Thanks @Predrag Minovic!

avatar
New Contributor

Thank you it worked 🙂 @Predrag Minovic

As am just starting on Ambari and HDP

Kindly shed some light on what was the problem about and how can it be avoided in future?

avatar
Guru

@Predrag Minovic. I also had same issue and I tried to apply your given workaround but it failed with following error.

[ams@server resource_monitoring]$ python psutil/build.py

Executing make at location: /usr/lib/python2.6/site-packages/resource_monitoring/psutil

psutil build failed. Please find build output at: /usr/lib/python2.6/site-packages/resource_monitoring/psutil/build.out

When I checked given build.out file it gave me following output. So Can you please help me to resolve it.

rm -f `find . -type f -name \*.py[co]`

rm -f `find . -type f -name \*.so`

rm -f `find . -type f -name .\*~`

rm -f `find . -type f -name \*.orig`

rm -f `find . -type f -name \*.bak`

rm -f `find . -type f -name \*.rej`

rm -rf `find . -type d -name __pycache__`

rm -rf *.egg-info

rm -rf *\estfile*

rm -rf build

rm -rf dist

rm -rf docs/_build

python setup.py build

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.6

creating build/lib.linux-x86_64-2.6/psutil

copying psutil/__init__.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_psosx.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_psposix.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_common.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_compat.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.6/psutil

copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.6/psutil

running build_ext

building '_psutil_linux' extension

creating build/temp.linux-x86_64-2.6

creating build/temp.linux-x86_64-2.6/psutil

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.6 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_linux.o

psutil/_psutil_linux.c: In function ‘psutil_proc_cpu_affinity_set’:

psutil/_psutil_linux.c:327: warning: suggest explicit braces to avoid ambiguous ‘else’

gcc -pthread -shared build/temp.linux-x86_64-2.6/psutil/_psutil_linux.o -L/usr/lib64 -lpython2.6 -o build/lib.linux-x86_64-2.6/_psutil_linux.so

/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crti.o: could not read symbols: File in wrong format

collect2: ld returned 1 exit status

error: command 'gcc' failed with exit status 1

make: *** [build] Error 1

avatar
Explorer

Hello Guys,

I used a RHEL 7 and I have Python 2.7 and this is not building the psutils.

Is there any workaround ?

Best regards

avatar
Explorer

You may also tried :

cd /usr/lib/python2.6/site-packages/resource_monitoring/psutil
python setup.py build