Asterisk consuming 100% CPU

Hello guy’s. I’m new with Voip and i followed this tutorial to install freepbx and asterisk

http://www.osslab.tw/books/asterisk-freepbx/page/install-freepbx-15-with-asterisk-16-on-debian-10

the only module I’v selected that wasn’t in make menu is macro.

after that I followed this on to enable webRtc
https://wiki.asterisk.org/wiki/display/AST/Configuring+Asterisk+for+WebRTC+Clients
https://wiki.asterisk.org/wiki/display/AST/WebRTC+tutorial+using+SIPML5

but my asterisk is consuming 100% of cpu in idle without any peer
how can I debug this to understand what is happening here?
my top:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7117 root 20 0 55432 12232 8240 R 99.7 0.3 4414:33 rasterisk r
20985 root 20 0 9872 3576 3000 R 0.7 0.1 0:00.02 top
11111 asterisk 20 0 1248256 107344 36096 S 0.3 2.7 13:08.26 asterisk start
12079 asterisk 20 0 695512 54684 31812 S 0.3 1.4 1:10.89 PM2 v4.5.0: God Daemon (/var/lib/asterisk/.p+
1 root 20 0 170636 10592 8000 S 0.0 0.3 0:39.24 /sbin/init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kthreadd]
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [rcu_gp]
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [rcu_par_gp]
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kworker/0:0H-kblockd]
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [mm_percpu_wq]
9 root 20 0 0 0 0 S 0.0 0.0 0:02.85 [ksoftirqd/0]
10 root 20 0 0 0 0 I 0.0 0.0 0:15.63 [rcu_sched]
11 root 20 0 0 0 0 I 0.0 0.0 0:00.00 [rcu_bh]
12 root rt 0 0 0 0 S 0.0 0.0 0:02.92 [migration/0]
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [cpuhp/0]
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [cpuhp/1]
16 root rt 0 0 0 0 S 0.0 0.0 0:02.93 [migration/1]
17 root 20 0 0 0 0 S 0.0 0.0 0:04.84 [ksoftirqd/1]
19 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kworker/1:0H-kblockd]
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kdevtmpfs]
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [netns]
22 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kauditd]
24 root 20 0 0 0 0 S 0.0 0.0 0:00.13 [khungtaskd]
25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [oom_reaper]
26 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [writeback]
27 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kcompactd0]
28 root 25 5 0 0 0 S 0.0 0.0 0:00.00 [ksmd]
29 root 39 19 0 0 0 S 0.0 0.0 0:01.34 [khugepaged]
30 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [crypto]
31 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kintegrityd]
32 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kblockd]
33 root rt 0 0 0 0 S 0.0 0.0 0:00.00 [watchdogd]
34 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kswapd0]
50 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kthrotld]
51 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [ipv6_addrconf]
61 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kstrp]

image

Have you checked the asterisk logs (typically /var/log/asterisk/full) for any information?

nothing anormal, only random ips tryng to connect and I’m doing iptables -drop then;;

in core set debug 10 I’m gotting this

[2021-08-20 04:46:02] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 7 instead
[2021-08-20 04:46:02] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 6 instead
[2021-08-20 04:46:03] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 7 instead
[2021-08-20 04:46:03] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 6 instead
[2021-08-20 04:46:03] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 7 instead
[2021-08-20 04:46:03] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 6 instead
[2021-08-20 04:46:04] DEBUG[11177]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but
got 7 instead
[2021-08-20 04:46

Do you have channels that got stuck? I’ve seen that hanging channels can eat a lot of CPU.

asterisk -x"core show channels verbose"
PID  USER PR NI VIRT  RES   SHR  S %CPU %MEM TIME+   COMMAND
7117 root 20 0  55432 12232 8240 R 99.7 0.3  4414:33 rasterisk r

This isn’t the main Asterisk process that is looping, it an Asterisk CLI process. I’m not sure what would cause that to misbehave, but could it be trying to run on an invalid console (ssh sessions and X-Window windows count as consoles)?

I’d consider just killing it, but for better diagnostics, attach gdb to it and find out where it is looping.

This is the main Asterisk process:

PID   USER     PR NI VIRT    RES    SHR   S %CPU %MEM TIME+    COMMAND
11111 asterisk 20 0  1248256 107344 36096 S 0.3  2.7  13:08.26 asterisk start

asterisk*CLI> core show channels verbose
Channel Context Extension Prio State Application Data CallerID Duration Accountcode PeerAccount BridgeID
0 active channels
0 active calls
167 calls processed

I’m running the asterisk on Gcloud compute engine.
then I reboot the machine and that worked for now.

image

can it be that there is no swap space?

I’ve no idea how Asterisk, in remote console mode, reacts to failing to allocate memory. I would hope it would either shutdown, or fail more benignly. Generally, you don’t want to be in a position where you are using swap space on a machine dedicated to running Asterisk.

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