Support Questions

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

how does service_check works in ambari custom stack

avatar
Contributor

I was trying to develop a service for cassandra. my question is regarding the service check method. I wrote some smoke test in service_check.py but when I install the service and do service check it tries to do service check on client node where cassandra service won't be running, so it fails. One work around I thought of is that I will provide host IP address in the smoke test so that the client executes the check on that node but then it is possible that that node is down and the service check will always fail in that case. Is there any way that I can get the IP address of all the hosts in the cluster from ambari and do Execute(smoke test) on each node unless it is passed on any one of them before ambari declare that service check failed. I see the Execute method will run the commands specified in it and if they execute correctly it will update the service check ran correctly. Below is sample code of service check.py Any help is appreciated

class ServiceCheck(Script):
    def service_check(self, env):
        import params
        env.set_params(params)
        cmdfile = format("/tmp/cmds")
        cmdfile=
        File(cmdfile,
               mode=0600,
               content=InlineTemplate("CREATE KEYSPACE IF NOT EXISTS smokedemotest WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };\n"
                                  "Use smokedemotest;\n"
                                  "CREATE TABLE IF NOT EXISTS smokeusers (firstname text,lastname text,age int,email text,city text,PRIMARY KEY (lastname));\n"
                                  "INSERT INTO smokeusers (firstname, lastname, age, email, city) VALUES ('John', 'Smith', 46, 'johnsmith@email.com', 'Sacramento');\n"
                                  "DROP TABLE smokedemotest.smokeusers;\n"
                                  "DROP KEYSPACE smokedemotest;\n\n")
        )
        Execute(format("cqlsh -f {cmdfile}"))


Currently the execute command will run on the machine on which ambari executes service check. Can you please correct my understanding how service check executes the command, how does it decides where to execute the commands( which machine?

1 ACCEPTED SOLUTION

avatar

+ @smohanty @Alejandro Fernandez

Good question! Btw have you seen this? It was developed at our last Ambari hackathon

View solution in original post

2 REPLIES 2

avatar

+ @smohanty @Alejandro Fernandez

Good question! Btw have you seen this? It was developed at our last Ambari hackathon

avatar
Contributor

Yes but this repo does not implement service check. Check my repo.So still no answer to my question. @Mark Herring may I know what I missed here. My question is still unanswered.