diff --git a/.github/config/gitversion.yml b/.gitea/config/gitversion.yml similarity index 59% rename from .github/config/gitversion.yml rename to .gitea/config/gitversion.yml index 94fdb98..aa3a017 100644 --- a/.github/config/gitversion.yml +++ b/.gitea/config/gitversion.yml @@ -1,11 +1,9 @@ next-version: 1.0.0 +mode: ContinuousDeployment assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch branches: - master: - regex: ^master$ - mode: ContinuousDelivery + main: + regex: ^main$ increment: Patch - tag: '' - is-release-branch: true diff --git a/.gitea/readme/icon.png b/.gitea/readme/icon.png new file mode 100644 index 0000000..71df6da Binary files /dev/null and b/.gitea/readme/icon.png differ diff --git a/.gitea/workflows/analyze.yml b/.gitea/workflows/analyze.yml new file mode 100644 index 0000000..4927bf1 --- /dev/null +++ b/.gitea/workflows/analyze.yml @@ -0,0 +1,34 @@ +name: Analyze code + +on: + push: + branches: + - "dev" + paths: + - "src**" + - "requirements.txt" + pull_request: + branches: + - "dev" + - "main" + paths: + - "src**" + - "requirements.txt" + +jobs: + analyze: + name: Analyze code + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pylint + - name: Analysing the code with pylint + run: pylint --exit-zero $(git ls-files 'src/*.py') diff --git a/.gitea/workflows/analyze_and_publish.yml b/.gitea/workflows/analyze_and_publish.yml new file mode 100644 index 0000000..2b94cad --- /dev/null +++ b/.gitea/workflows/analyze_and_publish.yml @@ -0,0 +1,75 @@ +name: Analyze code and publish script + +on: + push: + branches: + - "main" + paths: + - "src**" + - "requirements.txt" + +jobs: + analyze: + name: Analyze code + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pylint + - name: Analysing the code with pylint + run: pylint --exit-zero $(git ls-files 'src/*.py') + publish: + name: Publish script + needs: analyze + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Setup GitVersion + uses: gittools/actions/gitversion/setup@v4.2.0 + with: + versionSpec: 6.4.x + - name: Determine version + uses: gittools/actions/gitversion/execute@v4.2.0 + id: gitversion + with: + configFilePath: ./.gitea/config/gitversion.yml + - name: Create package root directory + run: | + mkdir package + mkdir package/ipsec_exporter + cp -r src/* package/ipsec_exporter/ + cp requirements.txt package/requirements.txt + - name: Create .TAR.GZ archive + uses: ksm2/archive-action@v1 + with: + format: "tar.gz" + name: ipsec_exporter_${{steps.gitversion.outputs.SemVer}} + root-directory: "package" + - name: Create .ZIP archive + uses: ksm2/archive-action@v1 + with: + format: "zip" + name: ipsec_exporter_${{steps.gitversion.outputs.SemVer}} + root-directory: "package" + - name: Create Release + uses: akkuman/gitea-release-action@v1 + with: + tag_name: ${{steps.gitversion.outputs.SemVer}} + name: ${{steps.gitversion.outputs.SemVer}} + files: |- + ipsec_exporter_${{steps.gitversion.outputs.SemVer}}.tar.gz + ipsec_exporter_${{steps.gitversion.outputs.SemVer}}.zip + \ No newline at end of file diff --git a/.github/workflows/pull_request_dev.yml b/.github/workflows/pull_request_dev.yml deleted file mode 100644 index de96278..0000000 --- a/.github/workflows/pull_request_dev.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Chack code on dev pull request - -on: - pull_request: - branches: - - "dev" - paths: - - "ipsec_exporter.py" - - "src/*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: pylint --exit-zero $(git ls-files '*.py') diff --git a/.github/workflows/pull_request_master.yml b/.github/workflows/pull_request_master.yml deleted file mode 100644 index f6fdf8e..0000000 --- a/.github/workflows/pull_request_master.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Chack code on master pull request - -on: - pull_request: - branches: - - "master" - paths: - - "ipsec_exporter.py" - - "src/*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: pylint --exit-zero $(git ls-files '*.py') diff --git a/.github/workflows/push_dev.yml b/.github/workflows/push_dev.yml deleted file mode 100644 index 1b6d949..0000000 --- a/.github/workflows/push_dev.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Chack code on dev push - -on: - push: - branches: - - "dev" - paths: - - "ipsec_exporter.py" - - "src/*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: pylint --exit-zero $(git ls-files '*.py') diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml deleted file mode 100644 index c59cf13..0000000 --- a/.github/workflows/push_master.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Check code and publish on master push - -on: - push: - branches: - - "master" - paths: - - "src/*.py" - - "*.py" - -jobs: - check: - name: Code check - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Setup GitVersion - uses: gittools/actions/gitversion/setup@v0.9.7 - with: - versionSpec: 5.x - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install prometheus_client - pip install pylint - - name: Analysing the code with pylint - run: pylint --exit-zero $(git ls-files '*.py') - - name: Determine Version - uses: gittools/actions/gitversion/execute@v0.9.7 - id: gitversion - with: - useConfigFile: true - configFilePath: ./.github/config/gitversion.yml - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: src - path: | - ./ - !./.github/ - !./.gitignore - !./.git/ - outputs: - version: ${{ steps.gitversion.outputs.SemVer }} - publish: - name: Publish - needs: check - runs-on: ubuntu-latest - steps: - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: src - path: ./data/ - - name: Create zip - uses: ihiroky/archive-action@v1 - with: - root_dir: ./data/ - file_path: ipsec_exporter_${{ needs.check.outputs.version }}.zip - - name: Create tar.gz - uses: ihiroky/archive-action@v1 - with: - root_dir: ./data/ - file_path: ipsec_exporter_${{ needs.check.outputs.version }}.tar.gz - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ needs.check.outputs.version }} - release_name: ${{ needs.check.outputs.version }} - body_path: ./data/RELEASE.md - draft: false - prerelease: false - - name: Upload zip archive - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./ipsec_exporter_${{ needs.check.outputs.version }}.zip - asset_name: ipsec_exporter_${{ needs.check.outputs.version }}.zip - asset_content_type: application/zip - - name: Upload tar.gz archive - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./ipsec_exporter_${{ needs.check.outputs.version }}.tar.gz - asset_name: ipsec_exporter_${{ needs.check.outputs.version }}.tar.gz - asset_content_type: application/gzip - diff --git a/README.md b/README.md index db69113..75d4c29 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,103 @@ -# IPsecExporter -Prometheus IPsec metrics exporter for Libreswan +
![]()
Metrics exporter written in Python for IPsec VPN server set up with this scripts (probably works with any Libreswan IPsec server).
+ +--- + +## Support status + +> [!Warning] +> App is no longer maintained. Last time, it was updated on April 2024. There is no guarantee that it works with newer versions of Libreswan. I leave the repository mainly as a sample of my work. + +## Features + +- Read metrics from Libreswan status commands and export them to the Prometheus server +- Set read interval +- Define custom metrics and metrics sources + +## Installation + +Download latest package version from Releases tab, unpack, install requirements and you good to go + +**Requirements** + +- Prometheus server set up +- Python installed +- PIP packages: + - `argparse` + - `prometheus_client` + +You can also use `requirements.txt` file to install PIP dependencies + +``` +pip install -r requirements.txt +``` + +## Usage + +``` +python ipsec_exporter [additional_options] +``` + +**Additional options:** + +- `--address `, `-a ` - Prometheus server address (default: `0.0.0.0`) +- `--port