Code Monkey home page Code Monkey logo

hermod-api's Introduction

HERMOD : Monitoring notification API for RouterOS

Monitoring actions for RouterOS netwatch

https://en.wikipedia.org/wiki/Herm%C3%B3%C3%B0r Hermóðr the Brave (Old Norse "war-spirit";[1] anglicized as Hermod) is a figure in Norse mythology, a son of the god Odin. He is often considered the messenger of the gods.

Getting started

Docker-compose

Before you begin

You need to:

  • setup OVH API
  • setup env config file
OVH SMS : API configuration

Please follow python-ovh documentation to get config variables : https://github.com/ovh/python-ovh/blob/master/README.rst

API Configuration

NOTE: DB and REDIS hosts are based on docker-compose services names (docker internal DNS names)

.env file sample

API_HOST=0.0.0.0
API_PORT=9090
API_URL=hermod.api.domain.tld
API_PROTOCOL=http
API_LOG_FILE=hermod-api.log

DB_HOST=db
DB_PORT=3306
DB_DATABASE=hermod_api
DB_USER=hermod
DB_PASSWORD=hermod_password

REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=

SMTP_SERVER=smtp.domain.tld
SMTP_PORT=587
SMTP_USE_TLS=yes
[email protected]
SMTP_PASSWORD=smtp_password

OVH_ENDPOINT=ovh-eu
OVH_APPLICATION_KEY=
OVH_APPLICATION_SECRET=
OVH_CONSUMER_KEY=
Build and run

NOTE: mysql intialization can last few minutes on first launch due to use of docker-entrypoint-initdb

docker-compose up --build -d

Docker stack in swarm environment

Before you begin

You need to:

  • deploy a registry
  • follow 'Docker-compose' documention above to set env variables
  • build and push images
  • deploy

Registry

docker service create --name registry --publish published=5000,target=5000 registry:2

Build & push

docker-compose build
docker-compose push

Deploy

docker stack deploy --compose-file docker-compose.yml hermod-api

Database table definitions

Initialization is done by docker-compose, init file provided in db/init.sql

HTTP call examples

GET

Get json of requested entity

  • list of all routers:
curl http://127.0.0.1:9090/router
  • specific user:
curl http://127.0.01:9090/user/admin

POST

Add new entity

  • add new router:
curl -X POST -d "loopback=10.0.10.1" http://127.0.0.1:9090/router/test1

PUT

Modiy existing entity

  • set phone and email address on user:
curl -X PUT -d "phone='+336684684984'&[email protected]" http://127.0.0.1:9090/user/test1

DELETE

Remove entity

  • delete router 'test1':
curl -X DELETE http://127.0.0.1:9090/router/test1

Mikrotik scripts

Update '/host'

Source

NOTE: API is made to auto-generate (POST) new host object on first request, you don't need to declare it

You can use API to retreive script templates :

curl -X GET -d "email=True&user=admin" http://127.0.0.1:9090/host/template/192.168.1.1

Update '/router'

Source

NOTE: You need to create router first by using POST method on /router (documentation in HTTP call examples above)

scheduler: /system scheduler add name=api-put-router start-time=jan/01/1970 start-time=00:00:00 interval=5m on-event="system script run api-put-router"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.