Implementation of a monitoring system of interval cron tasks in Python. Useful for metrics tasks that need to run every n minutes.
Implementation requiring Plan and Crab.
####Installation
0. Install sqlite3
pip install -r requirements.txt- Crab specific steps:
2.1 Need to add a crabd.ini file in either ~/.crab or /etc/crab.
2.2 recreate crabdb.db:
`% sqlite3 crab.db < doc/schema.txt`
2.3 Download jquery and Font Awesome and install them on the res folder (specified in crabd.ini).
2.4 Port 8000 needs to be accesible on the machine (if using other port, need to change it in crabd.ini)
- Modify
config.yml(example included inconfig.yml.example). 3.1. Change theplanuser to the user in charge of running the crontab. 3.2. Change thepathin theplansection to the path where yourmodulesfolder will be located.
####Usage
- To add a task:
-
Create a folder on the
/modulesfolder. That task should have one entrypoint (one file run as__main__). (preferably namedmodule_main.py. -
Add that task on the
tasksection ofconfig.yml.- the
nameof the task should be the name of the folder you created for it. - task_specs should include the plan dsl for setting up a cron.
- If you need to import some task specific variables, you can either use the
environmentparamenter on the task config, or use theutils.get_task_config(task_name)that returns anEnvobject with the task config as attributes.
- the
-
Use
python start_cron.py writeto create the crontab with all the tasks, and start the crab dashboard. You can go tolocalhost:8000to see it in action. -
Use
python start_cron.py clearto empy the crontab, clean the/logsfolder and killcrabd
####Screenshots
By using the utils.crab_task context manager, every task gets sent to crab, along with their stdout and stderr.
You can see the history of each task.

