Skip to content

epmakOFF/netwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Russian README

NetWatch

NetWatch is a simple bash script that monitors network connectivity to specified hosts and executes scripts when connections are lost.

Table of Contents

Usage

netwatch.sh HOST SCRIPT

Where:

  • HOST: IP address or hostname to monitor
  • SCRIPT: Command or script to execute when host becomes unavailable

Examples

netwatch.sh 1.1.1.1 /usr/local/bin/my_script 
netwatch.sh 8.8.8.8 reboot 
netwatch.sh 1.1.1.1 "echo hello world"

Configuration

Make the script executable:

chmod +x netwatch.sh

You can change the time between checks by changing the variable DELAY in the script.

The script checks for the existence of the specified command or script. It also validates that the host is a valid IP address.

How it works

  1. The script pings the specified host every 10 seconds.
  2. If the host becomes unavailable (3 consecutive failed pings), it executes the specified script.
  3. When the host becomes available again, it resets the counters and status.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages