Asterisk Service Taking High CPU USAGE 100% ( 4 Cores )


(Amardeep Rana) #1

Hi
Asterisk Service Taking High CPU USAGE 100% ( 4 Cores ).

FreePBX 14.0.13.34

Please suggest.

Thanks
Amardeep


(Shahin Nazir) #2

Hi @amardeeprana
Pls try to check which service(s) used more CPU

ps -eo pcpu,pid,user,args | sort -k1 -r -n | head -10
or
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

And check your HDD Disk health status.
What is the your Asterisk version ?

Thanks.

Shahin


(Amardeep Rana) #3

Hi @shahin

Please find the output
Asterisk 13.32.0 - Version

[root@freepbx httpd]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
PID PPID CMD %MEM %CPU
1648 1257 /usr/libexec/mysqld --based 9.2 0.5
1418 1 /usr/sbin/named -u named -c 5.7 0.0
29779 2533 /usr/sbin/asterisk -f -U as 5.7 91.9

Thanks
Amardeep


(Shahin Nazir) #4

Hi @amardeeprana
Pls check your HDD status ? free space on it and health.
I think SQL DB trying to fix self, since when you have CPU overloaded?

ps auxf | grep asterisk
df -h
fwconsole chown

I think God Daemon works on the PBX background.

Thanks.

Shahin


(Amardeep Rana) #5

Hi @shahin

I facing very randomly high cpu usage. Call quality going bad when it is 100%. it has 4 cores. all are go High.
here is output of commands. checking HDD status too

[root@freepbx asterisk]# ps auxf | grep asterisk
root 19885 0.0 0.0 125912 1212 pts/0 T 17:33 0:00 | _ crontab -e -u asterisk
root 3732 0.0 0.0 125912 1216 pts/0 T 18:30 0:00 | _ crontab -e -u asterisk
root 16067 0.0 0.0 125912 1212 pts/0 T 21:30 0:00 | _ crontab -e -u asterisk
root 5218 0.0 0.0 112708 988 pts/0 S+ 22:04 0:00 | _ grep --color=auto asterisk
asterisk 18115 0.0 2.1 779624 83516 ? S 16:46 0:17 _ /usr/sbin/httpd -DFOREGROUND
asterisk 13339 0.0 1.9 764892 74748 ? S 17:15 0:13 _ /usr/sbin/httpd -DFOREGROUND
asterisk 14814 0.0 1.5 747208 59492 ? S 17:18 0:09 _ /usr/sbin/httpd -DFOREGROUND
asterisk 23917 0.0 1.5 758196 58244 ? S 17:39 0:06 _ /usr/sbin/httpd -DFOREGROUND
asterisk 24927 0.0 1.2 743564 49168 ? S 17:46 0:04 _ /usr/sbin/httpd -DFOREGROUND
asterisk 25359 0.0 1.6 758988 64716 ? S 17:47 0:04 _ /usr/sbin/httpd -DFOREGROUND
asterisk 21356 0.0 1.3 739504 51432 ? S 18:22 0:03 _ /usr/sbin/httpd -DFOREGROUND
asterisk 32018 0.0 0.9 736444 37744 ? S 20:59 0:00 _ /usr/sbin/httpd -DFOREGROUND
asterisk 32629 0.0 0.6 734376 26348 ? S 20:59 0:00 _ /usr/sbin/httpd -DFOREGROUND
asterisk 1886 0.0 0.6 734376 25640 ? S 21:25 0:00 _ /usr/sbin/httpd -DFOREGROUND
asterisk 2988 0.0 0.2 197980 8540 ? Ss Aug28 0:00 /usr/bin/python /usr/local/bin/pnp_server
asterisk 13046 0.1 2.0 964544 80600 ? Ssl Aug28 10:44 PM2 v2.10.6: God Daemon (/home/asterisk/.pm2)
asterisk 29889 1.9 1.2 1103896 48312 ? Ssl 17:55 4:49 _ node /var/www/html/admin/modules/ucp/node/index.js
asterisk 5216 0.0 0.4 370480 16668 ? Rs 22:04 0:00 _ php /var/www/html/admin/modules/restapps/restapps.php
root 2533 0.0 0.0 115308 1068 ? S 17:10 0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk -g
asterisk 29779 91.6 5.8 3268748 225100 ? Sl 17:55 228:26 _ /usr/sbin/asterisk -f -U asterisk -G asterisk -g -vvvg -c

[root@freepbx asterisk]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/SangomaVG-root 255G 8.0G 247G 4% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 206M 1.7G 11% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1.9G 114M 1.7G 7% /boot
tmpfs 378M 0 378M 0% /run/user/0


(Amardeep Rana) #6

Please suggest any command for HDD health.
Same server was running properly for years with lower version of freepbx but not possible to move back

I see CPU usage is normal when there are no active calls it increase when calls increase.


(Amardeep Rana) #7

hi @dicko

Please help.


#8

Hard to say what to do next. But why are you editing asterisk’s crontab three times?


(Amardeep Rana) #9

I comment 3 cron jobs but thaat does not make any impect.
Sserver cpu usage increase when call volume increase.


#10

So you can the headers for START and TIME

ps auxf | egrep 'asterisk|USER' 

(Amardeep Rana) #11

here is the output
[root@freepbx asterisk]# ps auxf | egrep ‘asterisk|USER’
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 19885 0.0 0.0 125912 1212 pts/0 T Sep01 0:00 | _ crontab -e -u asterisk
root 3732 0.0 0.0 125912 1216 pts/0 T Sep01 0:00 | _ crontab -e -u asterisk
root 16067 0.0 0.0 125912 1212 pts/0 T Sep01 0:00 | _ crontab -e -u asterisk
root 5064 0.0 0.0 112708 664 pts/0 R+ 01:17 0:00 | _ grep -E --color=auto asterisk|USER
root 22119 1.2 0.0 158064 3012 pts/1 S+ 00:39 0:28 _ watch -n 1 asterisk -rx “sip show channelstats”
asterisk 4272 0.0 0.0 113176 1220 ? Ss 01:17 0:00 _ /bin/sh -c [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null
asterisk 4276 0.0 0.0 107952 616 ? S 01:17 0:00 _ sleep 28
asterisk 23917 0.0 1.9 773304 73728 ? S Sep01 0:09 _ /usr/sbin/httpd -DFOREGROUND
asterisk 24927 0.0 1.2 740760 48236 ? S Sep01 0:06 _ /usr/sbin/httpd -DFOREGROUND
asterisk 21356 0.0 1.3 739760 53264 ? S Sep01 0:08 _ /usr/sbin/httpd -DFOREGROUND
asterisk 32629 0.0 1.5 754700 61020 ? S Sep01 0:03 _ /usr/sbin/httpd -DFOREGROUND
asterisk 28302 0.0 1.0 739428 41640 ? S Sep01 0:01 _ /usr/sbin/httpd -DFOREGROUND
asterisk 25150 0.0 0.9 739328 38276 ? S Sep01 0:01 _ /usr/sbin/httpd -DFOREGROUND
asterisk 3348 0.0 0.7 734700 29180 ? S Sep01 0:00 _ /usr/sbin/httpd -DFOREGROUND
asterisk 7319 0.0 0.9 737464 37108 ? S Sep01 0:01 _ /usr/sbin/httpd -DFOREGROUND
asterisk 8654 0.0 0.9 739540 38324 ? S Sep01 0:01 _ /usr/sbin/httpd -DFOREGROUND
asterisk 29742 0.0 0.9 737452 37172 ? S Sep01 0:00 _ /usr/sbin/httpd -DFOREGROUND
asterisk 2988 0.0 0.2 197980 8540 ? Ss Aug28 0:00 /usr/bin/python /usr/local/bin/pnp_server
asterisk 13046 0.2 2.0 961456 77632 ? Ssl Aug28 18:39 PM2 v2.10.6: God Daemon (/home/asterisk/.pm2)
asterisk 29889 1.5 1.7 1107480 67344 ? Ssl Sep01 7:02 _ node /var/www/html/admin/modules/ucp/node/index.js
asterisk 14075 0.0 0.5 977656 21716 ? Ssl 00:59 0:00 _ node /var/www/html/admin/modules/core/node/fastagi-server.js
asterisk 5061 0.0 0.4 372436 19016 ? Rs 01:17 0:00 _ php /var/www/html/admin/modules/restapps/restapps.php
root 2533 0.0 0.0 115308 1068 ? S Sep01 0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk -g
asterisk 29779 76.4 6.0 3238248 235388 ? Sl Sep01 337:57 _ /usr/sbin/asterisk -f -U asterisk -G asterisk -g -vvvg -c


#12

Yep,

asterisk 29779 76.4 6.0 3238248 235388 ? Sl Sep01 337:57 _ /usr/sbin/asterisk -f -U asterisk -G asterisk -g -vvvg -c

is out of control ,

asterisk -V

?


(Amardeep Rana) #13

yes this one.

asterisk 29779 76.4 6.0 3238248 235388 ? Sl Sep01 337:57 _ /usr/sbin/asterisk -f -U asterisk -G asterisk -g -vvvg -c


(Amardeep Rana) #14

when call volume increase CPU usage increase. this is what happening,


(Franck Danard) #15

Hi
Try to update asterisk.
We’ve got 13.35.0 and not 13.32.0 right now.
If there was any issue on this version, maybe this one has been fixed. Just test it.
BTW, ensure your system is up to date (O.S + FreePBX modules).
So make yum update -y, and fwconsole ma updateall.
Next, launch : fwconsole restart. and check if the asterisk version is righ.
Once updated, check again to see if your issue is still present.

Just an idea like that. :wink:

@shahin Hey my friend… How are you man :slight_smile:
@dicko Hey Dicko … nice to see you there.


(Shahin Nazir) #16

Hello / Bonjour @danardf
Nice to see you too :slight_smile:


(Amardeep Rana) #17

Thank You all

What I did to resolve the issue.
Very useful

  1. You can enable the FastAGI server in open source FreePBX today. In FreePBX 14 it is disabled by default (but you can enable it). Once you enable it in Advanced Settings you will need to do an fwconsole reload & fwconsole restart.

  2. fwconsole pm2 --list - Is showed me restapp was trying to restart and having 80% CPU usage. I Stopped this service. fwconsole stop restapps and fwconsole restart

Server CPU usage was stable after that.

Thanks
Amardeep Rana


(system) closed #18

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.