[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] On the output of condor_userprio -l

On 6/20/11 8:06 AM, Matthew Farrellee wrote:
On 06/20/2011 07:31 AM, Mark Calleja wrote:
Hi chaps,

I'd like to script against the output of "condor_userprio -l", and I
notice that it's made up of a number of records of the form (where X is
an integer starting from 1):

NameX = ...
PriorityX = ...
ResourcesUsedX = ...
WeightedResourcesUsedX = ...
AccumulatedUsageX = ...
WeightedAccumulatedUsageX = ...
BeginUsageTimeX = ...
LastUsageTimeX = ...
PriorityFactorX = ...

Would anyone in the Condor team vouch for how fixed in stone this format
is, i.e. the number of properties per record (always these nine?), the
order these properties appear in (it seems constant), and the constancy
of these names (how liable are they to change?). I'm currently using


Those attributes (sans WeightedResourcesUsed) have been around since '98. You should expect the set to increase. Decreasing is unlikely. You should not expect the order to be consistent. The AttrX format has been around for a long time ('98) and will likely stay the same until nested ClassAds start to be used, possibly 7.7 or 7.9. Though, it will be possible to maintain the two formats during a transition period, e.g. to let old userprio work against new negotiators.

In case it is of any help, I happen to have some python code lying around that reads the output of condor_userprio -l and extracts information into a python dictionary:

def ReadUsageNew(lines,usage_hash):
    # this reads data in the format produced by condor_userprio -usage -l

    if type(lines) == type(""):
        lines = lines.split("\n")

        # keyed by record number
        name_record = {}
        usage_record = {}
    is_accounting_group_record = {}

        for line in lines:
                fields = line.split("=",1)
                if len(fields) < 2: continue

                attribute = fields[0].strip()
                value = fields[1].strip()

                pos = len(attribute)
                while pos > 0 and (attribute[pos-1] in string.digits):
                        pos -= 1
                if pos == len(attribute):
                record_num = long(attribute[pos:])
                attribute = attribute[:pos]

                if value and value[0] == "\"" and value[-1] == "\"":
                        value = value[1:-1]

                if attribute == "Name":
                        name_record[record_num] = value
                elif attribute == "WeightedAccumulatedUsage":
                        usage_record[record_num] = float(value)/3600.0
                elif attribute == "AccumulatedUsage":
                        if not usage_record.has_key(record_num):
usage_record[record_num] = float(value)/3600.0
        elif attribute == "IsAccountingGroup":
            if( value.lower() == "true" ):
                is_accounting_group_record[record_num] = 1

        for record_num,name in name_record.items():
        if is_accounting_group_record.has_key(record_num):
            # For now, ignore all accounting group records.
            # Only pay attention to individuals (within groups).
            # Otherwise, we double-count.
            # Eventually, we could add a report that summarizes
            # by accounting group.
                usage = usage_record[record_num]
        if not usage_hash.has_key(name):
            usage_hash[name] = 0
                usage_hash[name] += usage