def _get_swarm_stat(self): leader = get_etcd_value("/lain/swarm/docker/swarm/leader") cmd = [ "timeout", "3", "docker", "-H", "swarm.lain:%d" % self._swarm_manager_port, "version" ] is_healthy = 0 is_alive = 0 has_leader = 0 if leader != "": has_leader = 1 with open("/dev/null", "w") as f: if subprocess.call(cmd, stdout=f) == 0: is_alive = 1 cmd[5] = "info" if subprocess.call(cmd, stdout=f) == 0: is_healthy = 1 self._result.append( GraphiteData("lain.cluster.swarm.alive", self._endpoint, is_alive, self._step, "status")) self._result.append( GraphiteData("lain.cluster.swarm.health", self._endpoint, is_healthy, self._step, "status")) self._result.append( GraphiteData("lain.cluster.swarm.leaderkey", self._endpoint, has_leader, self._step, "status"))
def _get_swarm_stat(self): leader = get_etcd_value("/lain/swarm/docker/swarm/leader") cmd = ["timeout", "3", "docker", "-H", "swarm.lain:%d" % self._swarm_manager_port, "version"] is_healthy = 0 is_alive = 0 has_leader = 0 if leader != "": has_leader = 1 with open("/dev/null", "w") as f: if subprocess.call(cmd, stdout=f) == 0: is_alive = 1 cmd[5] = "info" if subprocess.call(cmd, stdout=f) == 0: is_healthy = 1 self._result.append( GraphiteData("lain.cluster.swarm.alive", self._endpoint, is_alive, self._step, "status")) self._result.append( GraphiteData("lain.cluster.swarm.health", self._endpoint, is_healthy, self._step, "status")) self._result.append( GraphiteData("lain.cluster.swarm.leaderkey", self._endpoint, has_leader, self._step, "status"))
def _collect_deployd_debug_info(self): is_alive = 0 try: domain = get_etcd_value("/lain/config/domain") resp = requests.get( "http://deployd.lain:%d/debug/vars" % self._deployd_port, timeout=1) if resp.status_code == 200: is_alive = 1 except Exception: pass self._result.append( GraphiteData("lain.cluster.deployd.alive", self._endpoint, is_alive, self._step, "status"))
def _collect_deployd_debug_info(self): is_alive = 0 try: domain = get_etcd_value("/lain/config/domain") resp = requests.get("http://deployd.lain:%d/debug/vars" % self._deployd_port, timeout=1) if resp.status_code == 200: is_alive = 1 except Exception: pass self._result.append( GraphiteData("lain.cluster.deployd.alive", self._endpoint, is_alive, self._step, "status"))