egor-lukin / ip-monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IP Monitoring

Service for monitoring ip addresses (v4, v6) availability and aggregating stats.

Description

Service sends icmp packet every 1 minutes and saves result, success or not, to the ip_addresses table. Additionally, we can enable stats collection - after that we save rtt result to the ip_checks table. If rtt takes more than 1s - we drop request and save info about dropped packet to ip_checks table also. Info about active stats monitoring periods keeps in ip_monitoring_periods table. Additional project goal - research dry.rb, rom.rb and grape gems.

TODO

  • check ipv4/ipv6 address
  • add api for control ip address and collecting stats
  • use dry-system
  • use dry-monads
  • use rom.rb / sequel
  • use grape
  • use docker-compose
  • add github actions
  • add native ip checker

Dev environment

Prepare and run project

dip provision
dip web

Run rspec

dip rspec

Run rubocop

dip rubocop

Run psql

dip psql

IPv6

For working with ipv6 inside docker check that you enable v6 support - https://docs.docker.com/config/daemon/ipv6/

API Requests

  • Create IP
curl -X POST http://localhost:3000/ips \
   -H 'Content-Type: application/json' \
   -d '{"ip":"2a00:1450:4001:82b::200e","enable":true}'
   
curl -X POST http://localhost:3000/ips \
   -H 'Content-Type: application/json' \
   -d '{"ip":"8.8.8.8","enable":true}'
  • Enable/disable stats collection
curl -X POST http://localhost:3000/ips/:id/enable
curl -X POST http://localhost:3000/ips/:id/disable
  • Get ip stat
curl 'http://localhost:3000/ips/1/stats?time_from=2023-08-16&time_to=2023-08-22'
  • Delete ip (soft) and disable stats collection
curl -X DELETE http://localhost:3000/ips/:id

About


Languages

Language:Ruby 94.2%Language:Dockerfile 5.3%Language:Shell 0.6%