diff --git a/status.py b/status.py index b2afd43..7f1e2fe 100644 --- a/status.py +++ b/status.py @@ -1,4 +1,5 @@ import argparse +from pythonping import ping import sys def parseArguments(): @@ -22,9 +23,16 @@ def parseArguments(): # Mostrar el mensaje de ayuda parser.print_help() exit() - + +def check_ping(host): + try: + response = ping(host, count=4, timeout=2) # verbose=True -> Para ver la respuesta del ping + return True if response.success() else False + except Exception as e: + print(f"Error making ping to {host}: {e}") + return False if __name__ == '__main__': args = parseArguments() - print(args) \ No newline at end of file + print(check_ping(args))