CPU% steady at 100%

My system is super slow. Looking at htop I see the following command is running around 170% CPU

/usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pic --socket=/var/lib/mysql/mysql.sock

Reboot took care of it for a bit but then it came right back.

V15 FreePBX Distro

MariaDB [(none)]> SHOW PROCESSLIST\G;
*************************** 1. row ***************************
      Id: 208
    User: freepbxuser
    Host: localhost:45466
      db: asterisk
 Command: Sleep
    Time: 6513
   State:
    Info: NULL
Progress: 0.000
*************************** 2. row ***************************
      Id: 211
    User: freepbxuser
    Host: localhost:45478
      db: asterisk
 Command: Sleep
    Time: 6510
   State:
    Info: NULL
Progress: 0.000
*************************** 3. row ***************************
      Id: 218
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 6501
   State:
    Info: NULL
Progress: 0.000
*************************** 4. row ***************************
      Id: 236
    User: freepbxuser
    Host: localhost:45640
      db: asterisk
 Command: Sleep
    Time: 6490
   State:
    Info: NULL
Progress: 0.000
*************************** 5. row ***************************
      Id: 427
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 6. row ***************************
      Id: 429
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '38464'
Progress: 0.000
*************************** 7. row ***************************
      Id: 447
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 8. row ***************************
      Id: 448
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '38867'
Progress: 0.000
*************************** 9. row ***************************
      Id: 520
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 10. row ***************************
      Id: 523
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '39153'
Progress: 0.000
*************************** 11. row ***************************
      Id: 606
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 12. row ***************************
      Id: 607
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '39406'
Progress: 0.000
*************************** 13. row ***************************
      Id: 614
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 14. row ***************************
      Id: 616
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '39409'
Progress: 0.000
*************************** 15. row ***************************
      Id: 631
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 16. row ***************************
      Id: 634
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '39463'
Progress: 0.000
*************************** 17. row ***************************
      Id: 729
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 18. row ***************************
      Id: 730
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '40579'
Progress: 0.000
*************************** 19. row ***************************
      Id: 844
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 20. row ***************************
      Id: 848
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '41416'
Progress: 0.000
*************************** 21. row ***************************
      Id: 1088
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 22. row ***************************
      Id: 1092
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '44304'
Progress: 0.000
*************************** 23. row ***************************
      Id: 1100
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 24. row ***************************
      Id: 1101
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '44305'
Progress: 0.000
*************************** 25. row ***************************
      Id: 1142
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 26. row ***************************
      Id: 1145
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '44355'
Progress: 0.000
*************************** 27. row ***************************
      Id: 1151
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 28. row ***************************
      Id: 1153
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Opening tables
    Info: SELECT * FROM sms_media WHERE `mid` = '44392'
Progress: 0.000
*************************** 29. row ***************************
      Id: 1158
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 1
   State:
    Info: NULL
Progress: 0.000
*************************** 30. row ***************************
      Id: 1159
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 1
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '44485'
Progress: 0.000
*************************** 31. row ***************************
      Id: 1166
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 32. row ***************************
      Id: 1168
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '44507'
Progress: 0.000
*************************** 33. row ***************************
      Id: 1237
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 1
   State:
    Info: NULL
Progress: 0.000
*************************** 34. row ***************************
      Id: 1242
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 1
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '45535'
Progress: 0.000
*************************** 35. row ***************************
      Id: 1254
    User: freepbxuser
    Host: localhost:52468
      db: asterisk
 Command: Sleep
    Time: 4375
   State:
    Info: NULL
Progress: 0.000
*************************** 36. row ***************************
      Id: 1371
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 37. row ***************************
      Id: 1373
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '47897'
Progress: 0.000
*************************** 38. row ***************************
      Id: 1655
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 39. row ***************************
      Id: 1664
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '50116'
Progress: 0.000
*************************** 40. row ***************************
      Id: 1671
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 41. row ***************************
      Id: 1675
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '50118'
Progress: 0.000
*************************** 42. row ***************************
      Id: 1749
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 43. row ***************************
      Id: 1756
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '50333'
Progress: 0.000
*************************** 44. row ***************************
      Id: 1865
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 0
   State:
    Info: NULL
Progress: 0.000
*************************** 45. row ***************************
      Id: 1868
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Sending data
    Info: SELECT * FROM sms_media WHERE `mid` = '50516'
Progress: 0.000
*************************** 46. row ***************************
      Id: 1906
    User: freepbxuser
    Host: localhost
      db: asteriskcdrdb
 Command: Sleep
    Time: 50
   State:
    Info: NULL
Progress: 0.000
*************************** 47. row ***************************
      Id: 1937
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 381
   State:
    Info: NULL
Progress: 0.000
*************************** 48. row ***************************
      Id: 1938
    User: freepbxuser
    Host: localhost
      db: asteriskcdrdb
 Command: Sleep
    Time: 3016
   State:
    Info: NULL
Progress: 0.000
*************************** 49. row ***************************
      Id: 2149
    User: freepbxuser
    Host: localhost
      db: asteriskcdrdb
 Command: Sleep
    Time: 12
   State:
    Info: NULL
Progress: 0.000
*************************** 50. row ***************************
      Id: 3074
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Sleep
    Time: 16
   State:
    Info: NULL
Progress: 0.000
*************************** 51. row ***************************
      Id: 3078
    User: root
    Host: localhost
      db: NULL
 Command: Query
    Time: 0
   State: NULL
    Info: SHOW PROCESSLIST
Progress: 0.000
*************************** 52. row ***************************
      Id: 3079
    User: freepbxuser
    Host: localhost
      db: asterisk
 Command: Query
    Time: 0
   State: Copying to tmp table
    Info: SELECT sm.* FROM sms_messages sm, sms_routing sr WHERE sr.uid = '85' AND (sm.from = sr.did OR sm.to
Progress: 0.000
52 rows in set (0.00 sec)

Please try this