You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ambari.apache.org by Constantine Yarovoy <ky...@gmail.com> on 2015/11/16 10:00:41 UTC

Service component status method code

Hi all.

I'm developing my own stack for Ambari and right now I have a problem with
component status determination procedure.

I have something like this in my master component code:

def status(self,env):
 code, out = shell.call("systemctl status my-service | grep Active: | awk
'{ print $2 }'", logoutput=True)
 state = (False,True)[out == "active"]

if not state:
 raise ComponentIsNotRunning()

If I use this code - component state in web ui is always marked as stopped.

Can someone suggest what am I doing wrong ? What return value is expected
in status method to identify component as "running" ?

Thanks in advance.

Re: Service component status method code

Posted by Bhuvnesh Chaudhary <bc...@pivotal.io>.
Hello Constantine,

What version of ambari are you using ?

Also, You can check in the ambari agent log, it will log an entry for
service check which you can run from command line and and see the output to
debug it further. (If you don't see it by default, set debug log to be
logged in the ambari-agent.ini)

It will be of the form (example below)
/usr/bin/python2.6
/var/lib/ambari-agent/cache/stacks/PHD/3.3/services/HAWQ/package/scripts/hawqmaster.py
STATUS /var/lib/ambari-agent/data/status_command.json
/var/lib/ambari-agent/cache/stacks/PHD/3.3/services/HAWQ/package
/var/lib/ambari-agent/data/structured-out-status.json DEBUG
/var/lib/ambari-agent/data/tmp

Once you get the command, go to command line on that node and execute the
command to verify the result.
If there is no exception raised in the status, by default it will mark the
status as running i believe, you just need to ensure that there is no error
/ exception occurring during the execution performed under status method.

Thanks,
Bhuvnesh Chaudhary
Email: bchau <bc...@gopivotal.com>dhary@pivotal.io
Desk: +1-650-846-1696 | Mobile: +1-973-906-6976

On Mon, Nov 16, 2015 at 1:00 AM, Constantine Yarovoy <ky...@gmail.com>
wrote:

> Hi all.
>
> I'm developing my own stack for Ambari and right now I have a problem with
> component status determination procedure.
>
> I have something like this in my master component code:
>
> def status(self,env):
>  code, out = shell.call("systemctl status my-service | grep Active: | awk
> '{ print $2 }'", logoutput=True)
>  state = (False,True)[out == "active"]
>
> if not state:
>  raise ComponentIsNotRunning()
>
> If I use this code - component state in web ui is always marked as stopped.
>
> Can someone suggest what am I doing wrong ? What return value is expected
> in status method to identify component as "running" ?
>
> Thanks in advance.
>
>