Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Building Telephony Systems With Asterisk (2005).pdf
Скачиваний:
45
Добавлен:
17.08.2013
Размер:
1.82 Mб
Скачать

Maintenance and Security

We could also restart the Asterisk service nightly in order to resolve any hung channels; this may not be possible if the system sees high usage during the night, but is useful in situations where we have channels hanging often.

Finally, asterisk_restart.cron:

#!/bin/bash /etc/init.d/asterisk stop /etc/init.d/zaptel restart /etc/init.d/asterisk start

Time Synchronization

As our Asterisk system retains logs of calls and also makes routing decisions based on time, it is important to have the system clock synchronized. We can do this with Network Time Protocol (NTP). This is very easy to use. Just install the ntpdate program, which you will most likely find in your distribution's package management system (yum, urpmi, apt, or whatever). Then run the script shown below. If we have a local time server (for instance if we have other time-dependent services such as Kerberos authentication installed), we should use that.

The timesync.cron NTP script:

#!/bin/bash

ntpdate pool.ntp.org # replace pool.ntp.org with local time server /sbin/hwclock –-systohc # sync the hardware clock

Adding It All to cron

The four files we have created can be added to our crontab to ensure they are run periodically. We can do this by first running:

$ crontab –e

Then creating the following entries (replacing /path/to with the location of our scripts):

30

01

* * *

 

/path/to/backup.cron

59

23

* *

*

 

/path/to/monitor_mix.cron

00

01

* *

*

 

/path/to/asterisk_restart.cron

00,15,30,45

* * * *

/path/to/timesync.cron

This ensures that our backup.cron, monitor_mix.cron, and asterisk_restart.cron scripts are run nightly and that our time is synchronized every 15 minutes.

As we are running these commands non-interactively, i.e. we are using scp in batch mode, we must ensure that the scp command can authenticate with the backup server. To do this we should use SSH keys instead of passwords for authentication by running the following commands:

$ ssh-keygen -t dsa ; accept all defaults by pressing enter at each

;prompt

$ ssh username@backupserver 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_dsa.pub ; enter password when prompted

142