You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ambari.apache.org by Souvik Sarkhel <so...@gmail.com> on 2016/04/18 10:27:59 UTC

Ambari - Trouble Checking Status for Custom Application

Hi All,

I have created a custom service for Zookeeper and using Ambari 2.1.0 .In
status function of master.py if its defined in this way:
*def status(self, env):*
*        config = Script.get_config()*
*        zkDataDir = config['configurations']['zoo']['dataDir']*
*        print 'Status of the Zookeeper Master'*
*        print ******************************************
*        print zkDataDir*
*        dummy_master_pid_file = format("{zkDataDir}/zookeeper_server.pid")*
*        check_process_status(dummy_master_pid_file) *

Ambari is always showing status of application stopped but when I provide
the constant path of the pid file for example:

*dummy_master_pid_file = "/usr/share/zookeeper/tmp/zookeeper_server.pid")*

it starts working perfectly and Ambari is able to correctly show the status
of the application. I need a variable pid file instead of a constant one. I
would to thankful if someone suggest me a way out.

Thanking you in advance

-- 
Souvik Sarkhel

Re: Ambari - Trouble Checking Status for Custom Application

Posted by Jonathan Hurley <jh...@hortonworks.com>.
Ah, I had forgotten this was a status command. The print statements will also appear in /var/log/ambari-agent/ambari-agent.out

On Apr 19, 2016, at 1:08 AM, Souvik Sarkhel <so...@gmail.com>> wrote:

When will the command run as far as I know Ambari automatically invokes the status function.

On Mon, Apr 18, 2016 at 7:50 PM, Jonathan Hurley <jh...@hortonworks.com>> wrote:
When your command runs, it will show up in the UI as something like "command-123.json". You'll match this up to the "output" file on the agent:
/var/lib/ambari-agent/data/output-123.txt

You're not printing the value of dummy_master_pid_file in your example below; you'll want to print that as well to make sure it's rendering properly. Are you sure you have the directories correct? You're trying to use zoo/dataDir as the placeholder which renders to "/usr/share/zookeeper/tmp". You'll need to make sure that your "zoo" config has dataDir set to /usr/share/zookeeper/tmp

On Apr 18, 2016, at 9:44 AM, Souvik Sarkhel <so...@gmail.com>> wrote:

Hi Jonathan,
Earlier I was using
from resource_management import *
now I have added this import statement also
from resource_management.libraries.functions.format import format
and also given 777 permission till the intended pid file. Still its not working.

Can you please tell me from where can I see the print statements which I provide in status function so that I can debug the function.

On Mon, Apr 18, 2016, 18:35 Jonathan Hurley <jh...@hortonworks.com>> wrote:
What are your import statements? The "format" function provided by Ambari's common library has a naming conflict with a default python function named "format". If you don't import the right one, your format("...") command will fail silently. Make sure you are importing:

from resource_management.libraries.functions.format import format

On Apr 18, 2016, at 4:27 AM, Souvik Sarkhel <so...@gmail.com>> wrote:

Hi All,

I have created a custom service for Zookeeper and using Ambari 2.1.0 .In status function of master.py if its defined in this way:
def status(self, env):
        config = Script.get_config()
        zkDataDir = config['configurations']['zoo']['dataDir']
        print 'Status of the Zookeeper Master'
        print *****************************************
        print zkDataDir
        dummy_master_pid_file = format("{zkDataDir}/zookeeper_server.pid")
        check_process_status(dummy_master_pid_file)

Ambari is always showing status of application stopped but when I provide the constant path of the pid file for example:

dummy_master_pid_file = "/usr/share/zookeeper/tmp/zookeeper_server.pid")

it starts working perfectly and Ambari is able to correctly show the status of the application. I need a variable pid file instead of a constant one. I would to thankful if someone suggest me a way out.

Thanking you in advance

--
Souvik Sarkhel





--
Souvik Sarkhel


Re: Ambari - Trouble Checking Status for Custom Application

Posted by Souvik Sarkhel <so...@gmail.com>.
When will the command run as far as I know Ambari automatically invokes the
status function.

On Mon, Apr 18, 2016 at 7:50 PM, Jonathan Hurley <jh...@hortonworks.com>
wrote:

> When your command runs, it will show up in the UI as something like
> "command-123.json". You'll match this up to the "output" file on the agent:
> /var/lib/ambari-agent/data/output-123.txt
>
> You're not printing the value of dummy_master_pid_file in your example
> below; you'll want to print that as well to make sure it's rendering
> properly. Are you sure you have the directories correct? You're trying to
> use zoo/dataDir as the placeholder which renders to
> "/usr/share/zookeeper/tmp". You'll need to make sure that your "zoo" config
> has dataDir set to /usr/share/zookeeper/tmp
>
> On Apr 18, 2016, at 9:44 AM, Souvik Sarkhel <so...@gmail.com>
> wrote:
>
> Hi Jonathan,
> Earlier I was using
>
> *from resource_management import * *
> now I have added this import statement also
> from resource_management.libraries.functions.format import format
> and also given 777 permission till the intended pid file. Still its not
> working.
>
> Can you please tell me from where can I see the print statements which I
> provide in status function so that I can debug the function.
>
> On Mon, Apr 18, 2016, 18:35 Jonathan Hurley <jh...@hortonworks.com>
> wrote:
>
>> What are your import statements? The "format" function provided by
>> Ambari's common library has a naming conflict with a default python
>> function named "format". If you don't import the right one, your
>> format("...") command will fail silently. Make sure you are importing:
>>
>> from resource_management.libraries.functions.format import format
>>
>> On Apr 18, 2016, at 4:27 AM, Souvik Sarkhel <so...@gmail.com>
>> wrote:
>>
>> Hi All,
>>
>> I have created a custom service for Zookeeper and using Ambari 2.1.0 .In
>> status function of master.py if its defined in this way:
>> *def status(self, env):*
>> *        config = Script.get_config()*
>> *        zkDataDir = config['configurations']['zoo']['dataDir']*
>> *        print 'Status of the Zookeeper Master'*
>> *        print ******************************************
>> *        print zkDataDir*
>> *        dummy_master_pid_file =
>> format("{zkDataDir}/zookeeper_server.pid")*
>> *        check_process_status(dummy_master_pid_file) *
>>
>> Ambari is always showing status of application stopped but when I provide
>> the constant path of the pid file for example:
>>
>> *dummy_master_pid_file = "/usr/share/zookeeper/tmp/zookeeper_server.pid")*
>>
>> it starts working perfectly and Ambari is able to correctly show the
>> status of the application. I need a variable pid file instead of a constant
>> one. I would to thankful if someone suggest me a way out.
>>
>> Thanking you in advance
>>
>> --
>> Souvik Sarkhel
>>
>>
>>
>


-- 
Souvik Sarkhel

Re: Ambari - Trouble Checking Status for Custom Application

Posted by Jonathan Hurley <jh...@hortonworks.com>.
When your command runs, it will show up in the UI as something like "command-123.json". You'll match this up to the "output" file on the agent:
/var/lib/ambari-agent/data/output-123.txt

You're not printing the value of dummy_master_pid_file in your example below; you'll want to print that as well to make sure it's rendering properly. Are you sure you have the directories correct? You're trying to use zoo/dataDir as the placeholder which renders to "/usr/share/zookeeper/tmp". You'll need to make sure that your "zoo" config has dataDir set to /usr/share/zookeeper/tmp

On Apr 18, 2016, at 9:44 AM, Souvik Sarkhel <so...@gmail.com>> wrote:

Hi Jonathan,
Earlier I was using
from resource_management import *
now I have added this import statement also
from resource_management.libraries.functions.format import format
and also given 777 permission till the intended pid file. Still its not working.

Can you please tell me from where can I see the print statements which I provide in status function so that I can debug the function.

On Mon, Apr 18, 2016, 18:35 Jonathan Hurley <jh...@hortonworks.com>> wrote:
What are your import statements? The "format" function provided by Ambari's common library has a naming conflict with a default python function named "format". If you don't import the right one, your format("...") command will fail silently. Make sure you are importing:

from resource_management.libraries.functions.format import format

On Apr 18, 2016, at 4:27 AM, Souvik Sarkhel <so...@gmail.com>> wrote:

Hi All,

I have created a custom service for Zookeeper and using Ambari 2.1.0 .In status function of master.py if its defined in this way:
def status(self, env):
        config = Script.get_config()
        zkDataDir = config['configurations']['zoo']['dataDir']
        print 'Status of the Zookeeper Master'
        print *****************************************
        print zkDataDir
        dummy_master_pid_file = format("{zkDataDir}/zookeeper_server.pid")
        check_process_status(dummy_master_pid_file)

Ambari is always showing status of application stopped but when I provide the constant path of the pid file for example:

dummy_master_pid_file = "/usr/share/zookeeper/tmp/zookeeper_server.pid")

it starts working perfectly and Ambari is able to correctly show the status of the application. I need a variable pid file instead of a constant one. I would to thankful if someone suggest me a way out.

Thanking you in advance

--
Souvik Sarkhel



Re: Ambari - Trouble Checking Status for Custom Application

Posted by Souvik Sarkhel <so...@gmail.com>.
Hi Jonathan,
Earlier I was using

*from resource_management import **
now I have added this import statement also
from resource_management.libraries.functions.format import format
and also given 777 permission till the intended pid file. Still its not
working.

Can you please tell me from where can I see the print statements which I
provide in status function so that I can debug the function.

On Mon, Apr 18, 2016, 18:35 Jonathan Hurley <jh...@hortonworks.com> wrote:

> What are your import statements? The "format" function provided by
> Ambari's common library has a naming conflict with a default python
> function named "format". If you don't import the right one, your
> format("...") command will fail silently. Make sure you are importing:
>
> from resource_management.libraries.functions.format import format
>
> On Apr 18, 2016, at 4:27 AM, Souvik Sarkhel <so...@gmail.com>
> wrote:
>
> Hi All,
>
> I have created a custom service for Zookeeper and using Ambari 2.1.0 .In
> status function of master.py if its defined in this way:
> *def status(self, env):*
> *        config = Script.get_config()*
> *        zkDataDir = config['configurations']['zoo']['dataDir']*
> *        print 'Status of the Zookeeper Master'*
> *        print ******************************************
> *        print zkDataDir*
> *        dummy_master_pid_file =
> format("{zkDataDir}/zookeeper_server.pid")*
> *        check_process_status(dummy_master_pid_file) *
>
> Ambari is always showing status of application stopped but when I provide
> the constant path of the pid file for example:
>
> *dummy_master_pid_file = "/usr/share/zookeeper/tmp/zookeeper_server.pid")*
>
> it starts working perfectly and Ambari is able to correctly show the
> status of the application. I need a variable pid file instead of a constant
> one. I would to thankful if someone suggest me a way out.
>
> Thanking you in advance
>
> --
> Souvik Sarkhel
>
>
>

Re: Ambari - Trouble Checking Status for Custom Application

Posted by Jonathan Hurley <jh...@hortonworks.com>.
What are your import statements? The "format" function provided by Ambari's common library has a naming conflict with a default python function named "format". If you don't import the right one, your format("...") command will fail silently. Make sure you are importing:

from resource_management.libraries.functions.format import format

On Apr 18, 2016, at 4:27 AM, Souvik Sarkhel <so...@gmail.com>> wrote:

Hi All,

I have created a custom service for Zookeeper and using Ambari 2.1.0 .In status function of master.py if its defined in this way:
def status(self, env):
        config = Script.get_config()
        zkDataDir = config['configurations']['zoo']['dataDir']
        print 'Status of the Zookeeper Master'
        print *****************************************
        print zkDataDir
        dummy_master_pid_file = format("{zkDataDir}/zookeeper_server.pid")
        check_process_status(dummy_master_pid_file)

Ambari is always showing status of application stopped but when I provide the constant path of the pid file for example:

dummy_master_pid_file = "/usr/share/zookeeper/tmp/zookeeper_server.pid")

it starts working perfectly and Ambari is able to correctly show the status of the application. I need a variable pid file instead of a constant one. I would to thankful if someone suggest me a way out.

Thanking you in advance

--
Souvik Sarkhel