Skip to content

Ivashkka/net-monitor

Repository files navigation

NET-MONITOR

Linux daemon for monitoring network hosts availability


install:

install make and git package:

apt install make git

clone this git repo:

cd ~

git clone https://github.com/Ivashkka/net-monitor.git

cd net-monitor

start make install from root:

sudo make install; cd ~

wait until installation finishes

after the installation is finished, configure conf.yaml:

vim /etc/net-monitor/conf.yaml

also write scripts that will react to changes in the states of network groups (see conf.yaml)

start net-monitor:

systemctl start net-monitor

systemctl status net-monitor

and enable if needed:

systemctl enable net-monitor


settings:

all net-monitor settings located in /etc/net-monitor/conf.yaml

monitor:
  hosts: # actual hosts
    - name: ISP1
      addr: 172.16.1.1
      type: icmp # currently only icmp and command are supported
    - name: ISP2
      addr: 172.16.2.1
      type: icmp
    - name: ISP3
      addr: 172.16.3.1
      type: command
      exec: bash /usr/local/bin/check-isp3-availability.sh # exit 1 or 0 # exec param is ignored when type != command
  groups: # availability groups of hosts
    - name: HA-ISP
      hosts: [ ISP1, ISP2, ISP3 ]
      interval: 5 # seconds
      exec: /usr/local/bin/ha-isp.sh # the script is called when the availability state changes
      #with arguments indicating which hosts remain available
      #this exec param is not the same as one in hosts directive. Here you can only pass path to script
    - name: SINGLE-ISP3
      hosts: [ ISP3 ]
      interval: 10 # seconds
      exec: /usr/local/bin/isp3.sh
      #### optional group settings: ####
      args: #default arguments: ALL, , NONE
        - default: ALL # redefinition of default 'ALL' argument to 'up' argument
          redefine: up
        - default: NONE # redefinition of default 'NONE' argument to 'down' argument
          redefine: down

hosts - list of network hosts and info about it. Use icmp or command types.

groups - actual monitoring units. Group can contain one or more hosts. When availability ststus changes,

net-monitor calls specified in exec field script with arguments indicating which hosts remain available.

net-monitor daemon works in bg and monitors specified groups.

example of /usr/local/bin/ha-isp.sh script:

case $1 in
    ALL)
        ip route replace default \
            nexthop via 172.16.1.1 dev enp0s3 weight 1 \
            nexthop via 172.16.2.1 dev enp0s8 weight 1
    ;;
    ISP1)
        ip route replace default via 172.16.1.1 dev enp0s3
    ;;
    ISP2)
        ip route replace default via 172.16.2.1 dev enp0s8
    ;;
esac

where ALL, HOST, NONE - arguments passed from net-monitor on script call

you can redefine default arguments whith your own in conf.yaml

net-monitor demonstration:


uninstall:

stop net-monitor:

systemctl stop net-monitor

disable autorun if needed:

systemctl disable net-monitor

move inside net-monitor git repo directory(where you cloned net-monitor.git):

cd ~/net-monitor

start uninstall process:

make clean


About

Network monitor daemon for linux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published