Has anyone got a working bash script they could share for checking if a node is connected, and then reconnecting if it is not? I have found an example on the forum (below) but this one does not seem to work.
If anyone can share a working script, I would be very grateful!
73
Robert
date >> /usr/sbin/cron_check.txt
CHK=
echo “Checking if connected to the hub”
CHK= asterisk -rx "rpt nodes 537101" | grep -c "51288"
echo $CHK >> /usr/sbin/cron_check.txt
if [ $CHK -eq 1 ]
then
echo “OK, Connected.”
echo “OK, connected.” >> /usr/sbin/cron_check.txt
else
echo “Reconnecting.”
echo “Reconnecting.” >> /usr/sbin/cron_check.txt
asterisk -rx “rpt cmd 537101 ilink 3 51288”
fi
#End
It throws out the error:
“Checking if connected to the hub”
1
./autoconnect.sh: line 8: [: =: unary operator expected
“Reconnecting.”
No such command '“rpt' (type 'core show help “rpt' for other possible commands)
Try changing it to “rpt fun 537101 *351288” maybe? That’s what I would do, but you could probably remove the spaces so it’s “rpt cmd 527101 ilink351288” and I bet that might work too.
This functionality is already built into app_rpt with permanent connections and startupmacro. Just curious, why complicate things with an external script?
it is to check to make sure you are connected. if the other end drops and you are not aware of it then startup_macro will not help you. especially if there is a node down for some unknown reason.
A permanent connection will continually retry a connection if it is ever dropped. If you do a startup macro for a permanent connection, then the script would not be needed. Asterisk would make sure the connection to the node is established whenever possible, forever.
This is true but permanent connections are only permanent dialing out. If they get disconnected from the other end, or some other hiccup, it won’t redial.
I have the start up permanent connection *813nnnnn as well as the script