On Friday, April 15, 2011 at 4:39 AM, Raman Sehgal wrote:
I want some programmatic interface to condor,
So is there any API's of Condor available for C , C++ or Python.
There are a few different ways to do programmatic interaction with Condor. You have a SOAP API and good support for pipes from most of the command line executables. The best reference for interacting with Condor from your software is still probably this presentation from Todd and Matt circa 2006:
I believe there's a REST API in the works for the 7.6.x series, but I'm not 100% on that one.
Right now what i want to do is to get the number of idle jobs
, number of held jobs, number of running jobs etc, etc... in job queue.
So that these can be used somewhere else.
Tackling this from Python isn't too bad. You want to look at the output from:
condor_q -name <scheduler>
Specifically you want the last line of that, right:
0 jobs; 0 idle, 0 running, 0 held
To do this with Python:
r = re.compile(r'(\d+) jobs; (\d+) idle, (\d+) running, (\d+) held')
output = subprocess.Popen(['condor_q', '-name', schedd_name], stdout=subprocess.PIPE).communicate()
return [int(x) for x in r.search(output).groups()]
And the test:
>>> def condor_total_idle_running_held(schedd_name):
... r = re.compile(r'(\d+) jobs; (\d+) idle, (\d+) running, (\d+) held')
... output = subprocess.Popen(['condor_q', '-name', schedd_name], stdout=subprocess.PIPE).communicate()
... return [int(x) for x in r.search(output).groups()]
[0, 0, 0, 0]
Looks good. I now know total, idle, running and held jobs for this scheduler. Using the -name option on condor_q lets me get at any scheduler in my pool from any machine that has condor_q installed on it and a Condor configuration file that points to my pool's collector.
You can do this kind of thing with condor_status too.