Die Anzahl der aktiven Anrufe\Kanäle in Asterisk - Ausgabe in Datei

Die Anzahl der aktiven Anrufe\Kanäle in Asterisk - Ausgabe in Datei

Manchmal ist es notwendig, zu bestimmen, ob es genügend Kanäle Bodentelefonleitungen, für den Fall, wenn der Operator auf Asterisk verbunden. Um solche Statistiken in unserem Unternehmen zu sammeln, haben wir beschlossen, jede Minute (im Idealfall natürlich öfter) notieren die Anzahl der aktiven Anrufe\Kanäle in Asterisk in die Datei, dann zeichnen, wenn erforderlich.

Es gibt zwei Schritte in der Aufgabe:

  1. Ausgangs benötigten Daten, um im manuellen Modus anmelden.
  2. Setzen Sie das Skript in cron.

Befehl, um die Anzahl der aktiven Anrufe \ Kanäle in Asterisk erhalten (es ist auch Zeit):

root@ast:~# echo `date +"%d/%m/%y %H:%M:%S"` - `/usr/sbin/asterisk -rx "core show channels" | grep "call\|channel"`
11/12/15 12:02:11 - 2 active channels 1 active call 230 calls processed

Speichern Sie diesen Befehl, um .sh-Datei:

root@astspb:~# cat active-calls.sh
#!/bin/bash

echo `date +"%d/%m/%y %H:%M:%S"` - `/usr/sbin/asterisk -rx "core show channels" | grep "call\|channel"` >> /home/user/active-calls.log
root@astspb:~#

Stellen Sie die Datei als ausführbare Datei:

chmod +x active-calls.sh

Jetzt müssen wir diese Datei zu planen. Führen crontab (unter root) und erstellen Sie eine Aufgabe:

sudo crontab -e

Wenn Sie einige Ihrer Lieblingstexteditor benötigen, dies zu tun:

sudo EDITOR=vim crontab -e

Fügen Sie unser Skript in eine Datei und vergessen Sie nicht, leere Zeichenkette am Ende der Datei hinzu:

* * * * * /home/user/active-calls.sh

Überprüfen Sie, ob Aufgabe wurde hinzugefügt:

root@ast:~# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

* * * * * /home/user/active-calls.sh

Das ist es.

linux (de), asterisk (de)

  • Zugriffe: 1886
Kommentar schreiben

Related Articles