Support Questions

Find answers, ask questions, and share your expertise

HDP Ambari alert python script format

avatar
Explorer

I have been trying to create a custom ambari alert. I have created dedicated alert.json and its correspondent python script. 

I have successfully registered the alert function, but my python script is failing here. Is there any specific format which is required in python script. I have created a python script with execute function but still I get the error which says, 'module' object has no attribute 'execute'.
following is the python script,

 

 

from subprocess import check_output
def execute(configurations={}, parameters={}, host_name=None):
    try:
        pid = check_output(["pidof","servicename"])
        if pid > 0
            return "OK"
    except:
        return "CRITICAL"

if __name__ == '__main__':
  execute()

 


This is the screenshot of the alert.

sandipkumar_0-1660219215500.png

 

Please suggest if you think there is something wrong with this, I have tried making changes in python script, But I keep getting the same error.

0 REPLIES 0