當前位置: 首頁>>代碼示例>>Python>>正文


Python PBSQuery.PBSQuery類代碼示例

本文整理匯總了Python中PBSQuery.PBSQuery的典型用法代碼示例。如果您正苦於以下問題:Python PBSQuery類的具體用法?Python PBSQuery怎麽用?Python PBSQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PBSQuery類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: countppn

def countppn(queue):
    p = PBSQuery()
    p.new_data_structure()
    jobs = p.getjobs()
    nptot = 0
    for id in jobs:
        try:
            if jobs[id].queue[0] == queue and jobs[id].job_state[0] == 'R':
                np = jobs[id].Resource_List.nodes
                if 'ppn' not in np[0]:
                    np = 1
                else:
                    npptot = 0
		    ct = [m.start() for m in re.finditer('ppn', np[0])]
                    for val in ct:
                        char = np[0]
                        vals = val+4
                        valf = val+6
                        npp = char[vals:valf]
			npp = re.sub('[[email protected]#+:$]', '', npp)
                        npp = int(npp)
			npptot = npp + npptot
                    np = npptot
                nptot = np + nptot
        except PBSError, detail:
            print detail
        pass
開發者ID:sysmso,項目名稱:sysadmin,代碼行數:27,代碼來源:pbscpu.py

示例2: main

def main():
    """
    Main script.
    """

    options = {
        "jobid": ("The PBS_JOBID of the job for which we want information", None, "store", None),
        "information": (
            "Comma-separated list of the job info to print. " "Entries of the format input_key:output_key",
            None,
            "store",
            None,
        ),
    }
    opts = simple_option(options)

    if not opts.options.jobid:
        logger.error("jobid is a required option. Bailing.")
        sys.exit(1)

    pquery = PBSQuery()
    current_job = pquery.getjob(opts.options.jobid)

    s = transform_info(current_job, opts.options.information)

    print "\n".join(s)
開發者ID:wpoely86,項目名稱:vsc-jobs,代碼行數:26,代碼來源:qstat_wrapper.py

示例3: main

def main():
    pq = PBSQuery()
    nodedict = pq.getnodes()
    for nodename, node in sorted(nodedict.iteritems()):
        print nodename
        for k, v in node.iteritems():
            print k, v
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:7,代碼來源:pqnodes.py

示例4: main

def main():

  p = PBSQuery()
  p.new_data_structure()

  #job = p.getjob('2983215')
  #print job['substate']
  #print job.substate
  #print job.queue
  #print job.Resource_List
  #print job.Resource_List.nodes 
  #print job.Resource_List.arch 
  #print job.Variable_List.PBS_O_HOME

  l = ['np', 'state' ]
  node = p.getnode("gb-r5n1", l)
  print node.name, node['np']

  sys.exit(0)

  #nodes = p.getnodes(l)
  for id in nodes:
	print id

	try:
		print nodes[id].np
		print nodes[id].status.arch
		print nodes[id].status.uname
		print nodes[id].state
	except PBSError, detail:
		print detail
		pass
開發者ID:ronanp,項目名稱:ClusterInterface,代碼行數:32,代碼來源:new_interface.py

示例5: main

def main(args):
    """Main script."""

    options = {
        'nagios-check-interval-threshold': NAGIOS_CHECK_INTERVAL_THRESHOLD,
        'mail-report': ('mail a report to the hpc-admin list with job list for gracing or inactive users',
                        None, 'store_true', False),
    }
    opts = ExtendedSimpleOption(options)

    try:
        vsc_config = VscConfiguration()
        LdapQuery(vsc_config)

        grace_users = get_user_with_status('grace')
        inactive_users = get_user_with_status('inactive')

        pbs_query = PBSQuery()

        t = time.ctime()
        jobs = pbs_query.getjobs()  # we just get them all

        removed_queued = remove_queued_jobs(jobs, grace_users, inactive_users, opts.options.dry_run)
        removed_running = remove_running_jobs(jobs, inactive_users, opts.options.dry_run)

        if opts.options.mail_report and not opts.options.dry_run:
            if len(removed_queued) > 0 or len(removed_running) > 0:
                mail_report(t, removed_queued, removed_running)
    except Exception, err:
        logger.exception("critical exception caught: %s" % (err))
        opts.critical("Script failed in a horrible way")
        sys.exit(NAGIOS_EXIT_CRITICAL)
開發者ID:stdweird,項目名稱:vsc-jobs,代碼行數:32,代碼來源:pbs_check_inactive_user_jobs.py

示例6: pbs_handler

def pbs_handler(name):
    pbs = PBSQuery()
    jobs = pbs.getjobs()
    for jobid, jobinfo in jobs.iteritems():
        publish(jobid, jobinfo)
    publish_queue_state(pbs)
    return ""
開發者ID:dragz,項目名稱:torque-roll,代碼行數:7,代碼來源:pbsinfo.py

示例7: getModelServers

    def getModelServers():
        resultServers = []
        pQuery = PBSQuery()

        try:
            servers = pQuery.get_serverinfo()
            for serverName, pbsServer in servers.items():
                customServer = PBSServer(name=serverName)
                try:
                    customServer.state = TorqueService._listToStr(pbsServer[pbs.ATTR_status], '|')
                except KeyError:
                    pass
                try:
                    customServer.total_jobs = TorqueService._listToInt(pbsServer[pbs.ATTR_total])
                except KeyError:
                    pass
                try:
                    customServer.running_jobs = int(TorqueService._strToDict(pbsServer[pbs.ATTR_count][0])['Running'])
                except KeyError:
                    pass
                try:
                    customServer.queued_jobs = int(TorqueService._strToDict(pbsServer[pbs.ATTR_count][0])['Queued'])
                except KeyError:
                    pass
                try:
                    customServer.pbs_version = TorqueService._listToStr(pbsServer[pbs.ATTR_pbsversion], '|')
                except KeyError:
                    pass

                resultServers.append(customServer)
        except PBSError as pbsErr:
            print(pbsErr)

        return resultServers
開發者ID:dooodlesomething,項目名稱:PyPBS,代碼行數:34,代碼來源:torque_service.py

示例8: PBSManager

class PBSManager():

	def __init__(self):
	    self.p = PBSQuery()
	    self.queue = self.p.getqueue(survey)
	    self.jobs = self.p.getjobs()
	    self.nodes = self.p.getnodes_with_property(use_ressources)

	    self.queue_names = self.jobs.keys()

	    #print self.nodes
	    #print self.nodes['psr13']['ncpus']

	def jobs_running(self):

	    queue_status = self.queue['state_count'][0]

	    Transit, Queued, Held, Waiting, Running, Exiting = queue_status.split()

	    Queued = int(Queued.split(':')[1])
	    Running = int(Running.split(':')[1])
	    return Running, Queued


	def is_running(self, basefilename):

	    jobnames = []
	    for jobs_name in self.queue_names: 
	        job_info = self.jobs[jobs_name]
		jobnames.append(job_info["Job_Name"][0])

	    return (basefilename in jobnames)


	def get_stderr_path(self, basefilename):
	    stderr_path = os.path.join(logs_loc, "%s.err"%(basefilename))
	    if not os.path.exists(stderr_path):
		raise ValueError("Cannot find error log for job (%s): %s" % \
				(basefilename, stderr_path))
	    return stderr_path

	def had_errors(self, basefilename):    
	    try:
                errorlog = self.get_stderr_path(basefilename)
	    except ValueError:
	        errors = False
	    else:
	        if os.path.getsize(errorlog) > 0:
	            errors = True
		else:
		    errors = False
	    return errors

	def get_errors(self, basefilename):    
	    try:
		errorlog = self.get_stderr_path(basefilename)
	    except ValueError, e:
	        errors = str(e)
	    else:
開發者ID:gdesvignes,項目名稱:SPAN512,代碼行數:59,代碼來源:monitor_cluster.py

示例9: main

def main():
    pq = PBSQuery()
    print 'Server:',pq.server
    serverinfo = pq.get_serverinfo()
    for k, v in sorted(serverinfo.iteritems()):
        print k 
        for i, j in sorted(v.iteritems()):
            print i, j
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:8,代碼來源:pqserver.py

示例10: main

def main():
    pq = PBSQuery()
    jobsdict = pq.getjobs()
    for jobid, job in sorted(jobsdict.iteritems()):
        print jobid
        for k, v in job.iteritems():
            print "    ", k, v
        print ""
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:8,代碼來源:pqjobs.py

示例11: main

def main():
    pq = PBSQuery()
    queuedict = pq.getqueues()
    print queuedict
    for queuename, queue in sorted(queuedict.iteritems()):
        print queuename
        for k, v in queue.iteritems():
            print k, v
        print
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:9,代碼來源:pqqueues.py

示例12: getModelJobs

    def getModelJobs():
        """
        1. get jobs
        2. get users
        3. map each job to User and Queue
        4. save all jobs
        """
        resultJobs = []
        pQuery = PBSQuery()
        try:
            jobs = pQuery.getjobs()
            for jobName, pbsJob in jobs.items():
                customJob = PBSJob(jobId=jobName)
                try:
                    customJob.name = TorqueService._listToStr(pbsJob[pbs.ATTR_name], '|')
                except KeyError:
                    pass
                try:
                    customJob.owner = TorqueService._listToStr(pbsJob[pbs.ATTR_owner], '|')
                except KeyError:
                    pass
                try:
                    customJob.state = TorqueService._listToStr(pbsJob[pbs.ATTR_state], '|')
                except KeyError:
                    pass
                try:
                    customJob.queue_raw = TorqueService._listToStr(pbsJob[pbs.ATTR_queue], '|')
                except KeyError:
                    pass
                try:
                    customJob.start_time = datetime.fromtimestamp(TorqueService._listToInt(pbsJob[pbs.ATTR_start_time]))
                except KeyError:
                    pass
                try:
                    customJob.resource_cput = TorqueService._listToStr(pbsJob[pbs.ATTR_used]['cput'], '|')
                except KeyError:
                    pass
                try:
                    customJob.resource_mem = TorqueService._listToStr(pbsJob[pbs.ATTR_used]['mem'], '|')
                except KeyError:
                    pass
                try:
                    customJob.resource_vmem = TorqueService._listToStr(pbsJob[pbs.ATTR_used]['vmem'], '|')
                except KeyError:
                    pass
                try:
                    customJob.resource_walltime = TorqueService._listToStr(pbsJob[pbs.ATTR_used]['walltime'], '|')
                except KeyError:
                    pass

                resultJobs.append(customJob)
        except PBSError as pbsErr:
            print(pbsErr)

        return resultJobs
開發者ID:dooodlesomething,項目名稱:PyPBS,代碼行數:55,代碼來源:torque_service.py

示例13: __init__

 def __init__(self, server_name):
     p = PBSQuery(str(server_name))
     info = p.get_serverinfo().items()[0]
     self.name = info[0]
     self.p = p
     for k,v in info[1].items():
         if k.startswith('resources'):
             for i,j in v.items():
                 setattr(self, k + '_' + i, j[0])
         else:
             setattr(self, k, v[0]) 
開發者ID:VPAC,項目名稱:django-pbs,代碼行數:11,代碼來源:models.py

示例14: print_header

def print_header():
    # try connecting to the PBS server
    print "Content-Type: text/html"

    try:
        pbs  = PBSQuery(SERVER)
        jobs = pbs.getjobs()
#	ldin = ldap.open("192.168.0.90")
    except PBSError, error:
        print "<h1>Error connecting to PBS server:</h1><tt>",error,"</tt>"
        sys.exit(1)
開發者ID:mehr6666,項目名稱:hpc-cc,代碼行數:11,代碼來源:torquemon.py

示例15: getData

def getData():
    p=PBSQuery()
    nodes=p.getnodes()
    for node in nodes.keys():
        host=TorqueHost(node)
        try:
            host.setState(nodes[node]['state'])
        except:
            pass

        try:
            host.setSlots(int(nodes[node]['np'][0]))
        except:
            pass

        try:
            host.setSlotsUsed(len(nodes[node]['jobs']))
        except:
            host.setSlotsUsed(0)

        try:
            jobs=nodes[node]['status']['jobs'][0].split()
            host.setJobList(jobs)
        except:
            pass
        try:
            availmem=nodes[node]['status']['availmem'][0]
            host.setAvailMem(availmem)
        except:
            pass
        try:
            totalmem=nodes[node]['status']['totmem'][0]
            host.setTotalMem(totalmem)
        except:
            pass
        try:
            rectime=nodes[node]['status']['rectime'][0]
            host.setRecTime(rectime)
        except:
            pass
        try:
            loadave=nodes[node]['status']['loadave'][0]
            host.setLoadAve(loadave)
        except:
            pass
        try:
            netload=nodes[node]['status']['netload'][0]
            host.setNetLoad(netload)
        except:
            pass

        Hosts[host.Name] = host
開發者ID:riby,項目名稱:datacenter_monitoring,代碼行數:52,代碼來源:TorqueStatus.py


注:本文中的PBSQuery.PBSQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。