I have a script that I'm going to use for our FreePBX with Asterisk phone system. I would like to know if any of our extensions/endpoints are offline/unavailable, I would like to be sent that info in an email.
#!/bin/bash email="firstname.lastname@example.org" offlineExtensions=$(asterisk -rx 'pjsip show contacts' | grep -i "unavail") if [ "$offlineExtensions" ] then echo $offlineExtensions | mail -s "Extensions Offline" $email fi
My email looks like...
Contact: 7101/sip:7101@IP_ADDRESS:5060 d20a378e88 Unavail 55.829 Contact: 7770/sip:7770@IP_ADDRESS:5060 174a796f10 Unavail 12.275
I would like the contacts info to be on their own separate line, not concatenated together. I've used the next line symbol(\n) in the script but it doesn't seem to work.
Any ideas, please?