hi vitalpbx team,
we had vitalpbx2 and vitalpbx3 running for years (dating back to VitalPBX 2.4.1-3) and over the time we have collected the crontab below to deal with rare issues of slowly collecting cpu / mem / disk exhausting issues. These issues may or may not be present any more. Please ignore issues which might have been fixed years ago.
In detail:
1. core dump file size:
in our setup the asterisk creates core dumps every now and then. The fact that the asterisk fails with a c memory issue and restarts is fine for us. The actual issue is that the coredumps are ~200MB in size and over time accumulate to a lot of disk space usage. We have solved this by deleting old core dumps:
15 1 * * * root find /var/lib/asterisk/ -name “core.*” -mtime +1 -delete >/dev/null 2>&1
2. update script stuck and using lots of cpu:
The update_tc in our vitalpbx2 installations maybe once a month or every two months the script completely stucks, never terminates and saturates one cpu core completely. We have solved it by killing the script when running too long:
15 * * * * root killall --older-than 1h update_tc
3. collection of cdrs over time disk usage:
The disk usage over time of the cdrs inside the database can collect multiple gbs of data. (hundred thousands of calls)
We solved this by having a fixed timeframe of data retention and deleting older records from the database:
15 * * * * root mysql -e “DELETE asterisk.cdr FROM asterisk.cdr where tenant = ‘vitalpbx’ and calldate < DATE_SUB(NOW(), INTERVAL 30 DAY) LIMIT 10000;”
15 * * * * root mysql -e “DELETE asterisk.cel FROM asterisk.cel where eventtime < DATE_SUB(NOW(), INTERVAL 30 DAY) LIMIT 10000;”
full crontab content:
2020-xx-xx sj cleanup core dumps of asterisk, can take up huge amounts of space
15 1 * * * root find /var/lib/asterisk/ -name “core.*” -mtime +1 -delete >/dev/null 2>&1
2022-xx-xx sj kill stuck update script, if running, happens rarely once a month maybe and causes high load
15 * * * * root killall --older-than 1h update_tc
2022-03-31 sj delete old cdrs / sels in the database, if present
15 * * * * root mysql -e “DELETE asterisk.cdr FROM asterisk.cdr where tenant = ‘vitalpbx’ and calldate < DATE_SUB(NOW(), INTERVAL 30 DAY) LIMIT 10000;”
15 * * * * root mysql -e “DELETE asterisk.cel FROM asterisk.cel where eventtime < DATE_SUB(NOW(), INTERVAL 30 DAY) LIMIT 10000;”
Cheers and have a great christmas time! Sebastian