Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

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

avatar
Rising Star

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

avatar
Master 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

View solution in original post

3 REPLIES 3

avatar
Master 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

avatar
Rising Star

@Jay Kumar SenSharma, It resolves the issue

avatar
Explorer

As the description mentions that nothing from /var/lib/ambari-server/resources is populated in agent cache, I see a behavior where custom dashboard files which are placed at /var/lib/ambari-server/resources/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDP/ are also not available in /var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDP/. How to make this work?