def __init__(self): self.log_path: str = "" """path to logger, set in set_logger.""" self.pid_file_path: str = "" """path to pid_file, set in check_pid_file.""" # String, cause of days etc self.job_log_retention_time = "60d" """Configured spp log rentation time, logs get deleted after this time.""" self.set_logger() if (not self.check_pid_file()): ExceptionUtils.error_message( "Another instance of sppmon with the same args is running") self.exit(ERROR_CODE_CMD_LINE) # everything is option, otherwise its a typo. if (len(ARGS) > 0): ExceptionUtils.error_message( f"CAREFUL: ARG DETECTED, probably typing in programm call: {ARGS}" ) time_stamp_name, time_stamp = SppUtils.get_capture_timestamp_sec() self.start_counter = time.perf_counter() LOGGER.debug("\n\n") LOGGER.debug(f"running script version: {VERSION}") LOGGER.debug(f"cmdline options: {OPTIONS}") LOGGER.debug(f"{time_stamp_name}: {time_stamp}") LOGGER.debug("") if (not OPTIONS.confFileJSON): ExceptionUtils.error_message("missing config file, aborting") self.exit(error_code=ERROR_CODE_CMD_LINE) try: config_file = SppUtils.read_conf_file( config_file_path=OPTIONS.confFileJSON) except ValueError as error: ExceptionUtils.exception_info( error=error, extra_message="Syntax Error in Config file, unable to read") self.exit(error_code=ERROR_CODE_CMD_LINE) self.setup_args() self.set_critial_configs(config_file) self.set_optional_configs(config_file)
def __init__(self): self.log_path: str = "" """path to logger, set in set_logger.""" self.pid_file_path: str = "" """path to pid_file, set in check_pid_file.""" self.set_logger() LOGGER.info("Starting SPPMon") if (not self.check_pid_file()): ExceptionUtils.error_message( "Another instance of sppmon with the same args is running") self.exit(ERROR_CODE_START_ERROR) time_stamp_name, time_stamp = SppUtils.get_capture_timestamp_sec() self.start_counter = time.perf_counter() LOGGER.debug("\n\n") LOGGER.debug(f"running script version: {VERSION}") LOGGER.debug(f"cmdline options: {ARGS}") LOGGER.debug(f"{time_stamp_name}: {time_stamp}") LOGGER.debug("") if (not ARGS.configFile): ExceptionUtils.error_message("missing config file, aborting") self.exit(error_code=ERROR_CODE_CMD_ARGS) try: self.config_file = SppUtils.read_conf_file( config_file_path=ARGS.configFile) except ValueError as error: ExceptionUtils.exception_info( error=error, extra_message= "Error when trying to read Config file, unable to read") self.exit(error_code=ERROR_CODE_START_ERROR) LOGGER.info("Setting up configurations") self.setup_args() self.set_critial_configs(self.config_file) self.set_optional_configs(self.config_file)