Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log statistics port to modular VOLTTRON #2

Merged
merged 50 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
20318b9
updated readme
riley206 Dec 22, 2023
877dec3
added src and agent
riley206 Dec 22, 2023
1d86508
added test and adjusted imports
riley206 Dec 22, 2023
8d2b96f
added pyproject.toml
riley206 Dec 22, 2023
4e61fa9
added pyproject
riley206 Dec 22, 2023
6b528e4
temp path
riley206 Dec 22, 2023
d2169a9
updated publish
riley206 Dec 26, 2023
a539bd1
fixed readme
riley206 Dec 26, 2023
66f9dd8
fixed readme
riley206 Dec 26, 2023
f5c468a
changed config name
riley206 Dec 26, 2023
09c722a
added notice
riley206 Dec 26, 2023
a0a4d3e
added license
riley206 Dec 26, 2023
41b3248
updated import
riley206 Dec 26, 2023
dd18f18
updated config file name
riley206 Dec 26, 2023
b0f0f8e
fixed test
riley206 Dec 27, 2023
3e06677
added pre commit
riley206 Dec 27, 2023
f00a654
removed default config test
riley206 Jan 2, 2024
2b8b6f5
adjusted output, general flow
riley206 Jan 5, 2024
81d7bee
removed import
riley206 Jan 5, 2024
db8d491
added type hints
riley206 Jan 5, 2024
5492b70
added .gitignore
riley206 Jan 19, 2024
c098043
cleaned with linter
riley206 Jan 19, 2024
a5bc120
updated python version
riley206 Jan 19, 2024
632b085
added isort
riley206 Jan 19, 2024
1603410
ran with isort
riley206 Jan 19, 2024
5f20c86
updatd pre-commit
riley206 Feb 5, 2024
0af3112
updated column limit
riley206 Feb 5, 2024
0ead1d3
simplified readme
riley206 Feb 5, 2024
cf42b52
updated 2024
riley206 Feb 5, 2024
c177386
updated to 2024
riley206 Feb 5, 2024
e52e2b2
updated readme
riley206 Mar 11, 2024
5cb5353
updated config parameter descriptions
riley206 Mar 12, 2024
cebae03
uses default config if not present
riley206 Mar 12, 2024
223b21e
fixed json
riley206 Mar 12, 2024
6332a19
standard deviation based off of time
riley206 Mar 12, 2024
394c042
calculate mean and better logging
riley206 Mar 13, 2024
bb93764
better topic explanation
riley206 Mar 13, 2024
76e0cd5
getting volttron home uasing clientContext
riley206 Mar 18, 2024
f814e53
using config store
riley206 Mar 26, 2024
ce647dc
added config store support
riley206 Mar 28, 2024
9724ab1
can use --agent-config
riley206 Apr 2, 2024
a5921ff
Ability to change size units. B, KB, MB, GB
riley206 May 1, 2024
9cc092b
docs reflect ability to change size units. B, KB, MB, GB
riley206 May 1, 2024
7d160f1
removed onstart
riley206 May 20, 2024
169baca
Fixed file paths
riley206 May 22, 2024
26d39e6
using volttrons get utc now
riley206 May 22, 2024
7c1a937
using volttrons get utc now
riley206 May 22, 2024
1316f0a
fixed file path
riley206 Jul 31, 2024
0420153
added docs
riley206 Jul 31, 2024
5b676d3
updated docs
riley206 Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
.coverage*
pip-wheel-metadata/
site/
.venv/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# pycharm project settings
.idea/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-xml
- id: forbid-new-submodules
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- id: no-commit-to-branch # blocks main commits. To bypass do git commit --allow-empty
- id: pretty-format-json

- repo: https://github.com/google/yapf
rev: v0.40.2 # Use the sha / tag you want to point at
hooks:
- id: yapf
name: yapf
description: "A formatter for Python files."
entry: yapf
language: python
types: [ python ]
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Battelle Memorial Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
# volttron-log-statistics
# volttron-log-statistics

riley206 marked this conversation as resolved.
Show resolved Hide resolved
The Log Statistics agent periodically reads the "volttron.log" file based on the configured interval, computes the size delta from the previous hour and publishes the difference in bytes with a timestamp. It also publishes standard deviation of the size delta every 24 hours. This agent can be useful for detecting unexpected changes to the system which may be an indication of some sort of failure or breach.
riley206 marked this conversation as resolved.
Show resolved Hide resolved

## Requires

* python >= 3.10
* volttron >= 10.0

## Installation

Before installing, VOLTTRON should be installed and running. Its virtual environment should be active.
Information on how to install of the VOLTTRON platform can be found
[here](https://github.com/eclipse-volttron/volttron-core).

Create a directory called `config` and use the change directory command to enter it.
riley206 marked this conversation as resolved.
Show resolved Hide resolved

```shell
mkdir config
cd config
```

After entering the config directory, create a file called `log_stat_config.json`. Use the below configuration section to populate your new file.

### Configuration

The Log Statistics agent has 4 required configuration values:
riley206 marked this conversation as resolved.
Show resolved Hide resolved

- `file_path`: This should be the path to the "volttron.log" file
riley206 marked this conversation as resolved.
Show resolved Hide resolved
- `analysis_interval_secs`: The interval in seconds between publishing the size delta statistic to the message bus
riley206 marked this conversation as resolved.
Show resolved Hide resolved
- `publish_topic`: Can be used to specify a topic to publish log statistics to which does not get captured by the
riley206 marked this conversation as resolved.
Show resolved Hide resolved
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")

```json
{
"file_path" : "~/volttron/volttron.log",
"analysis_interval_sec" : 60,
"publish_topic" : "platform/log_statistics",
"historian_topic" : "record/log_statistics"
}
```

Install and start the log statistics agent

```bash
vctl install volttron-log-statistics --agent-config log_stat_config.json --vip-identity platform.log_statistics --start --force
riley206 marked this conversation as resolved.
Show resolved Hide resolved
```

View the status of the installed agent.

```shell
vctl status
```

## Development

Please see the following for contributing guidelines [contributing](https://github.com/eclipse-volttron/volttron-core/blob/develop/CONTRIBUTING.md).

Please see the following helpful guide about [developing modular VOLTTRON agents](https://github.com/eclipse-volttron/volttron-core/blob/develop/DEVELOPING_ON_MODULAR.md)

## Disclaimer Notice

This material was prepared as an account of work sponsored by an agency of the
United States Government. Neither the United States Government nor the United
States Department of Energy, nor Battelle, nor any of their employees, nor any
jurisdiction or organization that has cooperated in the development of these
materials, makes any warranty, express or implied, or assumes any legal
liability or responsibility for the accuracy, completeness, or usefulness or any
information, apparatus, product, software, or process disclosed, or represents
that its use would not infringe privately owned rights.

Reference herein to any specific commercial product, process, or service by
trade name, trademark, manufacturer, or otherwise does not necessarily
constitute or imply its endorsement, recommendation, or favoring by the United
States Government or any agency thereof, or Battelle Memorial Institute. The
views and opinions of authors expressed herein do not necessarily state or
reflect those of the United States Government or any agency thereof.
6 changes: 6 additions & 0 deletions log_stat_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"file_path" : "~/volttron/volttron.log",
"analysis_interval_sec" : 60,
"publish_topic" : "platform/log_statistics",
"historian_topic" : "analysis/log_statistics"
}
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = ["poetry-core>=1.2.2"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
volttron-log-statistics = "log_statistics.agent:main"

[tool.isort]
profile = "black"

[tool.poetry]
include = ["src/log_statistics", "log_stat_config.json"]

name = "volttron-log-statistics"
version = "0.1.0"
description = ""
authors = ["VOLTTRON Team <[email protected]>"]
license = "Apache License 2.0"
readme = "README.md"
repository = "https://github.com/eclipse-volttron/volttron-log-statistics"
homepage = "https://github.com/eclipse-volttron/volttron-log-statistics"
keywords = []
packages = [ { include = "log_statistics", from = "src" } ]
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Science/Research",
"Intended Audience :: Information Technology",
"Intended Audience :: Developers",
"Intended Audience :: Other Audience",
"License :: OSI Approved :: Apache Software License"
]

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
volttron = "^10.0.4rc1"

[tool.poetry.group.dev.dependencies]
volttron-testing = "^0.4.0rc0"
pytest = "^6.2.5"
pytest-cov = "^3.0.0"
mock = "^4.0.3"
pre-commit = "^2.17.0"
yapf = "^0.32.0"
toml = "^0.10.2"
mypy = "^0.942"
coverage = "^6.3.2"
isort = "^5.10.1"

[tool.poetry.dev-dependencies]
Sphinx = "^4.5.0"
sphinx-rtd-theme = "^1.0.0"

[tool.yapf]
based_on_style = "pep8"
spaces_before_comment = 4
column_limit = 120
split_before_logical_operator = true

[tool.yapfignore]
ignore_patterns = [
".venv/**",
".pytest_cache/**",
"dist/**",
"docs/**"
]
Loading