CPU at 100% (load average > 3) with a basic config

Hello there,

I have mounted a very basic PBX with a configuration very close to basic-pbx and the only updates are on the extensions.conf and pjsip.conf configuration files listed here

My CPU is a Intel Celeron 3865U and it’s load average is permanently over 3.
The Asterisk version is 18.15.0
The full and other logs seem to display nothing abnormal

Any idea?
Thanks!

Additional info:

CLI> core show channels
Channel              Location             State   Application(Data)             
0 active channels
0 active calls
0 calls processed

CLI> core show applications
    -= Registered Asterisk Applications =-
        AddQueueMember: 
                Answer: 
            BackGround: 
                Bridge: 
            BridgeWait: 
                  Busy: 
  CallCompletionCancel: 
  CallCompletionRequest: 
             ClearHash: 
            ConfBridge: 
              ConfKick: 
            Congestion: 
                  Dial: 
             Directory: 
            ExecIfTime: 
                 Gosub: 
               GosubIf: 
                  Goto: 
                GotoIf: 
            GotoIfTime: 
                Hangup: 
             ImportVar: 
            Incomplete: 
                   Log: 
           MessageSend: 
                  MSet: 
           MusicOnHold: 
                  NoOp: 
      PauseQueueMember: 
              Playback: 
            Proceeding: 
              Progress: 
                 Queue: 
              QueueLog: 
           QueueUpdate: 
        RaiseException: 
     RemoveQueueMember: 
             RetryDial: 
                Return: 
               Ringing: 
              SayAlpha: 
          SayAlphaCase: 
             SayDigits: 
              SayMoney: 
             SayNumber: 
            SayOrdinal: 
           SayPhonetic: 
                   Set: 
           SetAMAFlags: 
              StackPop: 
      StartMusicOnHold: 
       StopMusicOnHold: 
    UnpauseQueueMember: 
               Verbose: 
        VMAuthenticate: 
             VMSayName: 
             VoiceMail: 
         VoiceMailMain: 
      VoiceMailPlayMsg: 
                  Wait: 
             WaitDigit: 
             WaitExten: 
    -= 62 Applications Registered =-

CLI> core show taskprocessors

Processor                                                               Processed   In Queue  Max Depth  Low water High water
app_voicemail                                                                   0          0          0        450        500
ast_msg_queue                                                                   0          0          0        450        500
CCSS_core                                                                       0          0          0        450        500
dns_system_resolver_tp                                                          7          0          1        450        500
pjsip/default-00000008                                                         24          0          1        450        500
pjsip/default-00000009                                                          0          0          0        450        500
pjsip/default-0000000a                                                          0          0          0        450        500
pjsip/default-0000000b                                                          0          0          0        450        500
pjsip/default-0000000c                                                          0          0          0        450        500
pjsip/default-0000000d                                                          0          0          0        450        500
pjsip/default-0000000e                                                          0          0          0        450        500
pjsip/default-0000000f                                                          0          0          0        450        500
pjsip/distributor-00000020                                                      0          0          0        450        500
pjsip/distributor-00000021                                                      0          0          0        450        500
pjsip/distributor-00000022                                                      0          0          0        450        500
pjsip/distributor-00000023                                                      0          0          0        450        500
pjsip/distributor-00000024                                                      0          0          0        450        500
pjsip/distributor-00000025                                                      4          0          1        450        500
pjsip/distributor-00000026                                                      0          0          0        450        500
pjsip/distributor-00000027                                                      0          0          0        450        500
pjsip/distributor-00000028                                                      0          0          0        450        500
pjsip/distributor-00000029                                                      0          0          0        450        500
pjsip/distributor-0000002a                                                      0          0          0        450        500
pjsip/distributor-0000002b                                                      0          0          0        450        500
pjsip/distributor-0000002c                                                      8          0          1        450        500
pjsip/distributor-0000002d                                                      0          0          0        450        500
pjsip/distributor-0000002e                                                      0          0          0        450        500
pjsip/distributor-0000002f                                                      6          0          1        450        500
pjsip/distributor-00000030                                                      0          0          0        450        500
pjsip/distributor-00000031                                                      2          0          1        450        500
pjsip/distributor-00000032                                                      0          0          0        450        500
pjsip/distributor-00000033                                                      0          0          0        450        500
pjsip/distributor-00000034                                                      0          0          0        450        500
pjsip/distributor-00000035                                                      0          0          0        450        500
pjsip/distributor-00000036                                                      2          0          1        450        500
pjsip/distributor-00000037                                                      0          0          0        450        500
pjsip/distributor-00000038                                                      0          0          0        450        500
pjsip/distributor-00000039                                                      2          0          1        450        500
pjsip/distributor-0000003a                                                      0          0          0        450        500
pjsip/distributor-0000003b                                                      0          0          0        450        500
pjsip/distributor-0000003c                                                      0          0          0        450        500
pjsip/distributor-0000003d                                                      4          0          1        450        500
pjsip/distributor-0000003e                                                      0          0          0        450        500
pjsip/exten_state                                                               0          0          0        450        500
pjsip/messaging                                                                 0          0          0        450        500
pjsip/mwi-0000004c                                                              1          0          1        450        500
pjsip/mwi-0000004d                                                              0          0          0        450        500
pjsip/mwi-0000004e                                                              0          0          0        450        500
pjsip/mwi-0000004f                                                              0          0          0        450        500
pjsip/mwi-00000050                                                              0          0          0        450        500
pjsip/mwi-00000051                                                              0          0          0        450        500
pjsip/mwi-00000052                                                              0          0          0        450        500
pjsip/mwi-00000053                                                              0          0          0        450        500
pjsip/options/1001-00000041                                                     2          0          1        450        500
pjsip/options/1002-00000042                                                     1          0          1        450        500
pjsip/options/1003-00000043                                                     1          0          1        450        500
pjsip/options/1004-00000044                                                     1          0          1        450        500
pjsip/options/1005-00000045                                                     2          0          1        450        500
pjsip/options/1006-0000003f                                                     1          0          1        450        500
pjsip/options/manage                                                            5          0          2       4500       5000
pjsip/options/trunk-sfr-00000040                                                1          0          1        450        500
pjsip/outreg/trunk-sfr-00000059                                                44          0          2        450        500
pjsip/pool                                                                     94          0          2        450        500
pjsip/pool-control                                                            259          0          3        450        500
sorcery/acl-00000056                                                            0          0          0        450        500
sorcery/aor-00000015                                                            1          0          1        450        500
sorcery/asterisk-publication-00000055                                           0          0          0        450        500
sorcery/auth-00000010                                                           0          0          0        450        500
sorcery/bucket-00000000                                                         0          0          0        450        500
sorcery/contact-00000014                                                       10          0          1       1350       1500
sorcery/domain_alias-00000016                                                   0          0          0        450        500
sorcery/endpoint-00000011                                                       1          0          1        450        500
sorcery/file-00000001                                                           0          0          0        450        500
sorcery/global-00000017                                                         5          0          1        450        500
sorcery/identify-00000046                                                       0          0          0        450        500
sorcery/inbound-publication-0000004a                                            0          0          0        450        500
sorcery/log_mappings-00000006                                                   0          0          0        450        500
sorcery/nat_hook-00000012                                                       0          0          0        450        500
sorcery/outbound-publish-00000047                                               0          0          0        450        500
sorcery/pool                                                                   18          0          1        450        500
sorcery/pool-control                                                           44          0          1        450        500
sorcery/registration-00000058                                                   1          0          1        450        500
sorcery/resource_list-00000049                                                  0          0          0        450        500
sorcery/subscription_persistence-00000048                                       0          0          0        450        500
sorcery/system-00000007                                                         0          0          0        450        500
sorcery/transport-00000013                                                      0          0          0        450        500
stasis/m:bridge:all-0000005b                                                    1          0          1        450        500
stasis/m:cdr:aggregator-00000005                                                4          0          1       4500       5000
stasis/m:channel:all-0000005c                                                   2          0          1        450        500
stasis/m:channel:all-0000005e                                                   1          0          1        450        500
stasis/m:devicestate:all-00000002                                              21          0          2        450        500
stasis/m:devicestate:all-00000003                                              21          0          2        450        500
stasis/m:devicestate:all-0000005d                                               5          0          2        450        500
stasis/m:presence_state:all-00000004                                            1          0          1        450        500
stasis/m:security:all-0000001f                                                  1          0          1        450        500
stasis/m:security:all-00000057                                                  1          0          1        450        500
stasis/m:system:all-0000005a                                                    1          0          1        450        500
stasis/p:endpoint:PJSIP/1001-00000019                                           1          0          1        450        500
stasis/p:endpoint:PJSIP/1002-0000001a                                           1          0          1        450        500
stasis/p:endpoint:PJSIP/1003-0000001b                                           1          0          1        450        500
stasis/p:endpoint:PJSIP/1004-0000001c                                           1          0          1        450        500
stasis/p:endpoint:PJSIP/1005-0000001d                                           1          0          1        450        500
stasis/p:endpoint:PJSIP/1006-0000001e                                           1          0          1        450        500
stasis/p:endpoint:PJSIP/trunk-sfr-00000018                                      1          0          1        450        500
stasis/pool                                                                    11          0          1        450        500
stasis/pool-control                                                            33          0          2        450        500

106 taskprocessors

CLI> core show threads
0x7f42cbc59b38 132 netconsole           started at [ 1569] asterisk.c listener()
0x7f42c9bbdb38 54 monitor_sig_flags    started at [ 4314] asterisk.c asterisk_daemon()
0x7f42c9cc1b38 52 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42c9c42b38 53 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42c9d57b38 51 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42c9de8b38 50 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42c9eefb38 48 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42c9e6cb38 49 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42c9f88b38 47 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42ca12bb38 44 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42ca09fb38 45 check_expiration_thread started at [ 1400] res_pjsip_registrar.c expiration_global_loaded()
0x7f42ca00fb38 46 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42ca2e6b38 40 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42ca1e8b38 42 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42ca267b38 41 keepalive_transport_thread started at [  335] res_pjsip/pjsip_transport_management.c keepalive_global_loaded()
0x7f42ca365b38 39 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42ca7b8b38 31 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42ca83bb38 30 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42ca8f1b38 29 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42ca974b38 28 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42ca9f5b38 27 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cb627b38 24 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cb527b38 26 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cb7afb38 21 bridge_manager_thread started at [ 4949] bridge.c bridge_manager_create()
0x7f42cb72eb38 22 do_devstate_changes  started at [  621] devicestate.c ast_device_state_engine_init()
0x7f42cb6a6b38 23 sched_run            started at [  216] sched.c ast_sched_start_thread()
0x7f42cb5a6b38 25 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cb846b38 20 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cb8c5b38 19 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cb947b38 18 logger_thread        started at [ 1973] logger.c init_logger()
0x7f42cb9c6b38 17 listener             started at [ 1635] asterisk.c ast_makesocket()
0x7f42cbbd9b38 14 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cbeb8b38 8 canary_thread        started at [ 4120] asterisk.c asterisk_daemon()
0x7f42cbd62b38 10 default_tps_processing_function started at [  229] taskprocessor.c default_listener_start()
0x7f42cbdf2b38 9 db_sync_thread       started at [ 1199] db.c astdb_init()
35 threads listed.

What is the load average when Asterisk is not running?

Antony.

0 to 0.5 when I pause the asterisk processes
The two cores are under 1%

When you say “mounted”, exactly what do you mean?

How much memory is in that system? Any chance you’re paging virtual memory, which can then manifest as high load average?

Have you attempted to stop modules you know you don’t need/won’t use from loading?

I have to assume you’ve also changed logger.conf to get a log file. Have you tried disabling the log files, to see if you’re having a disk IO issue? This is in the same idea of the paging question. Poor disk IO can manifest as high load average.

Try to run asterisk in debug mode and analyse.
Share the debug details here.

I would like to say “setup”…
Total memory usage : 438M/3.76G
I will try to disable unused modules and log files…

Following https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information:

CLI> logger add channel debug_log_123456 notice,warning,error,debug,verbose,dtmf
CLI> core set verbose 5
Console verbose was 10 and is now 5.
CLI> core set debug 5
Core debug was OFF and is now 5.
CLI> module reload logger
Module 'logger' reloaded successfully.
CLI> pjsip set logger on
PJSIP Logging enabled

cat /var/log/asterisk/debug_log_123456 seems to give nothing useful… :

[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_VARIABLES'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_EXISTS'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_MEMBER'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_MEMBER_COUNT'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_MEMBER_LIST'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_GET_CHANNEL'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_WAITING_COUNT'
[Feb 27 16:05:50] VERBOSE[1] pbx_functions.c: Registered custom function 'QUEUE_MEMBER_PENALTY'
[Feb 27 16:05:50] VERBOSE[1] loader.c: app_queue.so => (True Call Queueing)
[Feb 27 16:05:50] VERBOSE[1] asterisk.c: Asterisk Ready.
[Feb 27 16:06:28] VERBOSE[17] asterisk.c: Remote UNIX connection
[Feb 27 16:06:58] DEBUG[33] threadpool.c: Worker thread idle timeout reached. Dying.
[Feb 27 16:06:58] DEBUG[30] threadpool.c: Destroying worker thread 5
[Feb 27 16:06:58] Asterisk 18.15.0 built by buildozer @ build-3-17-x86_64 on a x86_64 running Linux on 2022-11-19 07:17:49 UTC
[Feb 27 16:06:58] VERBOSE[67] loader.c: Reloading module 'logger' (Logger)
[Feb 27 16:06:58] DEBUG[67] config.c: Parsing /etc/asterisk/logger.conf
[Feb 27 16:06:58] VERBOSE[67] logger.c: Asterisk Queue Logger restarted
[Feb 27 16:07:20] DEBUG[43] res_pjsip_registrar.c: Woke up at 1677514040  Interval: 30
[Feb 27 16:07:20] DEBUG[43] res_pjsip_registrar.c: Expiring 0 contacts
[Feb 27 16:07:50] DEBUG[43] res_pjsip_registrar.c: Woke up at 1677514070  Interval: 30
[Feb 27 16:07:50] DEBUG[43] res_pjsip_registrar.c: Expiring 0 contacts
[Feb 27 16:08:20] DEBUG[43] res_pjsip_registrar.c: Woke up at 1677514100  Interval: 30
[Feb 27 16:08:20] DEBUG[43] res_pjsip_registrar.c: Expiring 0 contacts

do you have E1/T1 interface ?

No, it’s just a basic mini pc with the following PCI device list:

# lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 02)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 610 (rev 02)
00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 02)
00:08.0 System peripheral: Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #0 (rev 21)
00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #1 (rev 21)
00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21)
00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller [AHCI mode] (rev 21)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 (rev f1)
00:1c.1 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #2 (rev f1)
00:1c.2 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #3 (rev f1)
00:1c.3 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #4 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 (rev f1)
00:1c.5 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #6 (rev f1)
00:1d.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #9 (rev f1)
00:1e.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO UART Controller #0 (rev 21)
00:1e.4 SD Host controller: Intel Corporation Device 9d2b (rev 21)
00:1e.6 SD Host controller: Intel Corporation Sunrise Point-LP Secure Digital IO Controller (rev 21)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point LPC Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
01:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
02:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
03:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
04:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
05:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)
06:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)

I have found the reason of the issue:

In fact, asterisk was launched as docker entrypoint (without terminal) with -vvvgc options (including -c, provide console CLI).
asterisk is now launched with -f and the process is around 1% of the CPU.

Thanks for your support

1 Like

Interesting fact, may you share your entry point.

This is my Dokerfile :

FROM alpine:3.17

RUN apk add asterisk
RUN mkdir -p /var/lib/asterisk/moh
RUN chown asterisk:asterisk -R /var/lib/asterisk
RUN chown -R asterisk:asterisk /usr/lib/asterisk
RUN chown -R asterisk:asterisk /var/lib/asterisk
RUN chown -R asterisk:asterisk /var/spool/asterisk
RUN chown -R asterisk:asterisk /var/log/asterisk
RUN chown -R asterisk:asterisk /var/run/asterisk
RUN chown asterisk:asterisk /usr/sbin/asterisk

USER asterisk:asterisk
ENTRYPOINT ["/usr/sbin/asterisk"]
CMD ["-f"]
1 Like

Interesting I ran in to the same problem, using Asterisk with Ubuntu as based image, This was my Dockerfile configuration.

1. ENTRYPOINT ["/usr/sbin/asterisk"]

2. CMD ["-c", "-vvvv", "-g"]

Changed to what you suggested and working perfectly, less than 1 % of the CPU usage.

ENTRYPOINT ["/usr/sbin/asterisk"]
CMD ["-f"]

Now the interesting part is finding out why?

Fom the asterisk manual :

-c

Provide a control console on the calling terminal. The console is similar to the remote console provided by -r. Specifying this option implies -f and will cause asterisk to no longer fork or detach from the controlling terminal. Equivalent to console = yes in asterisk.conf. 

Due to the entrypoint is launched without terminal and stdin (non-interactive mode), it may cause an infinite loop trying to read on a non-existing input device…

1 Like