Skip to content
Snippets Groups Projects
Commit 1ad8a859 authored by nimrod's avatar nimrod
Browse files

Small refactor.

parent afa6fb1b
Branches
No related tags found
No related merge requests found
from utils import check_ssh, publish
import socket
from utils import publish
def check_ssh(host, port=22):
"""Check that an SSH server is available on that host and port."""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect((host, port))
msg = sock.recv(1024)
sock.close()
return msg.startswith(b"SSH-2.0-OpenSSH")
except Exception as e: # pylint: disable=broad-except,invalid-name
print(str(e))
return False
def handler(event, context): # pylint: disable=unused-argument
......
# pylint: disable=import-error
import os
import socket
import boto3
import requests
......@@ -37,15 +36,3 @@ def check_urls(checks):
message = f"Failed check for {check['url']}."
print(message)
publish(message)
def check_ssh(host, port=22):
"""Check that an SSH server is available on that host and port."""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect((host, port))
msg = sock.recv(1024)
return msg.startswith(b"SSH-2.0-OpenSSH")
except Exception as e: # pylint: disable=broad-except,invalid-name
print(str(e))
return False
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment