This project gathers metrics for local or hosted servers that can be run on a server used to post data to Grafana and Prometheus.
Project description
Starlyng Server Metrics
This project gathers metrics for local or hosted servers that can be run on a server used to post data to Grafana and Prometheus.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have installed Python 3.x.
- You have a basic understanding of Python and virtual environments.
Setting Up Your Development Environment
To set up your development environment and run the project, follow these steps:
Clone the Repository
First, clone the repository to your local machine:
git https://github.com/starlyngapp/server-metrics.git
cd server-metrics
Create and Activate Virtual Environment
For macOS and Linux:
python -m venv venv
source venv/bin/activate
For Windows:
python -m venv venv
venv\Scripts\activate
Setup Environment for VSCode
- Open the Command Palette (Ctrl+Shift+P)
- Search for the Python: Create Environment command, and select it
- Select Venv
- Select Python interpreter
- Select dependencies to install
Install Required Packages
Install all dependencies listed in the dev-requirements.txt file:
pip install -r dev-requirements.txt
Installation
To install only the package (without dev dependencies):
pip install starlyng_server_metrics
To install development dependencies (useful for contributing to the project):
pip install starlyng_server_metrics[dev]
Alternatively, you can install the development dependencies using:
pip install -r dev-requirements.txt
Environment Configuration
To configure the server metrics collection, you need to set up environment variables. This can be done by creating a .env file in the root of the project.
An example .env file is provided as .env.example. You can copy this file and update the values as needed.
Steps to Configure Environment Variables
- Copy the example environment file:
cp .env.example .env
- Open the
.envfile and update the values:
# .env
# List of server IPs and ports in the format ip:port, separated by commas
SERVERS=192.168.1.1:22,192.168.1.2:22
# Path to the SSH private key
KEY_PATH=/path/to/your/.ssh/id_rsa
# SSH username
USERNAME=your_username
- Save the
.envfile.
The SERVERS variable should be a comma-separated list of server IP addresses and ports. The KEY_PATH should point to the SSH private key file you will use for authentication, and USERNAME should be the SSH username.
Usage
To run the main function:
server_metrics
PyPI
Command-line Arguments
You can also override configuration using command-line arguments:
server_metrics --servers "192.168.1.1:22,192.168.1.2:22" --key_path "/path/to/your/.ssh/id_rsa" --username "your_username"
Or locally:
python main.py --servers "192.168.1.1:22,192.168.1.2:22" --key_path "/path/to/your/.ssh/id_rsa" --username "your_username"
Building and Uploading Your Package
- Build the package:
python setup.py sdist bdist_wheel
- Upload to PyPI:
twine upload dist/*
Upload using specific project name referenced in .pypirc
twine upload dist/* --repository starlyng-server-metrics
Running Tests
To run tests, execute the following command in your terminal:
pytest
This command will run all tests and report the results. You can also run specific tests by providing the path and filename of the test file.
Contributing to the Project
Contributions to this project are welcome. Here's how you can contribute:
- Fork the project.
- Create your feature branch (git checkout -b feature/YourFeature).
- Commit your changes (git commit -am 'Add some YourFeature').
- Push to the branch (git push origin feature/YourFeature).
- Open a pull request.
Contact
If you have any questions, please contact us at:
- GitHub: @justinsherwood
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starlyng_server_metrics-0.9.7.tar.gz.
File metadata
- Download URL: starlyng_server_metrics-0.9.7.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
330d99cec7363852a02ddee0e4d9b7a51fe9b7b28c33658927f8cfb19ccff17b
|
|
| MD5 |
de5e7394aff7a8e47d7000d9d9c1db37
|
|
| BLAKE2b-256 |
310969d184c49c483262925e785d052e22668f9031c64ba69b12df7850fd1b3d
|
File details
Details for the file starlyng_server_metrics-0.9.7-py3-none-any.whl.
File metadata
- Download URL: starlyng_server_metrics-0.9.7-py3-none-any.whl
- Upload date:
- Size: 59.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59f6578f1852f9328abc866dd9b5184170a06a1b021842c9cabe7161c2011cbd
|
|
| MD5 |
42849ee01b97cb0ab455c6478bd8c6c6
|
|
| BLAKE2b-256 |
1e3ad3e581b014ff0eba756b78b66e4f68151861abf807802cb323e2bef5ce8b
|