当前位置: 首页>>代码示例>>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;未经允许,请勿转载。