Skip to content

Instantly share code, notes, and snippets.

@cinek810
cinek810 / ansible-review-standard-noSpacesInTaskName.py
Created December 15, 2018 22:05
ansible-review standard checking if task name doesn't contain spaces (funinit.wordpress.com)
def check_task_name(candidate,setting):
result = Result(candidate.path)
with open(candidate.path, 'r') as f:
for (lineno, line) in enumerate(f):
inArray=line.split(" ")
try:
if inArray[1]=="name:" and len(inArray) > 3:
result.errors.append(Error(lineno+1,line))
except IndexError:
pass
@cinek810
cinek810 / xdmod-remove.sh
Last active December 13, 2018 16:37
Script developed for funinit.wordpress.com
#!/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');
@cinek810
cinek810 / reingest.sh
Last active December 7, 2018 13:35
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');
@cinek810
cinek810 / xdmod-suspended-overestimate.patch
Last active November 23, 2018 21:28
Patch for Open XDMoD mitigating the issue with suspended jobs wall time beeing overestimated(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/)
diff --git a/classes/OpenXdmod/Shredder.php b/classes/OpenXdmod/Shredder.php
index 1a55a57b..951baf48 100644
--- a/classes/OpenXdmod/Shredder.php
+++ b/classes/OpenXdmod/Shredder.php
@@ -810,6 +810,14 @@ class Shredder
$errorMessages[] = 'Job start time as after job end time.';
$valid = false;
}
+ elseif ( $startTime !== null
+ && $endTime != null
@cinek810
cinek810 / image.expand.exec.sh
Created October 1, 2018 14:50
image.expand.exec
--- ./libexec/cli/image.expand.exec 2018-10-01 09:50:15.000000000 -0400
+++ /cm/shared/apps/singularity/libexec/singularity/cli/image.expand.exec 2018-10-01 09:30:41.000000000 -0400
@@ -112,15 +112,32 @@
exit 1
fi
+message 1 "Create loop device"
+SINGULARITY_LOOP_DEVICE=$(losetup -f)
+if [ $? -ne 0 ]; then
+ exit 1
@cinek810
cinek810 / snow-grafana-proxy-lambda-end.py
Last active August 22, 2018 20:33
Tests for aws-lambda version of snow-grafana-proxy
if __name__ == "__main__":
#Test search_post
event={}
context=[]
print("Testin search_post function")
result=search_post(event,context)
print(result)
@cinek810
cinek810 / snow-grafana-proxy.yaml
Created July 19, 2018 19:24
snow-grafana-proxy.conf version 2 (for use in funinit.wordpress.com blog post)
service:
address: 127.0.0.1
port: 8095
logfile: /var/log/snow-grafana-proxy.log
loglevel: info
service-now:
instance:
url: https://instance.service-now.com
user: api-user
password: password
#Check gist description on https://funinit.wordpress.com/2018/06/27/ansible-role-used-as-plugin-for-simple-rest-api-services/
icinga2_api_uri: https://your.host:your_port/v1/objects/services/
icinga2_api_user: XXX
icinga2_api_password: XXX
icinga2_validate_certs: no
#!/bin/bash
# $1 - VM name
# $2 - resoure group
# Overcomplicated solution for https://funinit.wordpress.com/2018/05/03/resizing-vms-in-azure-sequel/
# Basically change the VM disk from Premium to Standard SKU to allow resize to Basic tier
# Assume one VM in Resource group
# Assume VM has one disk
NAME=$1
GROUP=$2
def resize_vm(cmd, resource_group_name, vm_name, size, no_wait=False):
vm = get_vm(cmd, resource_group_name, vm_name)
vm.hardware_profile.vm_size = size # pylint: disable=no-member
return set_vm(cmd, vm, no_wait)