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

Re: [HTCondor-users] Querying Startd classad from python bindings



On 10/20/2017 2:14 AM, Antonio Delgado Peris wrote:
> Dear all,
> 
> A (hopefully) quick question: does anybody know if there is a way to 
> directly query a Startd (or other) daemon to get its classads, like 
> 'condor_status -direct' does?
> 

Yes, use method directQuery() in the Collector class.  This will not communicate with the Collector, but will go directly to the startd (or schedd), just like condor_status -direct.  

For example to directly query the startd on the local machine:

  import htcondor
  col = htcondor.Collector()
  ad = coll.directQuery(htcondor.AdTypes.Startd)
  print(ad)

And help details from the Python shell:

>>> help("htcondor.Collector.directQuery")
Help on method directQuery in htcondor.Collector:

htcondor.Collector.directQuery = directQuery(...) unbound htcondor.Collector method
    directQuery( (Collector)arg1, (DaemonTypes)daemon_type [, (str)name='' [, (list)projection=[] [, (str)statistics='']]]) -> object :
        Query a given daemon directly instead of returning a collector ad.
        This may return more up-to-date or detailed information than what is in the collector.
        :param daemon_type: Type of daemon; must be from the DaemonTypes enum.
        :param name: Name of daemon to locate.  If not specified, it searches for the local daemon.
        :param projection: A list of attributes; if specified, the returned ads will be projected along these attributes.
        :param statistics: A list of additional statistics to return, if the remote daemon has any.
        :return: The ad of the matching daemon, from the daemon itself.

For gory details, here is the development ticket that added this functionality:
  https://htcondor-wiki.cs.wisc.edu/index.cgi/tktview?tn=4843

Hope this helps,
Todd