Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
alarm system for my network
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ee99ee2
Guru
Guru


Joined: 18 Jun 2002
Posts: 307
Location: Murfreesboro, TN, USA

PostPosted: Sat Nov 02, 2002 8:26 pm    Post subject: alarm system for my network Reply with quote

This is kind of a weird question, so bare with me. My network (my ISP) has a tendency to go offline alot. I was wondering if there was a way I could write a program that would ping say their DNS server all the time, and if it doesn't get a responce for more then 10 seconds, it set off some kind of alarm. I'm thinking maybe hook up a pizeo buzzer up to my serial port? Which pins have how much power? Then the program pulse the power on the serial port to make the buzzer buzz on and off.

Reason a buzzer is so I can wire it up next to my bed, and if it goes down it'll wake me up. I know it's kinda stupid, but hey, why not? haha.

-ee99ee2
_________________
ServerMotion
Back to top
View user's profile Send private message
c_kuzmanic
Guru
Guru


Joined: 18 Apr 2002
Posts: 488
Location: Los Angeles , California

PostPosted: Sat Nov 02, 2002 10:31 pm    Post subject: Reply with quote

Ok, I corrected my post and put up a simpler version of the previous script. This script simply checks network status and plays an alarm sound when the network is down.

#!/bin/sh

# netcheck.sh
# Christian Andreas Kuzmanic, 11-02-2202
#
# Description: Simple script to check network connection status at specified interval.
# If the network goes down, netcheck will play an alarm to alert the admin.
#
# Requires : fping, sox.
# Usage: Run from console or xterm as root.

#configuration

PINGTARGET=207.69.188.185 #put your gateway or dns server here, this is the machine you will ping to check your connection.
ALARMSOUND=/usr/share/sounds/gabber/gabber_connected.wav #any soundfile will do, look for some in /usr/share/sounds
INTERVAL=300 # interval to ping $PINGTARGET in seconds, should be set to more than five minutes as not to burden the target

#do some checks for required user and progs

if [ "`/usr/bin/id -u`" != "0" ]; then
echo "Oops, you must run this script as root. Please su to root and run this script again."
#play $ALARMSOUND
exit 1
fi

if [ ! -f "/usr/sbin/fping" ];then
echo "Fping is not installed. Please emerge fping and run this script again"
#play $ALARMSOUND
exit 1

fi

if [ ! -f "/usr/bin/play" ];then
echo "Sox is not installed. Please emerge sox and run this script again"
exit 1

fi

#check if connection is alive

ALARM=0
i=0

while [ "$ALARM" -eq 0 ]; do


if `fping $PINGTARGET | grep -v alive > /dev/null`; then

echo "**** NETWORK STATUS ALERT: ***"

echo "---* `date` : Your Internet Connection seems to be down,"

echo "---* PINGTARGET is not responding. "

echo "---* Press CTRL-C to end this process."

ALARM=1


while [ "$ALARM" -eq 1 ]; do


play $ALARMSOUND

wait

ALARM=0

i=1

done

else

if [ "$i" = 0 ]; then

echo "---* `date` : Internet Connection is alive and well."
fi

if [ "$i" = 1 ]; then

echo "---* `date` : Internet Connection is alive after temporary outage."

fi
sleep $INTERVAL

fi

done
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum