Saturday, October 17, 2009

MySQL Change root Password

Setting up mysql password is one of the essential tasks. By default root user is MySQL admin account. Please note that the Linux / UNIX login root account for your operating system and MySQL root are different. They are separate and nothing to do with each other (indeed some admin removes root account and setup admin as mysql super user)

mysqladmin command to change root password

If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

$ mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use following command

$ mysqladmin -u root -p'oldpassword' password newpass

For example, If old password is abc, and set new password to 123456, enter:

$ mysqladmin -u root -p'abc' password '123456'

Change MySQL password for other user

To change a normal user password you need to type (let us assume you would like to change password for vivek):

$ mysqladmin -u vivek -p oldpassword password newpass

Changing MySQL root user password using MySQL sql command

This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:

1) Login to mysql server, type following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user dip

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='dip';

4) Reload privileges:

mysql> flush privileges;
mysql> quit

This method you need to use while using PHP or Perl scripting.

Install and Configure phpMyAdmin on Ubuntu LAMP


PhpMyAdmin is a nice database management and administration tool, it is easy to install it, but some people are having problems making it work under apache, that’s because it needs configuration. I presume you already have LAMP installed and configured on your machine, if not, please read this post – Install and Configure LAMP on Ubuntu first.

Just in case you haven’t installed phpMyAdmin yet, type the following line in the Terminal:
apt-get install phpmyadmin

To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf, first type the following command to open up this file:
nano /etc/apache2/apache2.conf

Add the following line of code inside apache2.conf:
Include /etc/phpmyadmin/apache.conf

Now restart Apache:
sudo /etc/init.d/apache2 restart

Point your browser to: http://domain/phpmyadmin, you should be able to see the phpMyAdmin landing page now!

Tuesday, October 13, 2009

New Threat to Voip Industry - SPIT

VoIP Spam Is Called SPIT


As if an inbox jam-packed with email ads for organ-enlargement and weight-loss products was not bad enough, now VoIP users can look forward to becoming a brand-new target. Slowly but surely, spammers are adding SPIT (SPam over Internet Telephony) to their bags of tricks. Warned Terrence Brewton, a Frost & Sullivan market analyst, “SPIT is an evolving threat that will come on par with the prevalence of spam, all because of the VoIP products we’re now seeing in homes and the commercial marketplace.”


More than simply an annoyance, SPIT’s real-time impact on a network “ ... creates business risks because it opens up companies to denial-of-service attacks like any other IP-based system,” said Brewton. What’s more, SPIT can consume bandwidth, thereby diminishing call quality and reducing employee productivity.

While it’s true that SPIT is still quite rare, VoIP’s growing popularity is certain to make its presence more widespread. Fortunately, there are steps that companies can take to combat SPIT.

Filtering: According to Brewton, “The best course of action for any IT manager who is trying to protect his VoIP system is to buy filtering technology and keep up with patch management.” But while VoIP providers can help filter out obvious SPIT before it traverses a network, there is always a risk of false positives — legitimate traffic or large-scale message transmissions that are accidentally flagged as SPIT and prevented from reaching employees.

Firewalls: A VoIP firewall is an application driven by a security policy that defines whether to allow or deny certain calls. Administrators set policies through GUIs similar to those found in traditional data firewalls. A first line of defense against numerous threats, this technology detects and blocks VoIP DoS (denial-of-service) attacks, SIP attacks, toll fraud, virus infections and SPIT.

VoIP SEAL: NEC Corp.’s VoIP SEAL is a new tool that targets calls originating from spam-generating software and ill-intentioned humans. SPIT is detected and blocked based on communication patterns observed during the call. If a spam-related call comes in, VoIP SEAL will prevent the phone from ringing.

Voice Recognition: Microsoft has developed V-Priorities, a system for automatically screening phone calls. The technology works by analyzing characteristics of a caller's voice and word usage to figure out how urgent a call is and whether the caller is a friend, a family member, a colleague or a stranger.

Although the aforementioned security options are effective SPIT countermeasures, they also present drawbacks. “Any time you try to run any type of packet through any kind of filter, it’s going to slow down network processes. That’s because VoIP is a very sensitive piece of technology,” said Brewton. Such latency issues can lead to reduced quality of service and customer frustration.

Nor is there a panacea for SPIT. Even the brightest and best-prepared IT managers can be a step behind hackers. Said Brewton, “Everything changes at the speed of light on the Internet. Spammers are changing their tactics constantly because they’re trying to make money like anybody else. So by the time you’ve figured out what they’re doing, they’ve gone on to the next attack. That’s the one thing people really have to remember about security; we’re always fighting yesterday’s attack.”

Further complicating matters is the fact that the savings accrued through a VoIP network can be somewhat offset by having to invest in the appropriate security technologies. In the end, said Brewton, companies need to weigh what they stand to gain — and possibly lose to SPIT — by deploying a VoIP network. “With any technology,” said Brewton, “you really need to take pause and ask yourself, ‘Do I really need to deploy this? Is this going to be cost-effective? What is going to be my total cost of ownership for purchasing such a new technology?’”


www.astnext.com is dealing in Anti SPIT solutions to tackle this

Monday, September 7, 2009

Train yourself on Asterisk

Thanks everyone for your overwhelming support

I would like to take this blog to a next level, where i will
post interesting engineering applications on asterisk

So Need to fund for the project, henceforth i am starting
to train the people so that they also be a part of my
blog

Please email me at dipkumar.mehta@gmail.com and
book your slots

15 $ per hour for Asterisk Training

Ask your doubts or whatever little queries you have.

Friday, September 4, 2009

ISDN Alarms indications in zaptel/Dahdi

The TE200 series user manual contains only a description of LEDs states.

These alarmsstates are visible in zttool/dahditool or in astersick CLI (zap show status)

You have three different general alarm states:

Red alarm
---
Your T1/E1 port will go into red alarm when it maintain
synchronization with the remote switch. A red alarm
typically indicates either aphysical wiring problem,
loss of connectivity, or a framing and/or line-coding
mismatch with the remote switch. When your T1/E1 port
loses sync, it will transmit a yellow alarm to the remote
switch to indicatethat it's having a problem receiving
signal from the remore switch.(The easy way to remember
this is that the R in red stands for "right here" and "receive".
.. indicating that we're having a problem right here
receiving the signal from the remote switch.)

Yellow alarm or RAI (Remote Alarm Indication)
---
Your T1/E1 port will go into yellow alarm when it receives a
signal from the remote switch that the port on that remote
switch is in red alarm.This essentially means that the remote
switch is not able to maintain sync with you, or is not receiving
your transmission. (The easy way to remember this is that t
he Y in yellow stands for "yonder"... indicating that the
remote switch (over yonder) isn't able to see what you're
sending.)

Blue alarm or AIS (Alarm Indication Signal)
---
Your T1/E1 port will go into blue alarm when it receives all
unframed 1s on all timeslots from the remote switch. This is
a special signal to indicate that the remote switch is
having problems with it's upstream connection.


Please contact me at
dipkumar.mehta@gmail.com if you need any help regarding isdn troubleshooting issues

Sunday, August 30, 2009

G.729 and G.723 Codec installation on Asterisk

Installation and Configuration of G.729 and G.723 codecs on asterisk
  1. Download the codec binary file from http://asterisk.hosting.lv/bin/codec_g729-ast14-gcc4-glibc-pentium4.so
  2. Copy it to the /usr/lib/asterisk/modules folder.
  3. Restart the Asterisk: /etc/init.d/asterisk restart

Estimating the Number of G.729 Channels Required

If you choose to purchase the G.729 license from Digium you will need to compute the number of G.729 channels required by your configuration. You can estimate the required value by using the following information:

  • a call between two SIP extensions usually requires two G.729 channels, unless the pass-thru mode is used (http://voip-info.org/wiki/view/Asterisk+G.729+pass-thru), in which case it doesn’t require any G.729 channel.
  • a call between a SIP extension and a Zaptel/DAHDI extension/trunk requires one G.729 channel.
  • a call to Voice Mail or another Asterisk service where IVR messages must be played requires one G.729 channel.

SIP Trunking - IP Based authentication and Password based authentication

SIP trunking is the method of sending calls to ITSP service provider using sip protocol.

Indepth details refer RFC 3261

There are two types of authentications

1. IP based authentication
2.Username and Password based authentication


For IP Based Authentication

You need to do the following changes in the sip.conf


[siptrunk]
type=friend
fromuser=X.X.X.X ( your asterisk server ip ) which will send traffic to the service provider
host=X.X.X.X ( service provider ip )
canreinvite=no
qualify=no
dtmfmode=RFC2833
context=intenal
disallow=all
allow=g729
allow=ulaw
allow=alaw
port=5060


Then you need to edit extensions.conf
[intenal]
exten => _9X.,1,Dial(SIP/${EXTEN}@siptrunk)


For Username and password based authentication

[siptrunk]
type=friend
username=
fromuser=X.X.X.X
host=X.X.X.X
canreinvite=no
secret=
qualify=no
dtmfmode=RFC2833
context=intenal
disallow=all
allow=g729
allow=ulaw
allow=alaw
port=5060

define username and password to it





Wednesday, July 8, 2009

How to read DTMF and store in the database in Asterisk

Aim :

To Read a variable in the form for DTMF tones as pressed by the caller.

For example if you would like your users to call up the system and record there inputs in the database and then make use of Asterisk to perform what ever tasks with those recorded inputs.

Syntax :

Read(variable[,filename][,maxdigits][,option][,attempts][,timeout])

Reads a #-terminated string o
f digits a certain number of times from the user in to the given variable.
  • variable: variable where the user's response will be stored.
  • filename: file to play before reading digits.
  • maxdigits: maximum acceptable number of digits. Stops reading after maxdigits have been entered (without requiring the user press the '#' key). Defaults to 0 - no limit - wait for the user press the '#' key. Any value below 0 means the same. Max accepted value is 255.
  • option: may be 'skip' to return immediately if the line is not up, or 'noanswer' to read digits even if the line is not up.
  • attempts: if greater than 1, that many attempts will be made in the event no data is entered.
  • timeout: Timeout in seconds. If greater than 0, that value will override the default timeout.

Read should disconnect if the function fails or errors out.

[edit]

Example

; The Following Example uses Read and Say digits to read 3 digits from user, saying each one as user types.

Asterisk 1.2:
exten => s,1,Gotoif($[ "${LEN(${extensao})}" < "3"]?3:100)
exten => s,n,NoOp(Executing - ${extensao} - )
exten => s,n,Read(digito||1)
exten => s,n,SayDigits(${digito})
exten => s,n,Set(extensao=${extensao}${digito})
exten => s,n,GoTo(s,1)
exten => s,100,GoTo(from-pstn,s,1)
exten => h,1,hangup()

Asterisk 1.4, 1.6:
exten => s,1(start),Gotoif($[ "${LEN(${extensao})}" < "3"]?collect:pstn)
exten => s,n,NoOp(Executing - ${extensao} - )
exten => s,n(collect),Read(digito,,1)
exten => s,n,SayDigits(${digito})
exten => s,n,Set(extensao=${extensao}${digito})
exten => s,n,GoTo(start)
exten => s,n(pstn),GoTo(from-pstn,s,1)
exten => h,1,hangup()


[edit]

Notes

Pipe characters ( | ) have been changed to commas in Asterisk 1.6.
In Asterisk 1.4, either pipes OR commas will work. Using commas will ease future upgrades.

'#' is the End-Of-Input Key. It is NOT possible to accept '#' with Read()

Warning:
In Asterisk 1.4: the "filename" field does not accept concatenation (file1&file2&file...).

Tuesday, July 7, 2009

Configuring a queue

The following queue works as following:

star all calls are monitored, i.e. saved to disk
star if after 60 seconds on the queue the call is unanswered, the call is routed to voicemail
star there are two levels of agents: agents 302 and 303 will answer the queue (level 1); only if none of them is available the call is routed to agent 301 (level 2). If nobody is available, the queue keeps trying until timeout is reached.

Extensions.conf

[q-my-sample]
; ...queue description.....
exten =>
s,1,SetVar(MONITOR_FILENAME=/var/spool/asterisk/queuecalls/QSAMPLE-${
UNIQUEID})
exten => s,2,Queue(q-sample|n|||)
exten => s,3,Playback(voicemail-invitation)
exten => s,4,VoiceMail,s2001

Queues.conf

[q-sample]
music = default
announce = q-sample-announce
strategy = roundrobin
timeout = 60
retry = 5
maxlen = 0
announce-frequency = 0
announce-holdtime = no
monitor-format = wav
monitor-join = yes
queue-youarenext = silence
queue-thankyou = q-sample-thankyou
member=>Agent/302,0
member=>Agent/303,0
member=>Agent/301,1

Understanding queue logic in Asterisk

When a call enters the queue application, there are many possible scenarios, that are controlled by the queue's own timeout and the ringing timeout.

If a timeout is specified on the queue command itself, that is the maximum queue wait length (we call this queue timeout). It is the maximum time that a caller can wait on hold on the queue. If that time is expired, then the caller is moved on to the next step in the dialplan. If no timeout is specified, we assume it to be the default value, i.e. 300 seconds (5 minutes).

There is then another timeout specified in the queue definition itself, that is the ringing timeout. This is the queue "loop time", i.e. the timeout over which events in the queue are rotated. If the queue finds a free member, it tries to ring it for the given period of time. If it finds no free members, it retries finding a new member when this time period expires. In any case, the global queue timeout is triggered only when this timer expires, so if this timeout is very long, your queue timeouts may be longer than expected. If a member is busy or unavailable (e.g. an extension that is not working) it is skipped as soon as the condition is detected and the next available agent is rung.

If the option "n" is passed to the queue command, there are no retries, i.e. when the retry period expires, the queue is terminated no matter what.

It is possible to add a wait time after an extension is ringed unsuccessfully and the next one is ringed; this parameter id the retry parameter in the queue definition.

When the ringing timeout expires, all queue events are processed, not only the global queue timeout; if an announce is set and the time from the last announce has elapsed, then the announce is played. While the announce is being played, no new agent is being called; this might be a minor problem if your queue-thankyou message is very short, but if it is quite long and quite frequent, you may find an undue slowdown on your agents being searched.

As a summary, we can say that:
star Your ringing timeout should ideally be quite short (10-15 seconds)
star Announce frequencies and the overall queue timeout should be comparatively much longer than the ringing timeout, and are triggered on a schedule driven by the ringing timeout
star The time taken to play announces is added between each ringing timeout cycle, so if it is very long, you may find that your agents sit idle while callers listen to the announcement.

Compressing recorded calls to MP3

If you record a big chunk of traffic (or even all traffic, as some call-centers do) on your Asterisk box, you will see that it ends up taking a substantial amount of disk space. The problem is the following:
star Recording wav files is very good in terms of CPU usage, but those files end up being huge
star Transcoding to GSM files still takes up substantial disk space and is much heavier on the CPU
The ideal would be saving those files in some very-compressed MP3 format, but this is not a very good idea as the hit on the CPU is quite dramatic.
Still, most systems do not operate on a 24/7 basis; if your call center gets a lot of traffic during office hours, it's just as well likely that it will be sitting idle all night.

Therefore, it would be nice if we could:
star Record all calls using the cheapest recording format
star Transform all calls to some very compressed format at night, when the CPU is sitting idle


his way, if you listen to a call that's just been recorded, you will download a large wav file; if you listen to a call that has been recorded two days ago, you will download a highly-compressed MP3 file.

For example, take the standard agent-101 recording file that is distribuited with Asterisk; its size is:

+--------------+----------------+
| wav file | 1310764 bytes |
| gsm file | 135168 bytes |
| mp3 file 16k | 164520 bytes |
| mp3 file 12k | 120528 bytes |
| mp3 file 8k | 83808 bytes |
+--------------+----------------+

The mp3 file is compressed as 16kbps/mono and sounds pretty good, likely better that the gsm file. The mp3 compressed at 8kbps/mono sounds a bit compressed, but it stays intellegible.

Enconding wav files into MP3
To encode wav files into mp3, we create a make file. Make is the right tool for the job, as it is built to transform one file into a different file, by name.

So we edit a file called Makefile (yes, with the capital M) into our main storage directory, usually /var/spool/asterisk/monitor:

DIRWAV = $(shell dir *.wav)
ALLWAV = $(DIRWAV:.wav=.mp3)
DIRGSM = $(shell dir *.gsm)
ALLGSM = $(DIRGSM:.gsm=.mp3)
mp3: $(ALLWAV) $(ALLGSM)
%.mp3: %.wav
nice lame --quiet --preset phone $? $@
rm -f $?
%.wav: %.gsm
nice sox $? -r 8000 -c 1 -w -s $@
rm -f $?
clean:
rm -f *.mp3
rm -f *.wav
rm -f *.raw
rm -f *.gsm
cp /var/lib/asterisk/mohmp3/*.wav .
cp /var/lib/asterisk/sounds/a*.gsm .

(You can omit the clean section we used for testing).

Leave a few blank lines after each target.

Make sure you have sox and lame installed on your machine.

Then at night you run a job like:

cd /var/spool/asterisk/monitor; make mp3

At night, this makefile will search all wav (or gsm) files and convert them into mp3, deleting the original files.

Choosing 16k, 12k or 8k compression
In order to fine-tune the mp3 encoding to your preferred size, you can change the parameter after --preset to:

star --preset phone -> 16kbps/mono, high quality
star --preset 12 -> 12kbps/mono, normal quality
star --preset 8 -> 8 kbps/mono, low quality

If your system is not over-loaded, you may also want to pass the '-h' parameter to turn on high-quality (but slower) mp3 encoding.

Recording of Extensions for Outgoing calls

You want to record all outgoing traffic done by some extensions - not all extensions (it would be trivial) but just some of your choosing. You also want to be able to turn recordings on or off without modifying the dialplan.

How to do it
We will use Asterisk's internal database to record a flag for each extension that tells us whether to record those calls or not. We add a check for this flag before dialling out, so we can catch all outgoing traffic.

Modifying the dialplan
Whenever you are currently dialing out (we assume that any number starting with 0 is an external call) you add the following piece of dialplan:

exten => _0.,1,NoOP,Dial out with hidden CLID
exten => _0.,2,SetCallerPres(prohib)
exten => _0.,3,DBGet(rec=registra/${CALLERIDNUM})
exten => _0.,4,GotoIf($[ ${rec} = 1 ]?10:20)
exten => _0.,10,MixMonitor(REC-${CALLERIDNUM}-${UNIQUEID}.wav|b|)
exten => _0.,11,Goto(20)
exten => _0.,20,Dial(Zap/g1/${EXTEN:1})

Deciding which extensions will be recorded
Once your piece of dialplan is in place, you use the following command from the Asterisk CLI to tell Asterisk an extension is to be recorded:

database put registra 299 1

While you use the following to tell Asterisk an extension is not to be recorded anymore:

database put registra 299 0

If you want to know the status of your recorded extension, you type:

ast*CLI> database show registra
/registra/223 : 1
/registra/224 : 0
/registra/299 : 1

Any key that has value of 1 will be recorded; any other key (whether it has value 0 or does not exist) is not recorded.

Finding recorded calls
You can find the recorded calls by issuing the following command:

[root@ast monitor]# ls -l /var/spool/asterisk/monitor/REC*
-rw-r--r-- 1 root root 186284 Jun 9 15:36 /var/spool/asterisk/monitor/REC-299-1186583777.73726.wav
-rw-r--r-- 1 root root 206764 Jun 9 15:40 /var/spool/asterisk/monitor/REC-299-1186584038.73774.wav

And you can listen to them by copying them over to any audio software.



Saturday, June 20, 2009

How do I Find Out Linux CPU Utilization?

Whenever a Linux system CPU is occupied by a process, it is unavailable for processing other requests. Rest of pending requests must wait till CPU is free. This becomes a bottleneck in the system. Following command will help you to identify CPU utilization, so that you can troubleshoot CPU related performance problems.

Finding CPU utilization is one of the important tasks. Linux comes with various utilities to report CPU utilization. With these commands, you will be able to find out:

* CPU utilization
* Display the utilization of each CPU individually (SMP cpu)
* Find out your system's average CPU utilization since the last reboot etc
* Determine which process is eating the CPU(s)

top - display top CPU processes

SYNOPSIS

top [-] [d delay] [p pid] [q] [c] [C] [S] [s] [i] [n iter] [b]

DESCRIPTION

top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can sort the tasks by CPU usage, memory usage and runtime. can be better configured than the standard top from the procps suite. Most features can either be selected by an interactive command or by specifying the feature in the personal or system-wide configuration file. See below for more information.

COMMAND-LINE OPTIONS

-d
Specifies the delay between screen updates. You can change this with the sinteractive command.
-p
Monitor only processes with given process id. This flag can be given up to twenty times. This option is neither available interactively nor can it be put into the configuration file.

q
This causes top to refresh without any delay. If the caller has superuser privileges, top runs with the highest possible priority.
-S
Specifies cumulative mode, where each process is listed with the CPU time that it as well as its dead children has spent. This is like the -S flag to ps(1). See the discussion below of the S interactive command.
-s
Tells top to run in secure mode. This disables the potentially dangerous of the interactive commands (see below). A secure top is a nifty thing to leave running on a spare terminal.
-i
Start top ignoring any idle or zombie processes. See the interactive command i below.
-C
display total CPU states instead of individual CPUs. This option only affects SMP systems.
-c
display command line instead of the command name only. The default behavior has been changed as this seems to be more useful.
-H
Show all threads.
-n
Number of iterations. Update the display this number of times and then exit.
-b
Batch mode. Useful for sending output from top to other programs or to a file. In this mode, top will not accept command line input. It runs until it produces the number of iterations requested with the n option or until killed. Output is plain text suitable for display on a dumb terminal.

FIELD DESCRIPTIONS

top displays a variety of information about the processor state. The display is updated every 5 seconds by default, but you can change that with the d command-line option or thes interactive command.
"uptime"
This line displays the time the system has been up, and the three load averages for the system. The load averages are the average number of process ready to run during the last 1, 5 and 15 minutes. This line is just like the output of uptime(1). The uptime display may be toggled by the interactive l command.
processes
The total number of processes running at the time of the last update. This is also broken down into the number of tasks which are running, sleeping, stopped, or undead. The processes and states display may be toggled by the t interactive command.
"CPU states"
Shows the percentage of CPU time in user mode, system mode, niced tasks, iowait and idle. (Niced tasks are only those whose nice value is positive.) Time spent in niced tasks will also be counted in system and user time, so the total will be more than 100%. The processes and states display may be toggled by the t interactive command.
Mem
Statistics on memory usage, including total available memory, free memory, used memory, shared memory, and memory used for buffers. The display of memory information may be toggled by the m interactive command.
Swap
Statistics on swap space, including total swap space, available swap space, and used swap space. This and Mem are just like the output of free(1).
PID
The process ID of each task.
PPID
The parent process ID each task.
UID
The user ID of the task's owner.
USER
The user name of the task's owner.
PRI
The priority of the task.
NI
The nice value of the task. Negative nice values are higher priority.
SIZE
The size of the task's code plus data plus stack space, in kilobytes, is shown here.
TSIZE
The code size of the task. This gives strange values for kernel processes and is broken for ELF processes.
DSIZE
Data + Stack size. This is broken for ELF processes.
TRS
Text resident size.
SWAP
Size of the swapped out part of the task.
D
Size of pages marked dirty.
LC
Last used processor. (That this changes from time to time is not a bug; Linux intentionally uses weak affinity. Also notice that the very act of running top may break weak affinity and cause more processes to change current CPU more often because of the extra demand for CPU time.)
RSS
The total amount of physical memory used by the task, in kilobytes, is shown here. For ELF processes used library pages are counted here, for a.out processes not.
SHARE
The amount of shared memory used by the task is shown in this column.
STAT
The state of the task is shown here. The state is either S for sleeping, D for uninterruptible sleep, R for running, Z for zombies, or T for stopped or traced. These states are modified by trailing < for a process with negative nice value, N for a process with positive nice value, W for a swapped out process (this does not work correctly for kernel processes).
WCHAN
depending on the availability of either /boot/psdatabase or the kernel link map/boot/System.map this shows the address or the name of the kernel function the task currently is sleeping in.
TIME
Total CPU time the task has used since it started. If cumulative mode is on, this also includes the CPU time used by the process's children which have died. You can set cumulative mode with the S command line option or toggle it with the interactive command S. The header line will then be changed to CTIME.
%CPU
The task's share of the CPU time since the last screen update, expressed as a percentage of total CPU time per processor.
%MEM
The task's share of the physical memory.
COMMAND
The task's command name, which will be truncated if it is too long to be displayed on one line. Tasks in memory will have a full command line, but swapped-out tasks will only have the name of the program in parentheses (for example, "(getty)").
"A , WP"
these fields from the kmem top are not supported.

INTERACTIVE COMMANDS

Several single-key commands are recognized while top is running. Some are disabled if thes option has been given on the command line.
space
Immediately updates the display.
^L
Erases and redraws the screen.
h or ?
Displays a help screen giving a brief summary of commands, and the status of secure and cumulative modes.
k
Kill a process. You will be prompted for the PID of the task, and the signal to send to it. For a normal kill, send signal 15. For a sure, but rather abrupt, kill, send signal 9. The default signal, as with kill(1), is 15, SIGTERM. This command is not available in secure mode.
i
Ignore idle and zombie processes. This is a toggle switch.
I
Toggle between Solaris (CPU percentage divided by total number of CPUs) and Irix (CPU percentage calculated solely by amount of time) views. This is a toggle switch that affects only SMP systems.
n or #
Change the number of processes to show. You will be prompted to enter the number. This overrides automatic determination of the number of processes to show, which is based on window size measurement. If 0 is specified, then top will show as many processes as will fit on the screen; this is the default.
q
Quit.
r
Re-nice a process. You will be prompted for the PID of the task, and the value to nice it to. Entering a positve value will cause a process to be niced to negative values, and lose priority. If root is running top, a negative value can be entered, causing a process to get a higher than normal priority. The default renice value is 10. This command is not available in secure mode.
S
This toggles cumulative mode, the equivalent of ps -S, i.e., that CPU times will include a process's defunct children. For some programs, such as compilers, which work by forking into many separate tasks, normal mode will make them appear less demanding than they actually are. For others, however, such as shells and init, this behavior is correct. In any case, try cumulative mode for an alternative view of CPU use.
s
Change the delay between updates. You will be prompted to enter the delay time, in seconds, between updates. Fractional values are recognized down to microseconds. Entering 0 causes continuous updates. The default value is 5 seconds. Note that low values cause nearly unreadably fast displays, and greatly raise the load. This command is not available in secure mode.
f or F
Add fields to display or remove fields from the display. See below for more information.
o or O
Change order of displayed fields. See below for more information.
l
toggle display of load average and uptime information.
m
toggle display of memory information.
t
toggle display of processes and CPU states information.
c
toggle display of command name or full command line.
N
sort tasks by pid (numerically).
A
sort tasks by age (newest first).
P
sort tasks by CPU usage (default).
M
sort tasks by resident memory usage.
T
sort tasks by time / cumulative time.
W
Write current setup to ~/.toprc. This is the recommended way to write a top configuration file.

The Field and Order Screens

After pressing f, F, o or O you will be shown a screen specifying the field order on the top line and short descriptions of the field contents. The field order string uses the following syntax: If the letter in the filed string corresponding to a field is upper case, the field will be displayed. This is furthermore indicated by an asterisk in front of the field description. The order of the fields corresponds to the order of the letters in the string.
From the field select screen you can toggle the display of a field by pressing the corresponding letter.
From the order screen you may move a field to the left by pressing the corresponding upper case letter resp. to the right by pressing the lower case one.

Configuration Files

The command top reads it's default configuration from two files, /etc/toprc and ~/.toprc. The global configuration file may be used to restrict the usage of top to the secure mode for non-non-privileged users. If this is desired, the file should contain a 's' to specify secure mode and a digit d (2<=d<=9) for the default delay (in seconds) on a single line. The personal configuration file contains two lines. The first line contains lower and upper letters to specify which fields in what order are to be displayed. The letters correspond to the letters in the Fields or Order screens from top. As this is not very instructive, it is recommended to select fields and order in a running top process and to save this using theW interactive command.

The second line is more interesting (and important). It contains information on the other options. Most important, if you have saved a configuration in secure mode, you will not get an insecure top without removing the lower 's' from the second line of your ~/.toprc.

A digit specifies the delay time between updates, a capital 'S' cumulative mode, a lower 'i' no-idle mode, a capital 'I' Irix view. As in interactive mode, a lower 'm', 'l', and 't' suppresses the display of memory, uptime resp. process and CPU state information. Currently changing the default sorting order (by CPU usage) is not supported.



Saturday, May 16, 2009

adsi.conf

This is the Analog Display Services Interface Configuration file for Asterisk. (Not to be mistaken with DISA, which is something completely unrelated).


1.1. Introduction to ADSI:

The file is located in the /etc/asterisk/ directory.

ADSI (Analog Display Services Interface) is a protocol for enabling alternate voice and data services over the analog telephone network, such as sending data to a display at the ADSI phone

It also allow for running simple interactive scripts on the ADSI phone, such as Call Waiting Deluxe, an application that displays the name and number of an incoming call while you are on the phone.
Not only will the phone display the number, it will also ask you what to do with it, including switching to the new call, forwarding the new call to your voice mail, putting the new caller on hold, playing a recorded message, or dropping the current call and switching to the new call.

Other ADSI applications include:

- Visual voice mail: the display of telephone voice mail menu options and a list of your voice mail messages
- Visual directory: a service that allows you to locate the telephone number of an individual or business and, possibly at extra charge, to download the address of that individual to your screen phone
- E-mail browsing: allowing you to send and receive e-mail messages via an ADSI-enabled device.
- Schedule-based services: faxing abilities, notification of incoming e-mail messages, home banking, ticket purchasing, and access to train and plane schedules.


1.2. Prequisites

- Asterisk
- a configured TDM card, fxo card or combination of channel bank and E1/T1 card.
- ADSI Capable phone



1.3. ADSI capable phones:

- Sayson/Aastra 390/480e
Cybiolink P-1 ADSI analog phone
- Nortel Vista 350/380

- Lucent Technologies' ADSI SpeakerPhone 980
- CybioTronics CY-2135-BH CybioLink

- Fanstel ST2112

(If you know more, please leave a comment and we will add them).

1.4. Configuration of asterisk for ADSI

Saddly, we don't have an ADSI phone in our lab, so all the information here is gathered on the internet and untested.

The main ADSI configuration file is called ADSI.conf, a sample ADSI script is included in the asterisk sources as asterisk.adsi.

To use ADSI, you need to enable ADSI on this specific zaptel line.
(So first you will need to read up on how to configure zaptel for your card and then enable ADSI on the channel your phone is connected to by adding the line adsi=yes to the configuration for this channel in zapata.conf.

; ADSI (Analog Display Services Interface) can be enabled on a per-channel
; basis if you have (or may have) ADSI compatible CPE equipment
;
;adsi=yes



I don't think you need to touch anything in adsi.conf, the sample configuration file looks as the snippet below:

;
; Sample ADSI Configuration file
;
[intro]
alignment = center; alignment on the screen, valid values are: l(eft), r(ight) i(indent?). All others are recognized as centered.
greeting => Welcome to the ; Some greeting, don't know when its shown on the phone
greeting => Asterisk
greeting => Open Source PBX
maxretries = 3 ; number of times to retry sending to the ADSI phone
[speeddial]
--please look at res_adsi.c

For the speeddial option, you will need to look at the res_adsi.c source code, i suppose its name,number or number,name.


1.5. ADSI scripts

Asterisk comes with two ADSI scripts included,
asterisk.adsi
telcordia-1.adsi

These scripts need to run on the phone, asterisk can upload them to the phone for you.
To do so, you will need to create a specific extension, which will call the ADSIProg application. When you call this extension with your phone, asterisk will upload the script to the phone.

exten => 1234,1,ADSIProg(telcordia-1.adsi);
exten => 1234,2,Hangup;


If no parameter is giving to ADSIProg, it will upload the default script, asterisk.adsi.

Before you upload any scripts, you might need to alter them and change two values for you specific phone:

SECURITY 0X9BDBF7AC ; Security code
FDN 0x0000000F ; Descriptor number


For a list with codes, have a look here

If your phone has multiple slots, you can upload one script per slot. (each slot will have a different FDN).


1.6. Other ADSI related features

1.6.1.: Voicemail

The comedian mail has some support for ADSI, if you want to use this with your phone, you will need to alter the codes again, but this time in the sources for comedian mail.
static char *adapp = "CoMa"; --> this value is the FDN as seen before
static char *adsec = "_AST"; --> this value is the security code as above.

This means that if you change the brand of phone, you will need to alter this again and recompile. And you probably will be unable to use different brands of phones at the same time.


1.6.2.: Send text to an ADSI phone

If you have a look at this google cache, you will find an application to send messages to your ADSI phone from the asterisk dialplan.


1.6.3.: Call Parking

Asterisk can send some information to your ADSI phone when you park a call, to enable this, edit features.conf and type the line adsipark = yes




See also:
- ADSIProg
- zapata.conf



References:

ADSI definition on techtarget.com
ADSI questions for a 390 ADSI Phone - part 1
ADSI questions for a 390 ADSI Phone - part 2
some more info on ADSI
ADSI FAQ
Another mail archive
ADSI unlock codes
Application to send text to the ADSI Phone
ADSI programming guide - WebSphere Voice Response for AIX V3.1 Programming for the ADSI feature
thread with some more info on locking codes

extensions.conf

extensions.conf - this is the configuration file, where have to make your dial plans

The extensions.conf file is one of the most used and most important configuration file in Asterisk PBX - it contains the dialplan. What is a dialplan? The dialplan , or we can say "the heart of the Asterisk System", defines how Asterisk PBX will handle incoming and outgoing calls, it also contains all extension numbers. The dialplan is divided in sections called contexts. Every context consists from more than one extensions. What is an extension? The extension is the telephone number, it can be numbers, letters or both. Every extension has a priority and an application. With the help of contexts we can organize our dialplan.

In general a dialplan looks like this:

[general]
--> some settings go here

[globals]
--> definition of some global variables go here

[context1]
-->extension 1, priority 1, application
-->extension 1, priority 2, application

--> extension helpdesk, priority 1, application
...
[context2]
--> extension 999, priority 1, application
--> extension 999, priority 1, application



2. Contexts

2.1 [general]

The first context in the extensions.conf file is [general], 3 configuration options can be set here:
static= yes | no - For now only the option yes is implemented, (so setting it to no won't have any effect) and if static=yes and writeprotect=no , then you can save dialplan from the CLI command 'save dialplan'.

More on this in the (upcoming) tutorial on the CLI commands. (The CLI is the interactive asterisk shell, where you could a.o. change your dialplan and save it without altering the extensions.conf file.)

writeprotect = yes | no - This option is require if you want to have ability to save dialplan changes from the CLI command.
autofallthrough=yes|no - If this option is set, after finishing with things to do, Asterisk will hang up the call. If not set, Asterisk will wait for another extension to be dialed. It is highly recommended this option to be set to yes.


2.2 [globals]

In context [globals] you can specify your own variables,
that can be used later in extensions. Note that a global variable
name is not case sensitive, so ${MYVAR} and ${mYvaR} are the same.
The way to write global variable in section [globals] is:

The_name_of_my_variable => The_variable's_value


Example:

[general]
static=yes
writeprotect=no

[globals]
MyMusicOnHold => /mp3/Mozart.mp3


2.3 "Real" call contexts

With the exception of [general] and [globals] everything else is consider as call contexts. The basic look of contexts is:

[context_name]
exten => some_exten_number,priority,application(arg1,arg2,...)
exten => some_exten_number,priority,application,arg1|arg2...
exten => some_pattern,priority,application(arg1,arg2,...)


But what is the purpose of the 'context' ? Inside a context, you could build an IVR menus (Interactive Voice Response) using extensions, you could define a specific context for every department of you company (Accounting, Support, etc)

Using different contexts, the Accounting team would call to their supervisor john when hitting 123, and the support team would call head of support 'alice' when pressing 123.

The support team might be able to do outgoing calls, but the account team could be restricted to only internal calls.

Or incoming calls from clients could be all sent to a waiting Queue, while internal calls between collegues will go straight to the collegue without queing.

So with the help of the contexts it's very easy to manage all assigned telephone numbers.

Example:
[general]
; ...skip...

[globals]
; ...skip...


[Helpdesk]
exten => 323206,1,Dial(SIP/Helpdesk_agent01)
; ...skip...

[Accounting]
exten => 443307,1,Dial(IAX2/Accounting_agent01)
; ...skip...


IVR menu example:

[default]
exten => steve,1,Dial(SIP/steve);
exten => mark,2,Dial(SIP/mark);

[mainmenu]
exten => s,1,Answer
exten => s,n,Background(thanks) ; "Thanks for calling press 1 for sales, 2 for support, ..."
exten => s,n,WaitExten
exten => 1,1,Goto(submenu,s,1)
exten => 2,1,Hangup

[submenu]
exten => s,1,Ringing ; Make them comfortable with 2 seconds of ringback
exten => s,n,Wait,2
exten => s,n,Background(submenuopts) ; "Thanks for calling the sales ;department. Press 1 for steve, 2 for..."
exten => s,n,WaitExten
exten => 1,1,Goto(default,steve,1)
exten => 2,1,Goto(default,mark,2)


Lets have a closer look at what the lines above do exactly.

Any call arriving in the mainmenu context, will first go to the s extension. (why ? Read on and you will find the answer below in the predefined extensions section)

exten => s,1,Ringing:
The first priority in this s extension is extension 1, this will just provide some ringing sound to the caller.


exten => s,n,Wait,2:
The second priority in extension s, is the wait application with parameter 2, which would just wait for 2 seconds, and as a result give ringing for 2 seconds before playing the audio file "submenuopts" to the caller as defined in the 3rd priority. (exten => s,n,Background(submenuopts))


exten => s,n,WaitExten:
The 4th priority will wait for the caller to enter some digits, (such as press 1 for steve, press 2 for mark), the keys pressed by the caller will be the new extension. (if the person presses 1, the call will go to extension 1, priority 1, if the person presses 2, the call would go to extension 2, priority 2)


Lets assume the caller pressed 2:

exten => 2,1,Goto(default,mark,2):
The caller pressed 2 and the call flow will now go to the default context, extension mark, priority 2.


exten => mark,2,Dial(SIP/mark);
In this last step, it would dial the sip user mark. (as defined in sip.conf)



3. Extension

Extension = telephone number? Yes, in general it is true.There are three types of extensions : litteral, predifined and pattern.

The litteral extensions can contain in their name: numbers (0-9), letters A,B,C,D (some hardphones have these letters) or all letters (a-z). Are extension names case sensitive? Yes and no. They are case sensitive when Asterisk have to match a user dialed extension to the extensions that are defined in a context. Extension names are not case sensitive when you try define two extensions (in one context) with same name but different case (you can not do this).

There are several predefined extension names:
- i - Invalid
- s - Start
- h - Hangup
- t - Timeout
- T - AbsoluteTimeout
- o - Operator


Example:
some example


If extension name starts with '_', it is consider as pattern.
For the extension that use pattern, some characters have special meaning:
- X - any digit from 0-9
- Z - any digit from 1-9
- N - any digit from 2-9
- [12679] - any digit in the brakets (in the example: 1,2,6,7,9)
- . - (dot) wildcard, matches everything remaining
( _1234. - matches anything strating with 1234 excluding 1234 itself).


Note: Do not use '_.', because it will match everything even the predefined extensions!!!

Example:
_359ZXXXXXX - This will match all dilaed extensions that start with 359, and are 10 digits long( including 359)
_0XXX. - This will match all dialed extensions that begin with 0 and are minimum 5 digits long (including 0)


So you can see that with help of patterns you can group calls as national, international or local, the only thing you must do is to write the pattern.

4. Other very useful stuff included in extensions.conf

4.1 ignorepad

Another option that can be set is ignorepat. This option instructs drivers
to not cancel dialtone upon receipt specified pattern:
Example:
ignorepat => 8 - dialtone will remain after pressing 8

4.2 switch
Switch option permits a server to share his dialplan with
another server (ServerA>ServerB). Note that reciprocal switch
statements are not allowed (ServerA>ServerB and ServerB>ServerA).

switch => IAX2/:[]@/

Note that and need to be declared in iax.conf
of the remote server ().

4.3 include

You can include all numbers from one context to another context. To do that use:
include => some_context_to_be_included

Except context you can include another configuration file. To do this you have to use '#include':

#include "some_file_to_be_included.conf"