I have seen this script in the forum but it is not working
#!/bin/bash
[email protected]
HOST=xxxxxx.dk
asteriskbin=/usr/sbin/rasterisk
thistrunk=Viptel_xxxxxxx
checkifok=$asteriskbin -rx "sip show peer $thistrunk" | grep Status | grep -wc OK
if [[ $checkifok == 0 ]]; then
$asteriskbin -rx "core restart now"
echo "Trunk is DOWN" | mail -s " - Trunk is Down [$HOST] -" "$EMAIL"
else
echo "Trunk OK"
fi
I get "line 8: -rx: command not found"
I run Freepbx Current Asterisk Version: 13.9.1
So you didn’t do what I said, and then you’re surprised it didn’t work? Use the back tick (the one under the tilde ~). One other thing that might be jamming you up you can try adding the “export” to your command
thistrunk=Viptel_xxxxxxx
checkifok=$asteriskbin -rx “sip show peer $thistrunk” | grep Status | grep -wc OK
if [[ $checkifok == 0 ]]; then
$asteriskbin -rx “core restart now"
echo “Trunk is DOWN” | mail -s " - Trunk is Down [$HOST] -” "$EMAIL"
else
echo "Trunk OK"
fi
you can’t the back tick made in this forum I don’t know why
when I save the go away
This is like firing a nuke at your girlfriend because she didn’t answer the first time you called.
If a trunk goes down in a manner that can be fixed by “restarting asterisk” then you need to fix the problem that is making it go down NOT restart asterisk. If it is going down for some other reason then restarting asterisk doesn’t matter.
It is my VDSL there is going Down some time and than the only thing I can get it to Work again is to reboot freepbx
or restart asterisk, and it is only when it goes real Down if I unplug the ehternet from my modem an put back in everything is ok
perhaps this should not be so, but it is