def expand_registry_url(hostname): if hostname.startswith('http:') or hostname.startswith('https:'): if '/' not in hostname[9:]: hostname = hostname + '/v1/' return hostname if utils.ping('https://' + hostname + '_ping'): return 'https://' + hostname + '/v1/' return 'http://' + hostname + '/v1/'
def check_connection(): status_code = ping() if status_code is None: raise ValueError("Invalid Status Code") log_level, log_message = get_log_level(status_code=status_code) logging.log(log_level, log_message) return log_level == logging.INFO
def run(self): if not self.stopped: if ping(self.url) == 200: logging.info(" Service %s healthy", self.url) else: logging.warning("Service %s unavailable", self.url) # Call self.run again in 2s in a new thread (so it doesn't block) threading.Timer(2, self.run).start()
def ping(self): ip_list = self.ip_list utils.log('IP-addresses: '+', '.join(ip_list)) for ip in ip_list: utils.log('Pinging {} ({})'.format(self.name, ip)) if utils.ping(ip): utils.log('Ping successful') return ip utils.log('Ping unsuccessful') raise HostDownException
def network_check(): tf.logging.info('************NETWORK CHECK*******************') tf_config = get_tf_config() if not tf_config: return for ip in tf_config['cluster']['worker']: if ping(str(ip)): tf.logging.info('PINGING: {} - OK'.format(ip)) else: tf.logging.warning('PINGING: {} - FAILED'.format(ip)) for ip in tf_config['cluster']['ps']: if ping(str(ip)): tf.logging.info('PINGING: {} - OK'.format(ip)) else: tf.logging.warning('PINGING: {} - FAILED'.format(ip)) for ip in tf_config['cluster']['master']: if ping(str(ip)): tf.logging.info('PINGING: {} - OK'.format(ip)) else: tf.logging.warning('PINGING: {} - FAILED'.format(ip))
def status(): """ Retrieves the status of a node, including: * If it's up (responds to ping) * Whether we can login * Disk space used * Disk space available * Uptime and current load * Whether Java has been installed The status is stored on the node at ~/status/status_[hostname].txt """ # Ping it and return of it's down up = utils.ping(env.host_string, 10) puts('Host is ' + ('UP' if up else 'DOWN')) if not up: return False # Hide output while we're getting info with hide('running', 'stdout', 'stderr'): # Check if we can SSH in and run a command try: run('whoami') except SystemExit: puts('Unable to log in!') return False # Get the status info disk = run('df -h').split('\n')[1].split() uptime = run('uptime') java = run('java -version 2>&1 | head -1') python = run('python --version 2>&1') # Make status folder if necessary run('mkdir -p status') status_file = './status/status_%s.txt' % env.host_string # Empty or make status file run('echo -n > %s' % status_file) # Write status to file append('Disk space used: %s' % disk[2], status_file) append('Disk space free: %s' % disk[3], status_file) append('Uptime and load: %s' % uptime, status_file) append('Java: %s' % ('not installed' if java.failed else java), status_file) append('Python: %s' % ('not installed' if python.failed else python), status_file) # Print out status that was written run('cat %s' % status_file) return True
async def handle_start_ping(alice_request): user_id = alice_request.session.user_id request_text = alice_request.request.original_utterance addr = request_text if 'мой сервер' in request_text: addr = SKOLTECH_URL result = utils.ping(addr) await dp.storage.set_state(user_id, UserStates.SELECT_COMMAND) if result == 0: return alice_request.response('Пакетики доставлены. Что дальше ?', buttons=meta.action_buttons) else: return alice_request.response('Пакетики не доставлены. Что дальше ?', buttons=meta.action_buttons)
def _stop_remote_redis(host): while True: try: cmd = "pkill -15 redis-server" exec_remote(host, cmd, exectimeout=7) except Exp, e: dwarn(e) try: cmd = "ps aux|grep -v grep|grep redis-server" exec_remote(host, cmd, exectimeout=7) except Exp, e: dwarn(e) p = ping(host) if p: dwarn("redis-server stopped!") else: dwarn("%s network down!" % (host)) break
async def handle_start_attack(alice_request): user_id = alice_request.session.user_id request_text = alice_request.request.original_utterance print(request_text) addr = request_text if 'мой сервер' in request_text: addr = SKOLTECH_URL result = utils.ping(addr) if result == 0: proc = subprocess.Popen( ['python', './src/test_http.py', addr] ) await dp.storage.update_data(user_id=user_id, data={'dos': proc}) await dp.storage.set_state(user_id, DosStates.START_ATTACK) print(proc.pid) return alice_request.response('Атака на Сколтех началась') else: await dp.storage.set_state(user_id, UserStates.SELECT_COMMAND) return alice_request.response('Невалидный хост')
def send_ping(): print("Sending ping to server...", end='\t', flush=True) response = ping() print("response code:", response)
# -- The received message is in raw bytes msg_raw = cs.recv(2048) # -- We decode it for converting it # -- into a human-redeable string msg = msg_raw.decode() formatted_message = utils.format_command(msg) formatted_message = formatted_message.split(" ") if len(formatted_message) == 1: command = formatted_message[0] else: command = formatted_message[0] argument = formatted_message[1] if command == "PING": utils.ping() # -- Send a response message to the client response = "OK!" # -- The message has to be encoded into bytes cs.send(str(response).encode()) elif command == "GET": utils.get(cs, list_sequences, argument) elif command == "INFO": utils.calc(cs) elif command == "COMP": utils.comp(cs, list_sequences, argument) elif command == "REV": utils.rev(cs, list_sequences, argument) elif command == "GENE": utils.gene(cs, argument)
def send_ping(url): logging.info("Sending ping to %s...", url) start = time.time() response = ping(url) logging.debug("Ping took %.02fs to respond", time.time() - start) logging.info("response code: %s\n", response)
def send_ping(url): logging.info("Sending ping to %s...", url) response = ping(url) logging.info("response code: %s\n", response)
def get_available_server(): for server in servers: if utils.ping(server): print("server active:" + server) return server return None
def test_is_postgres_service_reachable(self): """Check the Postgres service is reachable by pinging it""" self.assertTrue(ping("db"))