How to reduce the CPU usage?

i am using Intel® Pentium® 4 CPU 2.66GHz and 512 RAM and using 2 TE110P card.

PABX-> Asterisk-> PRI Telco

             |
          IP Network

             |
           Cisco -----> Gateway

My Asterisk will pass the local call to Telco while the receive local call from PABX. And Asterisk will pass the Handphone call ,IDD call to Cisco while receive call from PABX side.

Due to the utilization of the PRI Telco is quite low and we have route some local call from Gateway to Asterisk via Cisco.

i have set asterisk to use codec g729 while pass the call to cisco and at the mean time cisco will use codec alaw while pass the local call to asterisk and terminate at PRI telco.

I am facing breaking sound while the tracffic is high , and the cpu usage is constantly 99%. can anybody give me some advice to solve this problem ? is this problem due to the Hardware problem or network problem?

Thanks

You need to run “top” to see whats hogging the cpu.

Ian

i have run top to view the cpu usage and asterisk is hogging to the syetem

WOW! I haven’t seen my box doing that. What is the average number of sessions when the cpu hits 99%?

top - 11:46:52 up 9 days, 15:36, 2 users, load average: 6.15, 6.14, 6.10
Tasks: 135 total, 7 running, 128 sleeping, 0 stopped, 0 zombie
Cpu(s): 74.4% us, 21.6% sy, 0.0% ni, 0.0% id, 0.0% wa, 4.0% hi, 0.0% si
Mem: 514544k total, 384960k used, 129584k free, 47552k buffers
Swap: 779144k total, 0k used, 779144k free, 211444k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11021 root 25 0 30080 10m 5684 R 17.0 2.1 13:04.53 asterisk
5047 root 25 0 5788 1272 1020 R 16.6 0.2 11422:54 asterisk
348 root 25 0 5436 1272 1016 R 16.6 0.2 642:37.86 asterisk
11797 root 25 0 6628 1276 1020 R 16.6 0.2 617:43.09 asterisk
27089 root 25 0 6596 1276 1020 R 16.6 0.2 548:33.80 asterisk
13294 root 25 0 6680 1276 1020 R 16.3 0.2 253:18.34 asterisk
1 root 16 0 1996 552 472 S 0.0 0.1 0:00.34 init

Is it a better way to replace the E1 digium card with DSP features which can offload the cpu usage?

I hate to mention this (because its hardware based troubleshooting) but have you cleaned your hardware lately (making sure cpu fan is top speed, making sure the paste between the heat sink and cpu is still in its acceptable state, etc) ? I have read some posts which tackles the same thing. Problem is, those threads ended up in a open state (no answers were advised (asterisk relevant answers))

Worst case is installing another instance of Asterisk to another drive (newly formated)on the same machine and testing if the newly formatted disk makes difference. If it is still the same, then I think hardware upgrade is inevitable. If the disk makes a difference, you could go either ways, migrate all the files on the new disk or have that hacker kind of attitude and try to find that problem using a kit which monitors data coming in and out of the processor.

I wish somebody would post an Asterisk reconfiguration/tweaking answer so that many would benefit.

You have something seriously wrong here.

You need to go through your dialplan to see whats up, Im guessing that due to the number of asterisk processes you are using some agi here,

Im guessing you have a loop or something that is running away.

Ian

Hi,
why the two different codecs between Asterisk & the Cisco gear - you state ulaw to asterisk & g729 to cisco.

Aren’t you forcing unnecessary transcoding here - can you try ulaw both ways?

Ah the good old windoze way

Basicly there is a problem with the asterisk config. that is what needs to isolated. and fixed.

This is more like the way to go

Ian

It is just a guess, but if there is something wrong in your dialplan that force Asterisk to go to the other pbx and when landing there the other pbx is routing the call back I can imagine that, with all the transcoding in between, the cpu is fully loaded. Or maybe some other kind of loop like suggested in earlier posts.

My suggestion is to examine the logs and if that doesn’t give you any clue to do a fresh installation of linux and Asterisk without any fancy agi scripts etc, just the plain Asterisk. This will take you a couple of hours with most of the time just waiting for the installation to finish. You can spend days with debugging the current system.

Good luck!

First thing to do is look at the CLI of a call.

Then do a “show dialplan” to see what set to happen accordig to th esystem and not the conf file,

Ian

I didn’t run any Agi command , my asterisk just do the simple job , receive HP or IDD call then route it to CISCO, and terminate all the local calls from CISCO to PABX. Is there anybody know the DSP digium can offload the trascoding load of CPU?

Well if thats the case then there is a problem with the dialplan. Perhaps the hints havent been big enough, IE posting the CLI output of a call and the dialplan, so we can see whats actually happening.

Ian

;DID number from PRI telco to asterisk and pass to PABX via span 2

[Maxis_to_asterisk]
exten => _03233027xx,1,Dial(ZAP/g2/${EXTEN})
exten => _03233027xx,2,Hangup

exten => _03233028xx,1,Dial(ZAP/g2/${EXTEN})
exten => _03233028xx,2,Hangup

PABX call HP and IDD calls will terminate via cisco

[asterisk_to_pabx]

exten => _0X.,1,Dial(SIP/${EXTEN}@cisco)
exten => _0X.,3,Hangup

Local call will terminate via span 1 n pass to telco
exten => _2xxxxxxx,1,Dial(ZAP/g1/${EXTEN})
exten => _2xxxxxxx,2,Hangup

Local call will terminate via cisco to asterisk and it will pass to span 1 n terminate local calls

[from-sip-external]

exten => _032xxxxxxx,1,Dial(ZAP/g1/${EXTEN:2})
exten => _032xxxxxxx,2,Hangup

Hi

If that realy is the dialplan then something is realy wrong, I think the CLI output of a call after a “restart now” at the * CLI. first checking that only one asterisk process exists.

Then fire the call in and see what we get.

I would also up the memory to 1G or 2G

also when the load is high do a “show channels”

Ian

I think this should be rephrased as “the bad all-time windoze way” :smiley:

Count me in on the avid viewers of this thread! I wanna learn :wink:

Any ideal on this problem ?

I got an advice is to check the CISCO’s RAM. But the problem is this CISCO lasttime is handling 4 E1 together in a same time and there is no preoblem.

Is it got any culculation to culculate the CPU usage to handle each call wheter is trancoded or not transcode?

If you restart the server and start Asterisk you should only have one instance if the zabbix process running. The top output you showed before has more than one. My guess is the multiple instances are either fighting each other for cpu resources and/or at least one of them is in a runaway loop.

Try restarting and just starting asterisk and check the list of processes to see how many instances of asterisk are running (ps -C asterisk). If only one then move on otherwise check your startup script. Next, try making a call - again check the list of processes to see how many are running. Keep trying different things until you find the action(s) that cause new instances of asterisk to run.