def __init__(self, log_filename, logger_name, log_interval=5.0, print_console=False, process_id=None, **kwargs): """ Process Monitor monitors the CPU usage, memory usage of a specific process. :param logger_filename: The log filename for the logger. :param logger_name: The name for the logger. :param log_interval: The interval of logging. :param print_console: Whether output log content to console. Default is False. :param process_id: The process id of the process if monitor, if this is set None, then it will monitor the process that the ProcessMonitor is running in. """ self._monitor_thread = None self._logger = get_base_logger(log_filename=log_filename, logger_name=logger_name, print_console=print_console, **kwargs) self._pid = process_id or os.getpid() self._process_instance = psutil.Process(self._pid) self._log_interval = log_interval self.running = False
try: import psutil except ImportError: pass # If psutil isn't installed, simply does not capture process stats. from azure.servicebus import ServiceBusMessage, ServiceBusMessageBatch from azure.servicebus.exceptions import MessageAlreadySettled import logger from app_insights_metric import AbstractMonitorMetric from process_monitor import ProcessMonitor LOGFILE_NAME = "stress-test.log" PRINT_CONSOLE = True _logger = logger.get_base_logger(LOGFILE_NAME, "stress_test", logging.WARN) class ReceiveType: push = "push" pull = "pull" none = None class StressTestResults(object): def __init__(self): self.total_sent = 0 self.total_received = 0 self.time_elapsed = None self.state_by_sender = {} self.state_by_receiver = {}
import sys import asyncio import logging try: import psutil except ImportError: pass # If psutil isn't installed, simply does not capture process stats. from azure.servicebus import ServiceBusClient, ServiceBusMessage, ServiceBusMessageBatch from azure.servicebus.exceptions import MessageAlreadySettled import logger from app_insights_metric import AbstractMonitorMetric from process_monitor import AbstractProcessMonitor _logger = logger.get_base_logger("stress-test.log", "stress_test", logging.WARN) class ReceiveType: push = "push" pull = "pull" none = None class StressTestResults(object): def __init__(self): self.total_sent = 0 self.total_received = 0 self.time_elapsed = None self.state_by_sender = {} self.state_by_receiver = {}