mentat.module.cleanup module¶
This Mentat module is a script providing database and cache cleanup functions and features.
This script is implemented using the pyzenkit.zenscript
framework and
so it provides all of its core features. See the documentation for more in-depth
details.
It is further based on mentat.script.fetcher
module, which provides
database fetching and message post-processing capabilities.
Usage examples¶
# Display help message and exit.
mentat-cleanup.py --help
# Run in debug mode (enable output of debugging information to terminal).
mentat-cleanup.py --debug
# Run with increased logging level.
mentat-cleanup.py --log-level debug
Available script commands¶
cleanup
(default)Perform cleanup of configured database collections and directory caches.
Custom configuration¶
Custom command line options¶
--db-path dir-name
Path to database files (for disk usage measurements).
Type:
string
, default:/var/lib/postgresql
--simulate
Perform simulation, do not remove anything (flag).
Type:
boolean
, default:False
Available cleanup thresholds¶
3y
: items older than three years2y
: items older than two yearsy
: items older than one year9m
: items older than nine months6m
: items older than six months4m
: items older than four months3m
: items older than three months16w
: items older than sixteen weeks12w
: items older than twelwe weeks8w
: items older than eight weeks4w
: items older than four weeks2w
: items older than two weeksw
: items older than one week6d
: items older than six days5d
: items older than five days4d
: items older than four days3d
: items older than three days2d
: items older than two daysd
: items older than one day12h
: items older than twelve hours8h
: items older than eight hours6h
: items older than six hours4h
: items older than four hours3h
: items older than three hours2h
: items older than two hoursh
: items older than one hour
-
class
mentat.module.cleanup.
MentatCleanupScript
[source]¶ Bases:
mentat.script.fetcher.FetcherScript
Implementation of Mentat module (script) providing database and cache cleanup functions and features.
-
CONFIG_CACHES
= 'caches'¶
-
CONFIG_DB_PATH
= 'db_path'¶
-
CONFIG_EVENTS
= 'events'¶
-
CONFIG_RUNLOGS
= 'runlogs'¶
-
CONFIG_SIMULATE
= 'simulate'¶
-
CONFIG_TABLES
= 'tables'¶
-
-
mentat.module.cleanup.
SECS_YEAR
= 31556926¶ Number of seconds in a year (approximate).
-
mentat.module.cleanup.
THRESHOLDS
= {'12h': {'d': datetime.timedelta(seconds=43200), 'l': 'items older than twelve hours'}, '12w': {'d': datetime.timedelta(days=84), 'l': 'items older than twelve weeks'}, '16w': {'d': datetime.timedelta(days=112), 'l': 'items older than sixteen weeks'}, '2d': {'d': datetime.timedelta(days=2), 'l': 'items older than two days'}, '2h': {'d': datetime.timedelta(seconds=7200), 'l': 'items older than two hours'}, '2w': {'d': datetime.timedelta(days=14), 'l': 'items older than two weeks'}, '2y': {'d': datetime.timedelta(days=730, seconds=41852), 'l': 'items older than two years'}, '3d': {'d': datetime.timedelta(days=3), 'l': 'items older than three days'}, '3h': {'d': datetime.timedelta(seconds=10800), 'l': 'items older than three hours'}, '3m': {'d': datetime.timedelta(days=91, seconds=26831), 'l': 'items older than three months'}, '3y': {'d': datetime.timedelta(days=1095, seconds=62778), 'l': 'items older than three years'}, '4d': {'d': datetime.timedelta(days=4), 'l': 'items older than four days'}, '4h': {'d': datetime.timedelta(seconds=14400), 'l': 'items older than four hours'}, '4m': {'d': datetime.timedelta(days=121, seconds=64575), 'l': 'items older than four months'}, '4w': {'d': datetime.timedelta(days=28), 'l': 'items older than four weeks'}, '5d': {'d': datetime.timedelta(days=5), 'l': 'items older than five days'}, '6d': {'d': datetime.timedelta(days=6), 'l': 'items older than six days'}, '6h': {'d': datetime.timedelta(seconds=21600), 'l': 'items older than six hours'}, '6m': {'d': datetime.timedelta(days=182, seconds=53663), 'l': 'items older than six months'}, '8h': {'d': datetime.timedelta(seconds=28800), 'l': 'items older than eight hours'}, '8w': {'d': datetime.timedelta(days=56), 'l': 'items older than eight weeks'}, '9m': {'d': datetime.timedelta(days=273, seconds=80494), 'l': 'items older than nine months'}, 'd': {'d': datetime.timedelta(days=1), 'l': 'items older than one day'}, 'h': {'d': datetime.timedelta(seconds=3600), 'l': 'items older than one hour'}, 'w': {'d': datetime.timedelta(days=7), 'l': 'items older than one week'}, 'y': {'d': datetime.timedelta(days=365, seconds=20926), 'l': 'items older than one year'}}¶ List of possible cleanup thresholds.