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.

ambari custom alert script in host_scripts is not populating to the agent cache after ambari server and agent restart

Solved Go to solution
Highlighted

ambari custom alert script in host_scripts is not populating to the agent cache after ambari server and agent restart

Cloudera Employee

https://community.hortonworks.com/articles/38149/how-to-create-and-register-custom-ambari-alerts.htm... doesn't seems to be working with ambari 2.7.1, stuck at step 3)


No exception in ambari server or agent logs


@Jay Kumar SenSharma

1 ACCEPTED SOLUTION

Accepted Solutions

Re: ambari custom alert script in host_scripts is not populating to the agent cache after ambari server and agent restart

Super Mentor

@Franklin

Please try this:

1. On ambari agent host please find this script "/usr/lib/ambari-agent/lib/ambari_agent/CustomServiceOrchestrator.py" and then search for a string with 'if the return type is not used'

# grep -A2 'if the return type is not used' /usr/lib/ambari-agent/lib/ambari_agent/CustomServiceOrchestrator.py
        # if the return type is not used
        base_dir = self.file_cache.get_service_base_dir(command)
        script_path = self.resolve_script_path(base_dir, script)

.

2. Just add a new line on all agent hosts self.file_cache.get_host_scripts_base_dir(command) there as following Just below the commented line:

# grep -A2 'if the return type is not used' /usr/lib/ambari-agent/lib/ambari_agent/CustomServiceOrchestrator.py
        # if the return type is not used
        self.file_cache.get_host_scripts_base_dir(command)
        base_dir = self.file_cache.get_service_base_dir(command)
        script_path = self.resolve_script_path(base_dir, script)

.

**NOTE:** Python is Indentation sensitive so you will need to put the same indentation while adding the line there (else it might cause some syntax error)

3. Clear the Agent Cache Dir (or move it as backup)

# mv /var/lib/ambari-agent/cache /var/lib/ambari-agent/cache_OLD

.

4. Restart the ambari server and agent.

# ambari-server restart
# ambari-agent restart 

.

5. Now check the host script dir if it has pulled file the custom scripts from ambari server host.

# ls -lart /var/lib/ambari-agent/cache/host_scripts/


.

It looks related to: https://issues.apache.org/jira/browse/AMBARI-25123

2 REPLIES 2

Re: ambari custom alert script in host_scripts is not populating to the agent cache after ambari server and agent restart

Super Mentor

@Franklin

Please try this:

1. On ambari agent host please find this script "/usr/lib/ambari-agent/lib/ambari_agent/CustomServiceOrchestrator.py" and then search for a string with 'if the return type is not used'

# grep -A2 'if the return type is not used' /usr/lib/ambari-agent/lib/ambari_agent/CustomServiceOrchestrator.py
        # if the return type is not used
        base_dir = self.file_cache.get_service_base_dir(command)
        script_path = self.resolve_script_path(base_dir, script)

.

2. Just add a new line on all agent hosts self.file_cache.get_host_scripts_base_dir(command) there as following Just below the commented line:

# grep -A2 'if the return type is not used' /usr/lib/ambari-agent/lib/ambari_agent/CustomServiceOrchestrator.py
        # if the return type is not used
        self.file_cache.get_host_scripts_base_dir(command)
        base_dir = self.file_cache.get_service_base_dir(command)
        script_path = self.resolve_script_path(base_dir, script)

.

**NOTE:** Python is Indentation sensitive so you will need to put the same indentation while adding the line there (else it might cause some syntax error)

3. Clear the Agent Cache Dir (or move it as backup)

# mv /var/lib/ambari-agent/cache /var/lib/ambari-agent/cache_OLD

.

4. Restart the ambari server and agent.

# ambari-server restart
# ambari-agent restart 

.

5. Now check the host script dir if it has pulled file the custom scripts from ambari server host.

# ls -lart /var/lib/ambari-agent/cache/host_scripts/


.

It looks related to: https://issues.apache.org/jira/browse/AMBARI-25123

Re: ambari custom alert script in host_scripts is not populating to the agent cache after ambari server and agent restart

Cloudera Employee

@Jay Kumar SenSharma, It resolves the issue