Changeset 785 for branches/0.4/jobmond/jobmond.py
- Timestamp:
- 04/04/13 16:05:42 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/jobmond/jobmond.py
r784 r785 1517 1517 """Setup appropriate variables""" 1518 1518 1519 self.jobs = { }1520 self.timeoffset 1521 self.dp = DataProcessor()1519 self.jobs = { } 1520 self.timeoffset = 0 1521 self.dp = DataProcessor() 1522 1522 1523 1523 self.initPbsQuery() … … 1525 1525 def initPbsQuery( self ): 1526 1526 1527 self.pq 1527 self.pq = None 1528 1528 1529 1529 if( BATCH_SERVER ): 1530 1530 1531 self.pq 1531 self.pq = PBSQuery( BATCH_SERVER ) 1532 1532 else: 1533 self.pq 1533 self.pq = PBSQuery() 1534 1534 1535 1535 try: … … 1546 1546 """Gather all data on current jobs in Torque""" 1547 1547 1548 joblist = {}1549 self.cur_time = 01548 joblist = {} 1549 self.cur_time = 0 1550 1550 1551 1551 try: 1552 1552 joblist = self.pq.getjobs() 1553 self.cur_time 1553 self.cur_time = time.time() 1554 1554 1555 1555 except PBSError, detail: … … 1561 1561 1562 1562 for name, attrs in joblist.items(): 1563 display_queue 1564 job_id 1565 1566 name 1567 queue 1563 display_queue = 1 1564 job_id = name.split( '.' )[0] 1565 1566 name = self.getAttr( attrs, 'Job_Name' ) 1567 queue = self.getAttr( attrs, 'queue' ) 1568 1568 1569 1569 if QUEUE: … … 1580 1580 1581 1581 owner = self.getAttr( attrs, 'Job_Owner' ).split( '@' )[0] 1582 requested_time 1583 requested_memory 1584 1585 mynoderequest 1586 1587 ppn 1582 requested_time = self.getAttr( attrs, 'Resource_List.walltime' ) 1583 requested_memory = self.getAttr( attrs, 'Resource_List.mem' ) 1584 1585 mynoderequest = self.getAttr( attrs, 'Resource_List.nodes' ) 1586 1587 ppn = '' 1588 1588 1589 1589 if mynoderequest.find( ':' ) != -1 and mynoderequest.find( 'ppn' ) != -1: 1590 1590 1591 mynoderequest_fields 1591 mynoderequest_fields = mynoderequest.split( ':' ) 1592 1592 1593 1593 for mynoderequest_field in mynoderequest_fields: … … 1595 1595 if mynoderequest_field.find( 'ppn' ) != -1: 1596 1596 1597 ppn 1598 1599 status 1597 ppn = mynoderequest_field.split( 'ppn=' )[1] 1598 1599 status = self.getAttr( attrs, 'job_state' ) 1600 1600 1601 1601 if status in [ 'Q', 'R' ]: … … 1603 1603 jobs_processed.append( job_id ) 1604 1604 1605 queued_timestamp 1605 queued_timestamp = self.getAttr( attrs, 'ctime' ) 1606 1606 1607 1607 if status == 'R': 1608 1608 1609 start_timestamp 1610 nodes 1611 1612 nodeslist 1609 start_timestamp = self.getAttr( attrs, 'mtime' ) 1610 nodes = self.getAttr( attrs, 'exec_host' ).split( '+' ) 1611 1612 nodeslist = do_nodelist( nodes ) 1613 1613 1614 1614 if DETECT_TIME_DIFFS: … … 1620 1620 if int( start_timestamp ) > int( int( self.cur_time ) + int( self.timeoffset ) ): 1621 1621 1622 self.timeoffset 1622 self.timeoffset = int( int(start_timestamp) - int(self.cur_time) ) 1623 1623 1624 1624 elif status == 'Q': … … 1636 1636 # 1637 1637 1638 start_timestamp 1639 count_mynodes 1638 start_timestamp = '' 1639 count_mynodes = 0 1640 1640 1641 1641 for node in mynoderequest.split( '+' ): … … 1643 1643 # Just grab the {node_count|hostname} part and ignore properties 1644 1644 # 1645 nodepart = node.split( ':' )[0]1645 nodepart = node.split( ':' )[0] 1646 1646 1647 1647 # Let's assume a node_count value 1648 1648 # 1649 numeric_node 1649 numeric_node = 1 1650 1650 1651 1651 # Chop the value up into characters … … 1657 1657 if letter not in string.digits: 1658 1658 1659 numeric_node 1659 numeric_node = 0 1660 1660 1661 1661 # If this is a hostname, just count this as one (1) node … … 1663 1663 if not numeric_node: 1664 1664 1665 count_mynodes 1665 count_mynodes = count_mynodes + 1 1666 1666 else: 1667 1667 … … 1670 1670 # 1671 1671 try: 1672 count_mynodes 1672 count_mynodes = count_mynodes + int( nodepart ) 1673 1673 1674 1674 except ValueError, detail: … … 1683 1683 debug_msg( 10, 'attrs = ' + str( attrs ) ) 1684 1684 1685 nodeslist = str( count_mynodes )1685 nodeslist = str( count_mynodes ) 1686 1686 else: 1687 start_timestamp 1688 nodeslist = ''1687 start_timestamp = '' 1688 nodeslist = '' 1689 1689 1690 1690 myAttrs = { } 1691 1691 1692 myAttrs[ 'name' ] = str( name )1693 myAttrs[ 'queue' ] = str( queue )1694 myAttrs[ 'owner' ] = str( owner )1695 myAttrs[ 'requested_time' ] 1696 myAttrs[ 'requested_memory' ] 1697 myAttrs[ 'ppn' ] = str( ppn )1698 myAttrs[ 'status' ] = str( status )1699 myAttrs[ 'start_timestamp' ] 1700 myAttrs[ 'queued_timestamp' ] 1701 myAttrs[ 'reported' ] = str( int( int( self.cur_time ) + int( self.timeoffset ) ) )1702 myAttrs[ 'nodes' ] = nodeslist1703 myAttrs[ 'domain' ] = fqdn_parts( socket.getfqdn() )[1]1692 myAttrs[ 'name' ] = str( name ) 1693 myAttrs[ 'queue' ] = str( queue ) 1694 myAttrs[ 'owner' ] = str( owner ) 1695 myAttrs[ 'requested_time' ] = str( requested_time ) 1696 myAttrs[ 'requested_memory' ] = str( requested_memory ) 1697 myAttrs[ 'ppn' ] = str( ppn ) 1698 myAttrs[ 'status' ] = str( status ) 1699 myAttrs[ 'start_timestamp' ] = str( start_timestamp ) 1700 myAttrs[ 'queued_timestamp' ] = str( queued_timestamp ) 1701 myAttrs[ 'reported' ] = str( int( int( self.cur_time ) + int( self.timeoffset ) ) ) 1702 myAttrs[ 'nodes' ] = nodeslist 1703 myAttrs[ 'domain' ] = fqdn_parts( socket.getfqdn() )[1] 1704 1704 myAttrs[ 'poll_interval' ] = str( BATCH_POLL_INTERVAL ) 1705 1705 1706 1706 if self.jobDataChanged( self.jobs, job_id, myAttrs ) and myAttrs['status'] in [ 'R', 'Q' ]: 1707 1707 1708 self.jobs[ job_id ] 1708 self.jobs[ job_id ] = myAttrs 1709 1709 1710 1710 for id, attrs in self.jobs.items():
Note: See TracChangeset
for help on using the changeset viewer.