-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,386 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: pylint-windows-tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
# Don't use pypy on windows since it does not have pywin32 module | ||
# python-version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10"] | ||
python-version: ["3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
if (Test-Path "altaro_exporter/requirements.txt") { pip install -r altaro_exporter/requirements.txt } | ||
- name: Lint with Pylint | ||
#if: ${{ matrix.python-version == '3.12' }} | ||
run: | | ||
python -m pip install pylint | ||
# Do not run pylint on python 3.3 because isort is not available for python 3.3, don't run on python 3.4 because pylint: disable=xxxx does not exist | ||
python -m pylint --disable=C,W,R --max-line-length=127 altaro_exporter | ||
- name: Lint with flake8 | ||
#if: ${{ matrix.python-version == '3.12' }} | ||
run: | | ||
python -m pip install flake8 | ||
# stop the build if there are Python syntax errors or undefined names | ||
python -m flake8 --count --select=E9,F63,F7,F82 --show-source --statistics altaro_exporter | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
python -m flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics altaro_exporter | ||
- name: Lint with Black | ||
# Don't run on python < 3.6 since black does not exist there, run only once | ||
#if: ${{ matrix.python-version == '3.12' }} | ||
run: | | ||
pip install black | ||
python -m black --check altaro_exporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: windows-tests | ||
|
||
# The default shell here is Powershell | ||
# Don't run with python 3.3 as using python -m to run flake8 or pytest will fail. | ||
# Hence, without python -m, pytest will not have it's PYTHONPATH set to current dir and imports will fail | ||
# Don't run with python 3.4 as github cannot install it (pip install --upgrade pip fails) | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
# As of 2023/08/30, we have removed python 2.7 since github actions won't provide it anymore | ||
# Don't test on pypy since we don't have pywin32 | ||
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
if (Test-Path "altaro_exporter/requirements.txt") { pip install -r altaro_exporter/requirements.txt } | ||
- name: Generate Report | ||
env: | ||
RUNNING_ON_GITHUB_ACTIONS: true | ||
run: | | ||
pip install pytest coverage | ||
python -m coverage run -m pytest -vvs tests | ||
- name: Upload Coverage to Codecov | ||
uses: codecov/codecov-action@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# 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 | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# 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 maintainted 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/ | ||
|
||
RESTIC_SOURCE_FILES/restic* | ||
RESTIC_SOURCE_FILES/ARCHIVE | ||
_private* | ||
_NOUSE_private* | ||
NOUSE_private* | ||
BUILDS | ||
BUILDS-PRIVATE | ||
*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Altaro Backup Exporter | ||
|
||
This is an Altaro data exporter for Prometheus | ||
|
||
### Grafana Dashboard | ||
|
||
You can find an example dashboard in the examples directory | ||
|
||
 | ||
 | ||
|
||
### Install | ||
|
||
On the release page, you'll find precompiled binaries that are digitally signed. | ||
|
||
The exporter needs to be installed on the host that has Altaro VM Backup installed (since discussing with the API from anywhere else fails with `HTTP Error 400. The request hostname is invalid.`) | ||
|
||
Extract the zip file to let's say `C:\altaro_exporter` | ||
In the directory, you'll find the binaries as well as the config file `altaro_exporter.yaml` | ||
|
||
Configure your local/domain administrator account according to your needs. Don't worry, once running, the user and password will be encrypted. | ||
|
||
Once you're done, create a Windows Service with the following command | ||
|
||
``` | ||
sc create altaro_exporter DisplayName= "Altaro API exporter for Prometheus" start= auto binpath= "c:\altaro_exporter\altaro_exporter-x64.exe -c c:\altaro_exporter\altaro_exporter.yaml" | ||
``` | ||
|
||
Launch the service: | ||
``` | ||
sc start altaro_exporter | ||
``` | ||
|
||
You should now have a running Windows Service as seen in `services.msc`: | ||
 | ||
|
||
You must also enable the Altaro REST API service with the following command: | ||
``` | ||
sc config Hornetsecurity.VMBackup.Rest start= auto | ||
sc start Hornetsecurity.VMBackup.Rest | ||
``` | ||
|
||
You can now query the exporter with: | ||
``` | ||
curl http://localhost:9769/metrics | ||
``` | ||
|
||
### Firewall | ||
|
||
The default exporter-port is 9769/tcp, which you can change in the config file. | ||
Keep in mind that you need to create a firewall rule if you want to query it's output. | ||
|
||
### Metrics | ||
|
||
API status metric (0 = OK, 1 = Cannot connect to API, 2 = API didn't like our request) | ||
``` | ||
altaro_api_success | ||
``` | ||
|
||
The follwoing metrics have this labels: | ||
` hostname,vmname,vmuuid ` | ||
|
||
metrics: | ||
``` | ||
altaro_lastoffsitecopy_result | ||
altaro_lastbackup_result | ||
altaro_lastoffsitecopy_transfersize_uncompressed_bytes | ||
altaro_lastoffsitecopy_transfersize_compressed_bytes | ||
altaro_lastbackup_transfersize_uncompressed_bytes | ||
altaro_lastbackup_transfersize_compressed_bytes | ||
altaro_lastoffsitecopy_duration_seconds | ||
altaro_lastbackup_duration_seconds | ||
altaro_lastoffsitecopy_timestamp | ||
altaro_lastbackup_timestamp | ||
``` | ||
|
||
### Alert rules: | ||
|
||
``` | ||
- alert: Last Backup not successful | ||
expr: altaro_lastbackup_result{altaro_lastbackup_result="Success"} != 1 | ||
for: 1m | ||
- alert: Last OffSite Copy not successful | ||
expr: altaro_lastoffsitecopy_result{altaro_lastoffsitecopy_result="Success"} != 1 | ||
for: 1m | ||
- alert: Last Backup older than 30 hours | ||
expr: time() < 3600 * 30 - altaro_lastbackup_timestamp | ||
for: 1m | ||
- alert: Last OffSite Copy older than 30 hours | ||
expr: time() < 3600 * 30 - altaro_lastoffsitecopy_timestamp | ||
for: 1m | ||
``` | ||
|
||
### Troubeshooting | ||
|
||
By default, the exporter will log to current binary directory into a file named `altaro_exporter.log` | ||
Of course, you can also run the executable manually. | ||
|
||
### Self compilation | ||
|
||
For those who prefer compiling the project themselves, you can install Python >= 3.6 and install requirements in `requirements.txt` and `requirements-compile.txt`. | ||
Once this is done, you can simply launch the `compile.py` script from the root folder of the project. | ||
Optionally, you can modifiy the settings / icons in the resources directory. | ||
|
||
Note that in order to produce a proper Windows Service, you'll need Nuitka Commercial, please see https://nuitka.net/doc/commercial.html | ||
|
||
### Pip packaging | ||
|
||
We don't currently provide pip packages since the idea is to execute plain executable windows service files. | ||
If requested, we can provide pip packages too. | ||
|
||
### License | ||
|
||
MIT // 2024 - NetInvent SASU | ||
MIT // 2020 - Raphael Pertl | ||
|
||
Based on the work of Raphael Pertl available [here](https://github.com/raph2i/altaro_backup_exporter) |
Oops, something went wrong.