From 35859c1a21d7c540c1a2abf95c2c873874905c80 Mon Sep 17 00:00:00 2001 From: Barak Hoffer Date: Thu, 8 Oct 2015 13:30:36 +0300 Subject: [PATCH] - minor bug fixes --- chaos_monkey/config.py | 8 ++++---- chaos_monkey/network/network_scanner.py | 4 ++-- chaos_monkey/network/tcp_scanner.py | 2 +- chaos_monkey/network/tools.py | 8 +++++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/chaos_monkey/config.py b/chaos_monkey/config.py index f0dc32ec5..91fd948e4 100644 --- a/chaos_monkey/config.py +++ b/chaos_monkey/config.py @@ -101,10 +101,10 @@ class Configuration(object): singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}" # how long to wait between scan iterations - timeout_between_iterations = 120 + timeout_between_iterations = 10 # how many scan iterations to perform on each run - max_iterations = 5 + max_iterations = 3 scanner_class = TcpScanner finger_classes = (PingScanner, SSHFinger, SMBFinger) @@ -130,11 +130,11 @@ class Configuration(object): #range_class = RelativeRange range_size = 8 range_class = FixedRange - range_fixed = ("10.0.0.9", "10.0.0.13", "192.168.1.100", "192.168.1.87") + range_fixed = ("10.0.0.9", "10.0.0.13", "192.168.1.87") # TCP Scanner tcp_target_ports = [22, 445, 135, 3389] - tcp_scan_timeout = 1000 # 1000 Milliseconds + tcp_scan_timeout = 3000 # 3000 Milliseconds tcp_scan_interval = 200 tcp_scan_get_banner = True diff --git a/chaos_monkey/network/network_scanner.py b/chaos_monkey/network/network_scanner.py index 9e05a6222..ee63f1dca 100644 --- a/chaos_monkey/network/network_scanner.py +++ b/chaos_monkey/network/network_scanner.py @@ -43,7 +43,7 @@ class NetworkScanner(object): victims_count = 0 for range in self._ranges: - LOG.debug("Scanning for potantional victims in the network %r", range) + LOG.debug("Scanning for potential victims in the network %r", range) for victim in range: # skip self IP address if victim.ip_addr in self._ip_addresses: @@ -53,7 +53,7 @@ class NetworkScanner(object): # if scanner detect machine is up, add it to victims list if scanner.is_host_alive(victim): - LOG.debug("Found potational victim: %r", victim) + LOG.debug("Found potential victim: %r", victim) victims_count += 1 yield victim diff --git a/chaos_monkey/network/tcp_scanner.py b/chaos_monkey/network/tcp_scanner.py index 884822584..f088c562a 100644 --- a/chaos_monkey/network/tcp_scanner.py +++ b/chaos_monkey/network/tcp_scanner.py @@ -26,7 +26,7 @@ class TcpScanner(HostScanner, HostFinger): is_open, banner = check_port_tcp(host.ip_addr, target_port, - self._config.tcp_scan_interval / 1000.0, + self._config.tcp_scan_timeout / 1000.0, self._config.tcp_scan_get_banner) if is_open: diff --git a/chaos_monkey/network/tools.py b/chaos_monkey/network/tools.py index 9e945924d..3e3e0d85c 100644 --- a/chaos_monkey/network/tools.py +++ b/chaos_monkey/network/tools.py @@ -1,17 +1,23 @@ import socket import select +import logging DEFAULT_TIMEOUT = 10 BANNER_READ = 1024 +LOG = logging.getLogger(__name__) + def check_port_tcp(ip, port, timeout=DEFAULT_TIMEOUT, get_banner=False): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(timeout) try: sock.connect((ip, port)) - except socket.error: + except socket.timeout: return (False, None) + except socket.error, exc: + LOG.debug("Check port: %s:%s, Exception: %s", ip, port, exc) + return (False, None) banner = None