Python-License-LoadSensor
Introduction
This method uses a resource and a load sensor to monitor the number of free licenses. The script calculates the total number of free licenses across a number of license servers and can reserve licenses for use outside of gridware.
If the load sensor reports that there are four licenses free then gridware will start four jobs. If on the next scheduling interval there are still four licenses free, i.e. the newly started programs haven't claimed a license yet, gridware will start another four jobs. To avoid this you can increase the scheduling interval using or use the trick in the script below which effectively one report the real number of free licenses at 4*scheduling interval, thus slowing down the rate of just the jobs that require this license.
qconf -msconf
Python Script to check licenses
#!/usr/bin/python -u # Important stdout must be un-buffered hence the -u command line option to python import os, re, string,sys,datetime LM_LICENSE_FILE="1717@server1:1717@server2" lmstat="/usr/local/bin/lmstat" features=["license1","license2"] #How many licenses to reserve for use outside of gridware reserve=3 while (1): inputString=sys.stdin.readline() if string.strip(inputString)=="quit": sys.exit(1) usage={} licenses=os.popen("%s -a -c %s" % (lmstat, LM_LICENSE_FILE)) for line in licenses: for feature in features: if re.search(feature, line): m=re.findall("([0-9]+) license", line) if m: free=int(m[0])-int(m[1]) if usage.has_key(feature): usage[feature]=usage[feature]+free else: usage[feature]=free print "begin" for key in usage.keys(): free=usage[key]-reserve print "global:%s:%d" % (key, free) print "end"