From e010122998f9b19c67c0060277dba33b26a9d63e Mon Sep 17 00:00:00 2001 From: riley206 Date: Mon, 18 Mar 2024 15:26:51 -0700 Subject: [PATCH 1/9] default config, 24 hour stats --- .../logstatisticsagent/agent.py | 81 +++++++++++++++---- 1 file changed, 65 insertions(+), 16 deletions(-) diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index 0a624ea1d3..8afc30ddad 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -31,13 +31,14 @@ from volttron.platform.vip.agent import Agent, Core from volttron.platform.agent import utils from volttron.platform.agent.utils import get_aware_utc_now +from volttron.platform import get_home utils.setup_logging() _log = logging.getLogger(__name__) __version__ = '1.0' -def log_statistics(config_path, **kwargs): +def log_statistics(config_path: str, **kwargs): """ Load the LogStatisticsAgent agent configuration and returns and instance of the agent created using that configuration. @@ -66,8 +67,26 @@ class LogStatisticsAgent(Agent): } """ - def __init__(self, config, **kwargs): + def __init__(self, config: dict, **kwargs): super(LogStatisticsAgent, self).__init__(**kwargs) + + self.last_std_dev_time = get_aware_utc_now() + + volttron_home = get_home() + + self.default_config = { + "file_path": f"{volttron_home}/volttron.log", + "analysis_interval_sec": 60, + "publish_topic": "platform/log_statistics", + "historian_topic": "analysis/log_statistics" + } + + # Update config with defaults for any keys not present in config + for key, value in self.default_config.items(): + if config.get(key) is None: + _log.info(f"Using default value for {key}: {value}") + config[key] = value + self.analysis_interval_sec = config["analysis_interval_sec"] self.file_path = config["file_path"] self.publish_topic = config["publish_topic"] @@ -105,24 +124,54 @@ def publish_analysis(self): headers = {'Date': datetime.datetime.utcnow().isoformat() + 'Z'} - publish_message = {'timestamp': datetime.datetime.utcnow().isoformat() + 'Z', - 'log_size_delta': size_delta} - historian_message = [{"log_size_delta ": size_delta}, - {"log_size_delta ": {'units': 'bytes', 'tz': 'UTC', 'type': 'float'}}] + publish_message = {'timestamp': datetime.datetime.utcnow().isoformat() + 'Z', 'log_size_delta': size_delta} + historian_message = [{ + "log_size_delta ": size_delta + }, { + "log_size_delta ": { + 'units': 'bytes', + 'tz': 'UTC', + 'type': 'float' + } + }] - if len(self.size_delta_list) == 24: - standard_deviation = statistics.stdev(self.size_delta_list) - publish_message['log_std_dev'] = standard_deviation - historian_message[0]['log_std_dev'] = standard_deviation - historian_message[1]['log_std_dev'] = {'units': 'bytes', 'tz': 'UTC', 'type': 'float'} + now = get_aware_utc_now() + hours_since_last_std_dev = (now - self.last_std_dev_time).total_seconds() / 3600 - _log.debug('publishing message {} with header {} on historian topic {}' - .format(historian_message, headers, self.historian_topic)) - self.vip.pubsub.publish(peer="pubsub", topic=self.historian_topic, headers=headers, - message=historian_message) + if hours_since_last_std_dev >= 24: + if self.size_delta_list: # make sure it has something in it + if len(self.size_delta_list) >= 2: # make sure it has more than two items + mean = statistics.mean(self.size_delta_list) + standard_deviation = statistics.stdev(self.size_delta_list) + + publish_message['log_mean'] = mean + print(f"Calculated mean: {mean}") + publish_message['log_std_dev'] = standard_deviation + + historian_message[0]['log_mean'] = mean + historian_message[0]['log_std_dev'] = standard_deviation + + historian_message[1]['log_mean'] = {'units': 'bytes', 'tz': 'UTC', 'type': 'float'} + historian_message[1]['log_std_dev'] = {'units': 'bytes', 'tz': 'UTC', 'type': 'float'} + + else: + _log.info("Not enough data points to calculate standard deviation") + + else: + _log.info("Not enough data points to calculate mean and standard deviation") + + # Reset time + self.last_std_dev_time = now self.size_delta_list = [] + _log.debug('publishing message {} with header {} on historian topic {}'.format( + historian_message, headers, self.historian_topic)) + self.vip.pubsub.publish(peer="pubsub", + topic=self.historian_topic, + headers=headers, + message=historian_message) + _log.debug('publishing message {} on topic {}'.format(publish_message, self.publish_topic)) self.vip.pubsub.publish(peer="pubsub", topic=self.publish_topic, message=publish_message) @@ -143,7 +192,7 @@ def main(argv=sys.argv): """ Main method called by the platform. """ - utils.vip_main(log_statistics, identity='platform.logstatisticsagent') + utils.vip_main(log_statistics, identity='platform.log_statistics') if __name__ == '__main__': From bc59eaf3b742c7d04c65e05e92ca7ce08af640fd Mon Sep 17 00:00:00 2001 From: riley206 Date: Mon, 18 Mar 2024 15:28:47 -0700 Subject: [PATCH 2/9] updated parameters --- services/ops/LogStatisticsAgent/README.md | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/services/ops/LogStatisticsAgent/README.md b/services/ops/LogStatisticsAgent/README.md index b663023012..f444d60d8d 100644 --- a/services/ops/LogStatisticsAgent/README.md +++ b/services/ops/LogStatisticsAgent/README.md @@ -8,23 +8,21 @@ which may be an indication of some sort of failure or breach. ### Configuration -The Log Statistics agent has 4 required configuration values: +The Log Statistics agent has 4 configuration parameters, all of which are required: -- `file_path`: This should be the path to the "volttron.log" file -- `analysis_interval_secs`: The interval in seconds between publishing the size delta statistic to the message bus -- `publish_topic`: Can be used to specify a topic to publish log statistics to which does not get captured by the - historian framework (topics not prefixed by any of: "datalogger", "record", "analysis", "devices") -- `historian_topic`: Can be used to specify a topic to publish log statistics to which gets captured by the - historian framework ("datalogger", "record", "analysis", "devices") - -The following is an example configuration file: +- `file_path`: The file path to the log file. If left as `null`, defaults to `'volttron.log'` located within your VOLTTRON_HOME environment variable. +- `analysis_interval_secs`: The interval in seconds between publishes of the size delta statistic to the message bus. If left as `null`, defaults to 60 seconds. +- `publish_topic`: Used to specify a topic to publish log statistics to which does not get captured by the + historian framework (topics not prefixed by any of: "datalogger", "record", "analysis", "devices"). If left as `null`, defaults to `"platform/log_statistics"`. +- `historian_topic`: Can be used to specify a topic to publish log statistics to which gets captured by the + historian framework ("datalogger", "record", "analysis", "devices"). If left as `null`, defaults to `record/log_statistics`. ```json { - "file_path" : "~/volttron/volttron.log", - "analysis_interval_min" : 60, - "publish_topic" : "platform/log_statistics", - "historian_topic" : "record/log_statistics" + "analysis_interval_sec": 60, + "file_path": null, + "historian_topic": "analysis/log_statistics", + "publish_topic": "platform/log_statistics" } ``` From 4e81a702b333577c031a44d54a893ed3f2cc9296 Mon Sep 17 00:00:00 2001 From: riley206 Date: Tue, 19 Mar 2024 11:52:01 -0700 Subject: [PATCH 3/9] updated default log path --- services/ops/LogStatisticsAgent/README.md | 2 +- services/ops/LogStatisticsAgent/logstatisticsagent/agent.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/services/ops/LogStatisticsAgent/README.md b/services/ops/LogStatisticsAgent/README.md index f444d60d8d..9b7593f093 100644 --- a/services/ops/LogStatisticsAgent/README.md +++ b/services/ops/LogStatisticsAgent/README.md @@ -10,7 +10,7 @@ which may be an indication of some sort of failure or breach. The Log Statistics agent has 4 configuration parameters, all of which are required: -- `file_path`: The file path to the log file. If left as `null`, defaults to `'volttron.log'` located within your VOLTTRON_HOME environment variable. +- `file_path`: The file path to the log file. If left as `null`, defaults to "/home/volttron/volttron.log". - `analysis_interval_secs`: The interval in seconds between publishes of the size delta statistic to the message bus. If left as `null`, defaults to 60 seconds. - `publish_topic`: Used to specify a topic to publish log statistics to which does not get captured by the historian framework (topics not prefixed by any of: "datalogger", "record", "analysis", "devices"). If left as `null`, defaults to `"platform/log_statistics"`. diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index 8afc30ddad..5223858985 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -72,10 +72,8 @@ def __init__(self, config: dict, **kwargs): self.last_std_dev_time = get_aware_utc_now() - volttron_home = get_home() - self.default_config = { - "file_path": f"{volttron_home}/volttron.log", + "file_path": "/home/volttron/volttron.log", "analysis_interval_sec": 60, "publish_topic": "platform/log_statistics", "historian_topic": "analysis/log_statistics" From 96a8e35b1a8a59723a98eb186af3ba12c1068cab Mon Sep 17 00:00:00 2001 From: riley206 Date: Tue, 26 Mar 2024 15:12:04 -0700 Subject: [PATCH 4/9] uses config store --- .../logstatisticsagent/agent.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index 5223858985..d12a5ce1a2 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -67,24 +67,27 @@ class LogStatisticsAgent(Agent): } """ - def __init__(self, config: dict, **kwargs): + def __init__(self, config_path=None, **kwargs): super(LogStatisticsAgent, self).__init__(**kwargs) self.last_std_dev_time = get_aware_utc_now() self.default_config = { - "file_path": "/home/volttron/volttron.log", + "file_path": f"volttron/volttron.log", "analysis_interval_sec": 60, "publish_topic": "platform/log_statistics", "historian_topic": "analysis/log_statistics" } + self.vip.config.set_default("config", self.default_config) + self.vip.config.subscribe(self.configure_main, actions=["NEW", "UPDATE"], pattern="config") - # Update config with defaults for any keys not present in config - for key, value in self.default_config.items(): - if config.get(key) is None: - _log.info(f"Using default value for {key}: {value}") - config[key] = value + def configure_main(self, config_name, action, contents): + config = self.default_config.copy() + config.update(contents) + if action == "NEW" or "UPDATE": + self.reset_parameters(config) + def reset_parameters(self, config=None): self.analysis_interval_sec = config["analysis_interval_sec"] self.file_path = config["file_path"] self.publish_topic = config["publish_topic"] @@ -94,6 +97,8 @@ def __init__(self, config: dict, **kwargs): self.prev_file_size = None self._scheduled_event = None + self.publish_analysis() + @Core.receiver('onstart') def starting(self, sender, **kwargs): _log.info("Starting " + self.__class__.__name__ + " agent") From d43946cffe946d29d13d1e6b43509b76f7077494 Mon Sep 17 00:00:00 2001 From: riley206 Date: Tue, 26 Mar 2024 16:01:01 -0700 Subject: [PATCH 5/9] wait until config store has loaded --- .../LogStatisticsAgent/logstatisticsagent/agent.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index d12a5ce1a2..f2354c83cc 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -32,6 +32,7 @@ from volttron.platform.agent import utils from volttron.platform.agent.utils import get_aware_utc_now from volttron.platform import get_home +import time utils.setup_logging() _log = logging.getLogger(__name__) @@ -69,7 +70,7 @@ class LogStatisticsAgent(Agent): def __init__(self, config_path=None, **kwargs): super(LogStatisticsAgent, self).__init__(**kwargs) - + self.configured = False self.last_std_dev_time = get_aware_utc_now() self.default_config = { @@ -84,6 +85,7 @@ def __init__(self, config_path=None, **kwargs): def configure_main(self, config_name, action, contents): config = self.default_config.copy() config.update(contents) + self.configured = True if action == "NEW" or "UPDATE": self.reset_parameters(config) @@ -96,8 +98,8 @@ def reset_parameters(self, config=None): self.file_start_size = None self.prev_file_size = None self._scheduled_event = None - - self.publish_analysis() + if self.configured: + self.publish_analysis() @Core.receiver('onstart') def starting(self, sender, **kwargs): @@ -109,6 +111,9 @@ def publish_analysis(self): Publishes file's size increment in previous time interval (60 minutes) with timestamp. Also publishes standard deviation of file's hourly size differences every 24 hour. """ + if not self.configured: + return + if self._scheduled_event is not None: self._scheduled_event.cancel() From 521ec54891619a11f452ce4e2de5431b9d55cb2c Mon Sep 17 00:00:00 2001 From: riley206 Date: Tue, 2 Apr 2024 11:09:24 -0700 Subject: [PATCH 6/9] uses agent-config and config store --- .../logstatisticsagent/agent.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index f2354c83cc..c8c4e97d51 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -38,20 +38,6 @@ _log = logging.getLogger(__name__) __version__ = '1.0' - -def log_statistics(config_path: str, **kwargs): - """ - Load the LogStatisticsAgent agent configuration and returns and instance - of the agent created using that configuration. - :param config_path: Path to a configuration file. - :type config_path: str - :returns: LogStatisticsAgent agent instance - :rtype: LogStatisticsAgent agent - """ - config = utils.load_config(config_path) - return LogStatisticsAgent(config, **kwargs) - - class LogStatisticsAgent(Agent): """ LogStatisticsAgent reads volttron.log file size every hour, compute the size delta from previous hour and publish @@ -79,6 +65,8 @@ def __init__(self, config_path=None, **kwargs): "publish_topic": "platform/log_statistics", "historian_topic": "analysis/log_statistics" } + if config_path: + self.default_config.update(utils.load_config(config_path)) self.vip.config.set_default("config", self.default_config) self.vip.config.subscribe(self.configure_main, actions=["NEW", "UPDATE"], pattern="config") @@ -200,7 +188,7 @@ def main(argv=sys.argv): """ Main method called by the platform. """ - utils.vip_main(log_statistics, identity='platform.log_statistics') + utils.vip_main(LogStatisticsAgent, identity='platform.log_statistics') if __name__ == '__main__': From b854b100a14a14c2b6a373432c3cf5d81a44adba Mon Sep 17 00:00:00 2001 From: riley206 Date: Mon, 20 May 2024 10:26:18 -0700 Subject: [PATCH 7/9] remove on start, added new units --- services/ops/LogStatisticsAgent/README.md | 21 ++++--- .../logstatisticsagent.config | 9 +-- .../logstatisticsagent/agent.py | 58 ++++++++++++------- 3 files changed, 55 insertions(+), 33 deletions(-) diff --git a/services/ops/LogStatisticsAgent/README.md b/services/ops/LogStatisticsAgent/README.md index 9b7593f093..53ae291eaa 100644 --- a/services/ops/LogStatisticsAgent/README.md +++ b/services/ops/LogStatisticsAgent/README.md @@ -10,19 +10,26 @@ which may be an indication of some sort of failure or breach. The Log Statistics agent has 4 configuration parameters, all of which are required: -- `file_path`: The file path to the log file. If left as `null`, defaults to "/home/volttron/volttron.log". -- `analysis_interval_secs`: The interval in seconds between publishes of the size delta statistic to the message bus. If left as `null`, defaults to 60 seconds. +- `file_path`: The file path to the log file. If no config provided, defaults to `'volttron.log'` located within your VOLTTRON_HOME environment variable. +- `analysis_interval_secs`: The interval in seconds between publishes of the size delta statistic to the message bus. If no config provided, defaults to 60 seconds. - `publish_topic`: Used to specify a topic to publish log statistics to which does not get captured by the - historian framework (topics not prefixed by any of: "datalogger", "record", "analysis", "devices"). If left as `null`, defaults to `"platform/log_statistics"`. + historian framework (topics not prefixed by any of: "datalogger", "record", "analysis", "devices"). If no config provided, defaults to `"platform/log_statistics"`. - `historian_topic`: Can be used to specify a topic to publish log statistics to which gets captured by the - historian framework ("datalogger", "record", "analysis", "devices"). If left as `null`, defaults to `record/log_statistics`. - + historian framework ("datalogger", "record", "analysis", "devices"). If no config provided, defaults to `record/log_statistics`. +- `unit`: Can be used to specify units. Defaults to `bytes`. + - "bytes" + - "kb" + - "mb" + - "gb" + +Here is an example configuration file named `log_stat_config.json`. ```json { "analysis_interval_sec": 60, - "file_path": null, + "file_path": "path/to/.log/", "historian_topic": "analysis/log_statistics", - "publish_topic": "platform/log_statistics" + "publish_topic": "platform/log_statistics", + "unit": "bytes" } ``` diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent.config b/services/ops/LogStatisticsAgent/logstatisticsagent.config index 176d45ed88..c5f8813c6e 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent.config +++ b/services/ops/LogStatisticsAgent/logstatisticsagent.config @@ -1,6 +1,7 @@ { - "file_path" : "~/volttron/volttron.log", - "analysis_interval_sec" : 60, - "publish_topic" : "platform/log_statistics", - "historian_topic" : "analysis/log_statistics" + "analysis_interval_sec": 20, + "file_path": "/home/riley/DRIVERWORK/PORTS/rileysVOLTTRON/volttron.log", + "historian_topic": "analysis/log_statistics", + "publish_topic": "platform/log_statistics", + "unit": "mb" } diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index c8c4e97d51..690b1a3e2a 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -31,8 +31,6 @@ from volttron.platform.vip.agent import Agent, Core from volttron.platform.agent import utils from volttron.platform.agent.utils import get_aware_utc_now -from volttron.platform import get_home -import time utils.setup_logging() _log = logging.getLogger(__name__) @@ -60,10 +58,11 @@ def __init__(self, config_path=None, **kwargs): self.last_std_dev_time = get_aware_utc_now() self.default_config = { - "file_path": f"volttron/volttron.log", + "file_path": "volttron.log", "analysis_interval_sec": 60, "publish_topic": "platform/log_statistics", - "historian_topic": "analysis/log_statistics" + "historian_topic": "analysis/log_statistics", + "unit": "bytes" } if config_path: self.default_config.update(utils.load_config(config_path)) @@ -76,12 +75,15 @@ def configure_main(self, config_name, action, contents): self.configured = True if action == "NEW" or "UPDATE": self.reset_parameters(config) + _log.info("Starting " + self.__class__.__name__ + " agent") + self.publish_analysis() def reset_parameters(self, config=None): self.analysis_interval_sec = config["analysis_interval_sec"] self.file_path = config["file_path"] self.publish_topic = config["publish_topic"] self.historian_topic = config["historian_topic"] + self.unit = config["unit"] self.size_delta_list = [] self.file_start_size = None self.prev_file_size = None @@ -89,43 +91,42 @@ def reset_parameters(self, config=None): if self.configured: self.publish_analysis() - @Core.receiver('onstart') - def starting(self, sender, **kwargs): - _log.info("Starting " + self.__class__.__name__ + " agent") - self.publish_analysis() - def publish_analysis(self): """ Publishes file's size increment in previous time interval (60 minutes) with timestamp. Also publishes standard deviation of file's hourly size differences every 24 hour. """ - if not self.configured: + if not hasattr(self, '_scheduled_event'): + # The settings haven't been initialized, so skip the rest of the method return - + if self._scheduled_event is not None: self._scheduled_event.cancel() if self.prev_file_size is None: self.prev_file_size = self.get_file_size() - _log.debug("init_file_size = {}".format(self.prev_file_size)) + _log.debug(f"init_file_size = {self.convert_bytes(self.prev_file_size, self.unit)} {self.unit}") else: # read file size curr_file_size = self.get_file_size() # calculate size delta size_delta = curr_file_size - self.prev_file_size + size_delta = self.convert_bytes(size_delta, self.unit) + self.prev_file_size = curr_file_size self.size_delta_list.append(size_delta) headers = {'Date': datetime.datetime.utcnow().isoformat() + 'Z'} - publish_message = {'timestamp': datetime.datetime.utcnow().isoformat() + 'Z', 'log_size_delta': size_delta} + publish_message = {'timestamp': datetime.datetime.utcnow().isoformat() + 'Z', + 'log_size_delta': size_delta} historian_message = [{ "log_size_delta ": size_delta }, { "log_size_delta ": { - 'units': 'bytes', + 'units': f'{self.unit}', 'tz': 'UTC', 'type': 'float' } @@ -135,8 +136,8 @@ def publish_analysis(self): hours_since_last_std_dev = (now - self.last_std_dev_time).total_seconds() / 3600 if hours_since_last_std_dev >= 24: - if self.size_delta_list: # make sure it has something in it - if len(self.size_delta_list) >= 2: # make sure it has more than two items + if self.size_delta_list: # make sure it has something in it + if len(self.size_delta_list) >= 2: # make sure it has more than two items mean = statistics.mean(self.size_delta_list) standard_deviation = statistics.stdev(self.size_delta_list) @@ -147,8 +148,9 @@ def publish_analysis(self): historian_message[0]['log_mean'] = mean historian_message[0]['log_std_dev'] = standard_deviation - historian_message[1]['log_mean'] = {'units': 'bytes', 'tz': 'UTC', 'type': 'float'} - historian_message[1]['log_std_dev'] = {'units': 'bytes', 'tz': 'UTC', 'type': 'float'} + historian_message[1]['log_mean'] = {'units': f'{self.unit}', 'tz': 'UTC', 'type': 'float'} + historian_message[1]['log_std_dev'] = {'units': f'{self.unit}', 'tz': 'UTC', + 'type': 'float'} else: _log.info("Not enough data points to calculate standard deviation") @@ -161,14 +163,15 @@ def publish_analysis(self): self.size_delta_list = [] - _log.debug('publishing message {} with header {} on historian topic {}'.format( - historian_message, headers, self.historian_topic)) + _log.debug(f'publishing message {historian_message}' + f' with header {headers}' + f' on historian topic {self.historian_topic}') self.vip.pubsub.publish(peer="pubsub", topic=self.historian_topic, headers=headers, message=historian_message) - _log.debug('publishing message {} on topic {}'.format(publish_message, self.publish_topic)) + _log.debug(f'publishing message {publish_message} {self.unit} on topic {self.publish_topic}') self.vip.pubsub.publish(peer="pubsub", topic=self.publish_topic, message=publish_message) _log.debug('Scheduling next periodic call') @@ -183,6 +186,18 @@ def get_file_size(self): except OSError as e: _log.error(e) + def convert_bytes(self, size, unit): + """ + Converts size from bytes to the specified unit + """ + unit = unit.lower() + if unit == 'kb': + return size / 1024 + elif unit == 'mb': + return size / 1024 ** 2 + elif unit == 'gb': + return size / 1024 ** 3 + return size def main(argv=sys.argv): """ @@ -190,7 +205,6 @@ def main(argv=sys.argv): """ utils.vip_main(LogStatisticsAgent, identity='platform.log_statistics') - if __name__ == '__main__': # Entry point for script try: From 8c555956f808f9f666e97380bd100b9e39273f7e Mon Sep 17 00:00:00 2001 From: riley206 Date: Mon, 20 May 2024 10:30:47 -0700 Subject: [PATCH 8/9] removed redundent call --- services/ops/LogStatisticsAgent/logstatisticsagent/agent.py | 1 - 1 file changed, 1 deletion(-) diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py index 690b1a3e2a..9883894dbf 100644 --- a/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py +++ b/services/ops/LogStatisticsAgent/logstatisticsagent/agent.py @@ -76,7 +76,6 @@ def configure_main(self, config_name, action, contents): if action == "NEW" or "UPDATE": self.reset_parameters(config) _log.info("Starting " + self.__class__.__name__ + " agent") - self.publish_analysis() def reset_parameters(self, config=None): self.analysis_interval_sec = config["analysis_interval_sec"] From 2f5820b7452a84938346a90eceac940d67ea0cb7 Mon Sep 17 00:00:00 2001 From: riley206 Date: Wed, 22 May 2024 15:40:04 -0700 Subject: [PATCH 9/9] renamed config file --- .../{logstatisticsagent.config => log_stat_config.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename services/ops/LogStatisticsAgent/{logstatisticsagent.config => log_stat_config.json} (100%) diff --git a/services/ops/LogStatisticsAgent/logstatisticsagent.config b/services/ops/LogStatisticsAgent/log_stat_config.json similarity index 100% rename from services/ops/LogStatisticsAgent/logstatisticsagent.config rename to services/ops/LogStatisticsAgent/log_stat_config.json