http://phonewire.com/wp-content/uploads/Xorcom-Logo.jpg

 

https://www.cluecon.com/media/img/sponsor/voip-info_logo_x170_v2.png

 

https://lh5.googleusercontent.com/-UUDyQ0CdJwY/UsXGpq9p6DI/AAAAAAAAP-A/vUu7Bs8gr3U/w480-h500-k/Asterisk-Logo.PNG

 

http://www.nielsonnetworks.com/images/freepbx-logo.png

 

http://members.optusnet.com.au/bsharif/elastix/CoverElastix.jpg

 

http://www.asteriskguru.com/images/logo.gif

 

 

http://images.tmcnet.com/expo/images/logos/vitelity-logo.jpg

 

 

johnj.jpgAsterisk Tips/Fixes/Features

by John Johnson

These are various Asterisk how-to items I have found/developed over the last few years. Feel free to use or share them, I look forward to adding more as I am able to compile them into a share-able format from my own notes.    

“Experience is what you don’t get until just after you needed it.”

Home

Get email notification when Asterisk reloads or reboots

 

  As you build a population of Asterisk systems in the field it can be important to know when those systems reboot, are power-cycled or when the “safe-asterisk” script finds it necessary to restart Asterisk (without rebooting the server).

 

First things first, make sure your server can successfully send emails out-of-lan (if you don’t already know) by dropping a simple mail command into the linux CLI at the console or via an ssh session using a client such as putty. Test with a command line like this:

 

echo "Test Email" | mail -s "From Asterisk" your_address@your_domain.com

 

You should receive an email with a subject of “From Asterisk” and a body of “Test Email”, if you don’t… then you are off on another quest; configuring your server to send email 

That doesn’t have to be really painful, most Asterisk distributions have either Sendmail or Postfix installed and working and you probably just have to do a little “test-tweak-test-tweak” to get it working. (hint; check the user mailbox for your login to see if the message was refused by your email service due to hostname of your asterisk server, that is the most common hold-up I’ve had).

.

O.K. Now that you know your email out is working open an editor (Midnight Commander, Webmin File Manager, or if all else fails VI) and edit /etc/rc.d/rc.local *see note at bottom

This file is like the “startup folder” in Windows; all the commands in it are run after all other init scripts and it’s an easy place to do your custom add-ons. Put your “mail” command in there so that every time the system boots it emails notice of that event to you.

Add one line for each email address you would like to receive a notification, of course you can send to group email addresses like any other email. Because I have a pretty good population of systems out there I like to specify which one is sending in the subject line (–s) and have it drop the specific server host name in the message body, i.e.

 

hostname | mail -s "Customer-Name" support@mydomain.com

 

Of course, you can pipe just about any command line info to the mail command and have it appear as the message body i.e.

 

df -h | mail -s “Customer disk space report” support@mydomain.com

 

would deliver a report on the systems disk space as the message body.

 

There, you’re all set to get notified when servers boot up, read on to learn how to get email notifications when safe_asterisk reload the service ~without~ the system rebooting.

.

   The safe_asterisk bash script is what actually loads the asterisk service in most Asterisk distributions. It also will reload Asterisk when it encounters errors and unloads/crashes. Additionally safe_asterisk names core dumps to better identify/analyze  problems and it can send email notifications when Asterisk reloads if configured to do it.

To configure safe_asterisk use the file editor of your choice (Midnight Commander, Webmin File Manager, WIN SCP, or if all else fails VI) * see note at bottom

 It’s located at /usr/sbin/safe_asterisk and when you get it open notice the areas I’ve circled in red;

 

You can fill these in to send email notifications to your address and even specify the machine, though I usually leave it send the hostname of the server and add details to the message body itself as in; (I usually just search on “NOTIFY” to find this spot in the file)

 

Note the “mail” command in the above? Just like the one we used in /etc/rc.d/rc.local

 

That’s all there is to it, but when you call your customer to ask if they are having a problem within minutes of them rebooting their system (or having a power outage) they’ll be impressed with how in touch you are, and hey, looking good with customers is always a good thing.

.

*Note: Whenever you are editing a pre-existing file it is really a good idea to first make a copy of the original under a backup name, like adding .old to the original name.  That is unless you never make a typo and would never need to get back to where you were before you started editing… I’m just sayin’.

 

Home