What is the problem of arrival cpu 100%

I have several ( at least 5 ) freePBX servers that all experienced a similar issue. It looks like there are a lot of scheduled tasks in FreePBX crontab that all kick off at the top of the minute and all do database query’s. The fix for me was to change the crontab so that multiple tasks did not kick off at the same time (note this will probably [likely] be overwritten with future updates) and ultimately I had to upgrade ALL my systems to SSD disks to effectively eliminate the issue. (now it occurs very infrequently). My virtual server provider has an open ticket with Sangoma about this issue I had.

1 Like

Did you enable FastAGI?

This is my solution also. Editing the cron and the CPU spikes disapear on each minute.
Only problem is the module updates changes the cron back to FreePBX default settings.
FastAGI helps, but not as much as editing the cron jobs.
Ik inserted a sleep command with random time. Mostly on the commercial modules.
Just try it and compare cpu spike at the whole minute:
Change next line in the cron:
crontab -e -u asterisk
*/1 * * * * var/lib/asterisk/bin/pagepro-scheduler.php 2>&1 >/dev/null
into
*/1 * * * * sleep $(( ( RANDOM % 40 ) + 1 )) && var/lib/asterisk/bin/pagepro-scheduler.php 2>&1 >/dev/null

Make sure you make a backup first of /var/spool/cron/asterisk

How can i see or route to arrival? :
*/1 * * * * var/lib/asterisk/bin/pagepro-scheduler.php 2>&1 >/dev/null
into
*/1 * * * * sleep $(( ( RANDOM % 40 ) + 1 )) && var/lib/asterisk/bin/pagepro-scheduler.php 2>&1 >/dev/null

Check the difference with the time command
for example:
time sleep $(( ( RANDOM % 40 ) + 1 )) && /var/lib/asterisk/bin/pagepro-scheduler.php
compared to original
time /var/lib/asterisk/bin/pagepro-scheduler.php

My best practice was a screen recorder en record cli at the command line the next command:
Than you can easily pause the recorded screen at the whole minute and see what hgappens.
A bit simple, but it works for me. :slight_smile:

top -d 0.5 -u asterisk -c
And at the whole minute, you can see exactly, which cron, with which file, takes al the CPU power.

This result i Found

*/1 * * * * /var/lib/asterisk/bin/pagepro-scheduler.php 2>&1 >/dev/null
And in your command replied i set to :
time sleep $(( ( RANDOM % 40 ) + 1 )) && /var/lib/asterisk/bin/pagepro-scheduler.php
Suppose i changed whats the result can i have? For example the issue can solve or not back again, After i change ?
Please advice

It is hard to help you this way.
The best way is ta hire some help from Sangoma, or anyone who wants to help.
Maybe it is possible to use Teamviewer en let someone look with you to what is happening in your PBX.
If you want me to help, you can send me a private message.

Thank you,
In before 3 days i upgrade the server to the last version, After that i change the server from machine to another machine server and rebooted the server so in this time the server sort of stable, I monitor the server if any issue back again i will posted in this community,
Thank you again for your advice

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