Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: northpowered/SimpleSLA
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.1
Choose a base ref
...
head repository: northpowered/SimpleSLA
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 17 commits
  • 20 files changed
  • 2 contributors

Commits on Sep 6, 2022

  1. Copy the full SHA
    2c9d8df View commit details
  2. Copy the full SHA
    50a5ab9 View commit details
  3. Update requirements.txt

    romanov committed Sep 6, 2022
    Copy the full SHA
    b8dafa1 View commit details
  4. Config example to deploy docker image

    romanov committed Sep 6, 2022
    Copy the full SHA
    b3b2827 View commit details
  5. Update CI workflow

    romanov committed Sep 6, 2022
    Copy the full SHA
    0530bea View commit details
  6. CI clean

    romanov committed Sep 6, 2022
    Copy the full SHA
    3019ac5 View commit details
  7. bumped version

    romanov committed Sep 6, 2022
    Copy the full SHA
    39b9aee View commit details
  8. README update

    romanov committed Sep 6, 2022
    Copy the full SHA
    c0e2bfb View commit details
  9. Base docs structure

    romanov committed Sep 6, 2022
    Copy the full SHA
    7989e3c View commit details

Commits on Sep 7, 2022

  1. ReadTimeout hotfix

    romanov committed Sep 7, 2022
    Copy the full SHA
    80fcc49 View commit details
  2. Base documentation

    romanov committed Sep 7, 2022
    Copy the full SHA
    2ad4816 View commit details
  3. Docs deploy workflow

    romanov committed Sep 7, 2022
    Copy the full SHA
    82d8d05 View commit details
  4. Merge pull request #13 from northpowered/5-mkdocs-documentation

    5 mkdocs documentation
    northpowered authored Sep 7, 2022
    Copy the full SHA
    b539772 View commit details
  5. Docs CD fix

    romanov committed Sep 7, 2022
    Copy the full SHA
    6391cd6 View commit details
  6. Copy the full SHA
    70a0be0 View commit details
  7. Update README.md

    northpowered authored Sep 7, 2022
    Copy the full SHA
    fed5dbc View commit details

Commits on Sep 8, 2022

  1. Small refactoring

    romanov committed Sep 8, 2022
    Copy the full SHA
    9b109bd View commit details
38 changes: 34 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Docker Image CI
name: Docker Image CI/CD

on:
push:
branches: [ "master" ]
tags:
- 'v*.*.*'
pull_request:
branches: [ "master" ]

@@ -13,6 +15,34 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/simple-sla
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
17 changes: 17 additions & 0 deletions .github/workflows/documetation-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Documentation deployment

on:
push:
branches:
- master
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -2,11 +2,15 @@

FROM python:3.10-buster

LABEL org.opencontainers.image.source="https://github.com/northpowered/SimpleSLA"

LABEL version="2.0.2"

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python3", "main.py" , "--config=config.yml"]
CMD [ "python3", "main.py" , "--config=config.yml"]
126 changes: 11 additions & 115 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
[![CodeFactor](https://www.codefactor.io/repository/github/northpowered/simplesla/badge)](https://www.codefactor.io/repository/github/northpowered/simplesla)

[![Docker Image CI/CD](https://github.com/northpowered/SimpleSLA/actions/workflows/docker-image.yml/badge.svg)](https://github.com/northpowered/SimpleSLA/actions/workflows/docker-image.yml)
# SimpleSLA

Easy SLA control system for distribiuted networks

Full documentation available [here](https://northpowered.github.io/SimpleSLA/)

Obtain RTT value from devices, check policy and export all of this to Prometeus

Available ways to collect RTT:

- Directly from host with SimpleSLA (*simplesla-local* in 'device' field)
- Between two remote devices (SSH or telnet to closest device)

Supported devices:
- Cisco
- Juniper
- Eltex (ESR series)
- MT M716
- Potok KM-122
## Usage

TODO:
- Extending devices support
- Export data via logs (Loki way)
- Authentication via ssh with keys
- Logic for global_unit parameter
- Extend policies with severeties
- Async server
- Refactoring
- Tests
### Running from source
> pip install -r requirements.txt
## Usage
> python3 main.py -c config.yml
### In CLI mode
```bash
python3 main.py -c CONFIG

@@ -42,102 +33,7 @@ optional arguments:
Logging path {stdout,FILE}
--version show programs version number and exit
```
### Using docker image
> docker pull ghcr.io/northpowered/simple-sla:latest
## SLA statuses

| Status | Int value | Reccomended color | Description |
| ----------- | ----------- |------------------ |------------ |
| NoData | 0 | Black | No recieved data or parcing error |
| Normal | 1 | Green | Target is available and RTT less then policy |
| Warning | 2 | Yellow | Target is available and RTT bigger then policy |
| Error | 3 | Red | Target is unavailable |
| OutOfService| 4 | Green | Target is available and policy was not defined |

### Install:

```bash
pip install -r requirements.txt
python3 main.py -c config.yml
```
### Docker

```bash
docker build -t simplesla:yourtag .
docker run -p "8800:8800" simplesla:yourtag
```

### Configuration

All config is represented in YAML format

#### Section *server*
```yaml
server:
bind_address: '0.0.0.0' #[STRING] Ipv4 for binding http server with Prometheus endpoint
port: 8800 #[INT] Port for binding http server, be carefull about permissions for different port
refresh_time: 2 #[INT] Prometheus endpoint update time, in seconds

```
#### Section *global*
```yaml
global:
unit: 'ms' #[STRING] global unit of RTT [in progress]
```
#### Section *local*
Configuration of *simplesla-local* device
```yaml
local:
src_addr: '0.0.0.0' #[STRING] Source ping address
timeout: 1 #[INT] ICMP timeout in seconds
ttl: 64 #[INT] Max TTL for ICMP
size: 56 #[INT] Payload size in bytes
```
#### Section *devices*
```yaml
devices:
- name: 'RT' #[STRING] unique name of device
type: 'cisco' #[STRING] type of device, see supported device types
transport: 'telnet' #[STRING] telnet or ssh
address: '10.10.10.1' #[STRING] Device address
username: 'admin' #[STRING] Username (ssh/telnet)
password: 'cisco' #[STRING] Plaintext password (ssh/telnet)
port: 23 #[INT] Connection port for (ssh/telnet), default (22/23)
```
#### Section *policies*
```yaml
policies:
- name: mypolicy #[STRING] unique name of policy
max_rtt: 0.15 #[FLOAT] Max RTT in seconds
```
#### Section *services*
```yaml
services:
- name: 'service01' #[STRING] unique name of service
device: 'simplesla-local' #[STRING] Target device, device MUST exist in devices section, or simplesla-local
target: '192.168.0.2' #[STRING] ICMP target, which will be checked from device
delay: 3 #[INT] Check delay, in seconds
policy: mypolicy #[STRING] OPTIONAL police name, policy MUST exist in policies section
- name: 'sevice02'
device: 'RT'
target: '10.10.10.2'
delay: 4
```
#### Services groups
> To avoid multiple connections to one device, you can group your services, which should
be checked from one point
```yaml
ServicesGroups:
- name: mygroup
device: mydevice
policy: policy_for_all_subservices_without_own_policy
delay: 4 #the same for delay
services:
- name: serv1
target: '192.168.0.6'
policy: my_own_policy
- name: serv2
target: '10.3.5.3'
delay: 3
```
> docker run --name simple-sla ghcr.io/northpowered/simple-sla:latest
35 changes: 1 addition & 34 deletions config.yml
Original file line number Diff line number Diff line change
@@ -12,41 +12,8 @@ Local:
ttl: 64
size: 56

Devices:
- name: 'my_rt'
type: 'cisco'
transport: 'ssh'
address: '192.168.0.9'
username: 'admin'
password: 'password'
port: 22
- name: 'my_rt_2'
type: 'cisco'
transport: 'telnet'
address: '172.5.6.2'
username: 'cisco'
password: 'cisco'
port: 23

Policies:
- name: mypolicy
max_rtt: 0.15

ServicesGroups:
- name: mygroup
device: 'my_rt_2'
delay: 6
services:
- name: serv1
target: '16.35.48.3'
delay: 3
policy: mypolicy
- name: serv2
target: '10.71.206.75'

Services:
- name: 'service01'
device: 'simplesla-local'
target: '192.168.0.1'
target: '127.0.0.1'
delay: 20
policy: mypolicy
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ networks:
driver: bridge

services:
sla-simplesla:
image: "simplesla:latest"
container_name: sla-simplesla
simple-sla:
image: "ghcr.io/northpowered/simple-sla:latest"
container_name: simple-sla
restart: always
environment:
- SSLA_LL=INFO
63 changes: 63 additions & 0 deletions docs/configuration/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Examples

## Typical full config file

```yaml
Server:
bind_address: '0.0.0.0'
port: 8800
refresh_time: 2

Global:
unit: 'ms'

Local:
src_addr: '0.0.0.0'
timeout: 1
ttl: 64
size: 56

Devices:
- name: 'RT_1'
type: 'cisco'
transport: 'telnet'
address: '192.168.0.1'
username: 'user'
password: 'password'
port: 23
- name: 'RT_2'
type: 'juniper'
transport: 'ssh'
address: '192.168.0.9'
username: 'user'
password: 'password'
port: 22


Policies:
- name: mypolicy
max_rtt: 0.9

ServicesGroups:
- name: mygroup
device: 'RT_1'
services:
- name: serv1
target: '10.26.6.3'
delay: 3
policy: mypolicy
- name: serv2
target: '10.26.6.9'
delay: 8

Services:
- name: 'service01'
device: 'simplesla-local'
target: '192.168.0.24'
delay: 16
- name: 'service02'
device: 'RT_2'
target: '16.2.6.9'
delay: 5
policy: mypolicy
```
Loading