0
I am trying to monitor our voip sip trunk carrier if it becomes unavailable i get an email from script below, the command in the script is working fine create log file in /tmp/checkpeers but script is not sending out email i have tried many options as they can be seen in the script below, i have also tested mail delivery agent is enable and i have sent out some test emails using email -s "test" me@me.com it works, can someone please help out with this.
#!/bin/sh
# Check for Offline SIP Peers
#peername=vitel-inbound2/kdc_gatine
rm -f /tmp/checkPeers
#/usr/sbin/asterisk -rx 'sip show peers' | grep UNKNOWN >/tmp/checkPeers
#asterisk -rx "sip show peers" | grep vitel-inbound2/kdc_gatine | grep -v OK
asterisk -rx "sip show peers" | grep vitel-inbound2/kdc_gatine | grep -v OK >/tmp/checkpeers
if [ -s "/tmp/checkPeers" ]; then
mail -s "Vitelity Inbound SIP Connection OffLine please Check" me@me.com < /tmp/checkpeers
#[EMAIL="me@me.com"]me@me.com[/EMAIL] </tmp/checkpeers
#SUBJECT="Vitelity Inbound SIP Connection OffLine please Check"
#EMAILID="me@me.com" </tmp/checkPeers
#$SUBJECT
#$EMAILID
fi
Are you able to send an email from the command line using 'mail -s'? – Tyson – 2018-02-22T18:34:54.550
Yes it works with mail -s no problem – user313162 – 2018-02-22T18:37:09.063
How is the script being run? Note that the
asterisk
line will create/tmp/checkpeers
(which may be empty and will fail a-s
test), but you are removing and later testing for/tmp/checkPeers
, which is a different file, though themail
command takes input from the lower-case file. – AFH – 2018-02-22T19:25:40.457even if i comment rm -f /tmp/check.. it still does't sent out email, and i am running script manually sh monitorsip.sh, also the script has 755 permissions – user313162 – 2018-02-22T19:28:04.517