Skip to content

Instantly share code, notes, and snippets.

@cinek810
Last active December 7, 2018 13:35
Show Gist options
  • Save cinek810/b86807f13cb5e990fea46ddc759f464e to your computer and use it in GitHub Desktop.
Save cinek810/b86807f13cb5e990fea46ddc759f464e to your computer and use it in GitHub Desktop.
Script for reingestion of specific jobs data (based on the resource code name and dates) to XDMoD (Interested? Check whole article:https://funinit.wordpress.com/2018/11/23/notes-from-the-xdmod-patch-mitigating-the-issue-with-overestimated-wall-time-for-suspended-jobs/)
#!/bin/bash
# Author: Marcin Stolarek
#############################
START="2018-11-02"
END="2018-11-06"
RESOURCE="Cluster"
MYSQL_REMOVE=$(mktemp)
cat << END > $MYSQL_REMOVE
delete from mod_shredder.shredded_job_slurm where start_time > UNIX_TIMESTAMP('$START') and end_time < UNIX_TIMESTAMP('$END') and cluster_name = '$RESOURCE';
delete from mod_shredder.shredded_job where resource_name='$RESOURCE' and start_time > UNIX_TIMESTAMP('$START') and end_time < UNIX_TIMESTAMP('$END');
delete from mod_shredder.staging_job where resource_name='$RESOURCE' and start_time > UNIX_TIMESTAMP('$START') and end_time < UNIX_TIMESTAMP('$END');
delete from mod_hpcdb.hpcdb_jobs where resource_id=( SELECT resource_id FROM mod_hpcdb.hpcdb_resources where resource_code = "$RESOURCE" ) and start_time > UNIX_TIMESTAMP('$START') and end_time < UNIX_TIMESTAMP('$END');
delete from modw.jobfact where resource_id=( SELECT resource_id FROM mod_hpcdb.hpcdb_resources where resource_code = "$RESOURCE" ) and start_time > '$START' and end_time < '$END';
END
cat $MYSQL_REMOVE | mysql
/usr/bin/xdmod-ingestor --start-time "${START}" --end-time "${END}" --debug > /tmp/xdmod-ingestor-remove.debug
/usr/bin/xdmod-slurm-helper -r $RESOURCE --start-time "${START}T00:00:00" --end-time "${END}T00:00:00" --debug > /tmp/xdmod-slurm-helper.debug
/usr/bin/xdmod-ingestor --start-time "$START" --end-time "${END}" --debug > /tmp/xdmod-ingestor-add.debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment