[arm-allstar] Announce when Internet is lost
Danny K5CG
k5cg at hamoperator.org
Mon Nov 13 23:28:05 EST 2023
Ok I tested this and it works, it created the /tmp file too.
#!/usr/bin/bash
wget -q --spider http://google.com
result=$?
# if the test fails and the tmp file does not exist
if [[ $result -gt 0 ]] && [[ ! -f /tmp/internetdown ]] ; then
# play the message
/usr/bin/asterisk -rx "rpt localplay 40039 /etc/asterisk/local/offline"
# create the flag
touch /tmp/internetdown
elif [[ $result -eq 0 ]] && [[ -f /tmp/internetdown ]] ; then
# internet is back online
/usr/bin/asterisk -rx "rpt localplay 40039 /etc/asterisk/local/online"
# remove the flag
rm -f /tmp/internetdown
fi
I did not disconnect the network however, I changed "google" to "gaagle" to ensure it would fail the test.
73
Danny, K5CG
HH 550-000-0609
SKCC 14257
----- Original Message -----
From: "ARM Allstar" <arm-allstar at hamvoip.org>
To: "Dave Petrie" <wa2kjc at gmail.com>
Cc: "Danny Siminiuk" <k5cg at hamoperator.org>, "ARM Allstar" <arm-allstar at hamvoip.org>
Sent: Monday, November 13, 2023 8:33:07 PM
Subject: Re: [arm-allstar] Announce when Internet is lost
Dave,
This script will run as root from crontab so you don't really need the sudo at the front.
And use -rx for playback, as well you probably want localplay instead of playback for the local repeater only.
You could touch/remove a file in /tmp to track current status. Like this.
wget -q --spider [ http://google.com/ | http://google.com ]
# if the test fails and the tmp file does not exist
if [ $? -gt 0 ] -a [ ! -f /tmp/internetdown ] ; then
# play the message
/usr/bin/asterisk -rx "rpt localplay 40039 /etc/asterisk/local/ offline "
# create the flag
touch /tmp/internetdown
else
# internet is back online
/usr/bin/asterisk -rx "rpt localplay 40039 /etc/asterisk/local/ online "
# remove the flag
rm -f /tmp/internetdown
fi
Something like that.
Let me know...
73
Danny, K5CG
HH 550-000-0609
SKCC 14257
From: "Dave Petrie" <wa2kjc at gmail.com>
To: "ARM Allstar" <arm-allstar at hamvoip.org>
Cc: "Danny Siminiuk" <k5cg at hamoperator.org>
Sent: Monday, November 13, 2023 8:14:45 PM
Subject: Re: [arm-allstar] Announce when Internet is lost
got it, now to stop playing every minute the network is down or maybe
just change the announcement to a simple tone, beep, burp
but i don't want it to keyup every minute, getting there
wget -q --spider [ http://google.com/ | http://google.com ]
if [ $? -gt 0 ]; then
sudo /usr/bin/asterisk -vvvr -x "rpt playback 40039 /etc/asterisk/local/offline"
On Mon, Nov 13, 2023 at 8:34 PM Dave Petrie < [ mailto:wa2kjc at gmail.com | wa2kjc at gmail.com ] > wrote:
ok i am working on it, almost there, it's not announcing yet when i unplug the internet to the raspberry with the repeater up and running
here is what i have done, tell me what you think and what do i change to announce it is back when i can ping google,
do i change the -gt 0 to a -gt 1 in another line
i named your script internet.sh and put it in /etc/asterisk/local
and chmod +x internet.sh
#!/usr/bin/bash
wget -q --spider [ http://google.com/ | http://google.com ]
if [ $? -gt 0 ]; then
echo sudo /usr/bin/asterisk -vvvr -x "rpt playback 40039 /etc/asterisk/local/offline"
fi
then in crontab -e
it plays from the command line just not automatically from disconnecting the internet and waiting 3 or 4 minutes
*/1 * * * * /etc/asterisk/local/internet.sh
On Mon, Nov 13, 2023 at 7:28 PM Danny K5CG via ARM-allstar < [ mailto:arm-allstar at hamvoip.org | arm-allstar at hamvoip.org ] > wrote:
BQ_BEGIN
Dave,
There's probably so many ways to do that they can't be listed, but here's one that should work for you.
Create a new script and give it execute permission.
#!/usr/bin/bash
wget -q --spider [ http://google.com/ | http://google.com ]
if [ $? -gt 0 ]; then
echo "Offline"
fi
Replace the echo line with whatever asterisk command you want that will play a local file.
Add the script to your crontab to run every minute.
One idea of many.
73
Danny, K5CG
HH 550-000-0609
SKCC 14257
----- Original Message -----
From: "ARM Allstar" < [ mailto:arm-allstar at hamvoip.org | arm-allstar at hamvoip.org ] >
To: "ARM Allstar" < [ mailto:arm-allstar at hamvoip.org | arm-allstar at hamvoip.org ] >
Cc: "Dave Petrie" < [ mailto:wa2kjc at gmail.com | wa2kjc at gmail.com ] >
Sent: Monday, November 13, 2023 7:22:57 AM
Subject: [arm-allstar] Announce when Internet is lost
Is there anyway to run a script that would ping let's say 8.8.8.8 and
announce
over the local repeater the hamvoip raspberry is controlling, that the
internet has been lost, disconnected.
I am helping a Ham friend that is a History teacher at a school and is
setting up, with the support and enthusiasm from school staff and
principal, a uhf repeater with a internet hotspot that recently stopped
working, i know there are lots of reason for the disconnect, we just want
to know when it happens.
Thanks
Dave
_______________________________________________
ARM-allstar mailing list
[ mailto:ARM-allstar at hamvoip.org | ARM-allstar at hamvoip.org ]
[ http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar | http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar ]
Visit the BBB and RPi2/3/4 web page - [ http://hamvoip.org/ | http://hamvoip.org ]
_______________________________________________
ARM-allstar mailing list
[ mailto:ARM-allstar at hamvoip.org | ARM-allstar at hamvoip.org ]
[ http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar | http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar ]
Visit the BBB and RPi2/3/4 web page - [ http://hamvoip.org/ | http://hamvoip.org ]
BQ_END
_______________________________________________
ARM-allstar mailing list
ARM-allstar at hamvoip.org
http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
Visit the BBB and RPi2/3/4 web page - http://hamvoip.org
More information about the ARM-allstar
mailing list