Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Unable to execute custom ambari alert script.

Solved Go to solution

Unable to execute custom ambari alert script.

New Contributor

@jsensharma 

I followed all the steps but I m not seeing the custom alerts.

I tried executing the script but it is throwing below error: 

 

[root@xxxxx host_scripts]# python test_alert_disk_space.py
Traceback (most recent call last):
File "test_alert_disk_space.py", line 8, in <module>
from resource_management.core.logger import Logger
ImportError: No module named resource_management.core.logger

 

 

Ambari Version 2.7.3.0

HDF: 3.4.1

 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Unable to execute custom ambari alert script.

Super Mentor

@KaviTiwari 

Please make sure to set the "PYTHONPATH" variable to point to ambari agent lib directory as following:

# export PYTHONPATH=/usr/lib/ambari-agent/lib:$PYTHONPATH
# python test_alert_disk_space.py

 

.

4 REPLIES 4

Re: Unable to execute custom ambari alert script.

Super Mentor

@KaviTiwari 

Please make sure to set the "PYTHONPATH" variable to point to ambari agent lib directory as following:

# export PYTHONPATH=/usr/lib/ambari-agent/lib:$PYTHONPATH
# python test_alert_disk_space.py

 

.

Re: Unable to execute custom ambari alert script.

New Contributor

So I have to use export statement while running from console only, correct me if I am wrong.

Highlighted

Re: Unable to execute custom ambari alert script.

Super Mentor

@KaviTiwari 

Correct when we manually want to run such scripts which are dependent on ambari agent python modules then Yes, we will have to manually export PYTHONPATH.
Ambari agent automatically sets the necessary module paths in the python path when it tries to executed such scripts.  

Re: Unable to execute custom ambari alert script.

New Contributor

Thank you very much!

Don't have an account?
Coming from Hortonworks? Activate your account here