-
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.
Initial implementation of basic checks (#2)
* feat: implemented checks for cpu, memory, disk, systemd service and timer * feat: implement consul report Add github config files. Add tests.
- Loading branch information
Showing
30 changed files
with
2,178 additions
and
41 deletions.
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 @@ | ||
# These owners will be the default owners for everything in the repo. | ||
* @cofiem |
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,48 @@ | ||
name: Bug Report | ||
description: Create a report to help us improve | ||
title: "[Bug]: " | ||
labels: | ||
- bug | ||
assignees: | ||
- cofiem | ||
body: | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Describe the problem | ||
description: A summary of the problem you've seen. | ||
placeholder: Tell us what you see! | ||
value: "e.g. When the program is given these arguments, it does this action I don't want ..." | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduce | ||
attributes: | ||
label: Steps to reproduce the behavior | ||
description: Your step-by-step guide to help use reproduce the problem. | ||
placeholder: Tell us what you see! | ||
value: "e.g. Run using these arguments ... Look in at the output in this folder ..." | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: expected | ||
attributes: | ||
label: Expected behavior | ||
description: What do you expect to happen? | ||
placeholder: Tell us what you want to see! | ||
value: "e.g. Run using these arguments ... should do this ..." | ||
validations: | ||
required: true | ||
- type: input | ||
id: program-details | ||
attributes: | ||
label: Program Details | ||
description: What operating system and what version of the program is being used? | ||
placeholder: "e.g. OS: [e.g. iOS], Program version [e.g. 2.1]" | ||
validations: | ||
required: false | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Please attach any screenshots or logging output to help explain your problem. | ||
Thanks for taking the time to fill out this bug report! |
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,31 @@ | ||
name: Feature Request | ||
description: Suggest an idea for this project | ||
title: "[Feature]: " | ||
labels: | ||
- enhancement | ||
assignees: | ||
- cofiem | ||
body: | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Describe the feature | ||
description: A summary of the new functionality you'd like | ||
placeholder: Tell us what you want to see! | ||
value: "e.g. It would be nice to be able to do this and get this output ..." | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: alternative | ||
attributes: | ||
label: Are there other approaches? | ||
description: Any alternative solutions or features you've considered | ||
placeholder: Tell us what else could be done | ||
value: "e.g. Your program could interact with this other program like this ..." | ||
validations: | ||
required: true | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Please attach any screenshots or other files to help explain your feature. | ||
Thanks for taking the time to fill out this feature request! |
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,24 @@ | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
target-branch: "main" | ||
open-pull-requests-limit: 3 | ||
|
||
# Maintain dependencies for pip packages | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
target-branch: "main" | ||
commit-message: | ||
prefix: "pip stable" | ||
prefix-development: "pip dev" | ||
open-pull-requests-limit: 3 |
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,11 @@ | ||
documentation: | ||
- docs/**/* | ||
|
||
dependencies: | ||
- requirements.txt | ||
- requirements-dev.txt | ||
- pyproject.toml | ||
- MANIFEST.in | ||
|
||
tests: | ||
- tests/**/* |
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,18 @@ | ||
# Automatically generate release notes | ||
# .github/release.yml | ||
# see https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes | ||
|
||
changelog: | ||
categories: | ||
- title: New Features | ||
labels: | ||
- enhancement | ||
- title: Bug Fixes | ||
labels: | ||
- bug | ||
- title: Documentation changes | ||
labels: | ||
- documentation | ||
- title: Dependency updates | ||
labels: | ||
- dependencies |
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,57 @@ | ||
name: Code Analysis | ||
|
||
on: | ||
schedule: | ||
- cron: '04 2 * * 4' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ "python" ] | ||
python-version: [ "3.9", "3.10", "3.11" ] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
|
||
- name: Install dependencies | ||
run: | | ||
echo "::group::Pip dependencies" | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install --upgrade -r requirements-dev.txt -r requirements.txt | ||
python -m pip install . | ||
echo "::endgroup::" | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
setup-python-dependencies: false | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
|
||
- name: Run pip audit | ||
uses: pypa/[email protected] | ||
continue-on-error: true | ||
with: | ||
inputs: requirements.txt requirements-dev.txt |
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,21 @@ | ||
name: Labeler | ||
|
||
on: | ||
pull_request_target: | ||
types: [ "opened" ] | ||
branches: [ "main" ] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
label: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/labeler@v4 | ||
with: | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" |
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,59 @@ | ||
name: Test Package | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test_lint: | ||
name: Test and lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [ "3.9", "3.10", "3.11" ] | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
|
||
- name: Install dependencies | ||
run: | | ||
echo "::group::Pip dependencies" | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install --upgrade -r requirements-dev.txt -r requirements.txt | ||
echo "::endgroup::" | ||
- name: Run pytest coverage | ||
if: matrix.python-version == '3.9' | ||
run: | | ||
echo "::group::Tests - Run tests with coverage" | ||
( | ||
set -o pipefail | ||
python -X dev -m pytest --doctest-modules \ | ||
--junitxml=artifact-pytest-coverage.xml \ | ||
--cov-report=term-missing:skip-covered --cov=src/ tests/ | tee artifact-pytest-coverage.txt | ||
) | ||
echo "::endgroup::" | ||
# run tests using tox | ||
# https://tox.wiki/en/latest/config.html#conf-basepython | ||
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#running-tests-with-tox | ||
- name: Run tox | ||
run: | | ||
python -X dev -m tox -e py |
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,84 @@ | ||
# Server monitor agent contributing guide | ||
|
||
## Development | ||
|
||
Create a virtual environment: | ||
|
||
```bash | ||
python -m venv .venv | ||
``` | ||
|
||
Install runtime dependencies and development dependencies: | ||
|
||
```bash | ||
# Windows | ||
.venv\Scripts\activate.ps1 | ||
|
||
# Linux | ||
source .venv/bin/activate | ||
|
||
# install dependencies | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install --upgrade -r requirements-dev.txt -r requirements.txt | ||
|
||
# check for outdated packages | ||
pip list --outdated | ||
``` | ||
|
||
## Create and upload release | ||
|
||
Generate the distribution package archives. | ||
|
||
```bash | ||
python -X dev -m build | ||
``` | ||
|
||
Upload archives to Test PyPI first. | ||
|
||
```bash | ||
python -X dev -m twine upload --repository testpypi dist/* | ||
``` | ||
|
||
When uploading: | ||
|
||
- for username, use `__token__` | ||
- for password, create a token at https://test.pypi.org/manage/account/#api-tokens | ||
|
||
Go to the [test project page](https://test.pypi.org/project/server-monitor-agent) and check that it looks ok. | ||
|
||
Then create a new virtual environment, install the dependencies, and install from Test PyPI. | ||
|
||
```bash | ||
python -m venv .venv-test | ||
source .venv-test/bin/activate | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install --upgrade -r requirements.txt | ||
|
||
SERVER_MONITOR_AGENT_VERSION='0.1.0' | ||
pip install --index-url https://test.pypi.org/simple/ --no-deps server-monitor-agent==$SERVER_MONITOR_AGENT_VERSION | ||
``` | ||
|
||
Test the installed package. | ||
|
||
```bash | ||
server-monitor-agent --version | ||
server-monitor-agent --help | ||
server-monitor-agent memory | ||
server-monitor-agent cpu | ||
server-monitor-agent systemd-service | ||
``` | ||
|
||
If the package seems to work as expected, upload it to the live PyPI. | ||
|
||
```bash | ||
python -X dev -m twine upload dist/* | ||
``` | ||
|
||
When uploading: | ||
|
||
- for username, use `__token__` | ||
- for password, create a token at https://pypi.org/manage/account/#api-tokens | ||
|
||
Go to the [live project page](https://pypi.org/project/server-monitor-agent) and check that it looks ok. | ||
|
||
Done! |
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,3 @@ | ||
include VERSION | ||
include requirements.txt | ||
include requirements-dev.txt |
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 |
---|---|---|
@@ -1,18 +1,5 @@ | ||
# server-monitor-agent | ||
|
||
A simple Python application for running checks on a server and sending formatted notifications. | ||
A Python application for running checks on a server. | ||
|
||
This program is an agent that can be run on server instances. | ||
It provides a number of commands to do common tasks. | ||
|
||
## Commands | ||
|
||
### Check | ||
|
||
Gather information about the instance and report the result via | ||
exit code and json-formatted output. | ||
|
||
### Notify | ||
|
||
Send a message to an alerting service. | ||
One message contains details about one service. |
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 @@ | ||
0.1.0 |
Oops, something went wrong.