monitoring/scripts/defragtables.py
Adrian Schmutzler 7955e60f2f scripts: Add scripts to defragment MySQL tables
scripts/defragtables.py:
- If run without argument, all tables EXCEPT stats are defragmented
  (quick run)
- If run with argument e.g. "1", all table INCLUDING stats are
  defragmented (will take about one hour)

scripts/defragtable.py <space-separated list of tables>:
- Defragments the specified tables; will crash if table does not
  exist

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2018-04-16 13:12:47 +02:00

23 lines
458 B
Python
Executable File

#!/usr/bin/python3
# Execute manually
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from ffmap.misc import defrag_all
from ffmap.mysqltools import FreifunkMySQL
import time
start_time = time.time()
mysql = FreifunkMySQL()
if(len(sys.argv)>1):
defrag_all(mysql,sys.argv[1])
else:
defrag_all(mysql,False)
mysql.close()
print("--- Total defrag duration: %.3f seconds ---" % (time.time() - start_time))