Changeset 946


Ignore:
Timestamp:
01/17/14 11:05:42 (7 years ago)
Author:
ramonb
Message:

jobmond/jobmond.py:

  • reuse Gmetric classes instead of recreating them everytime
  • cleanup sockets if destroyed
  • see #176
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1/jobmond/jobmond.py

    r944 r946  
    697697                sys.exit( 1 )
    698698
     699        self.gmetric_send_instances = { }
     700
     701
     702    def __del__( self ):
     703
     704        for send_instance in self.gmetric_send_instances:
     705
     706            del send_instance
     707
    699708    def checkGmetricVersion( self ):
    700709
     
    757766                debug_msg( 10, printTime() + ' ' + metric_debug)
    758767
    759                 gm = Gmetric( c_ip, c_port )
    760 
    761                 gm.send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
     768                if not self.gmetric_send_instances.has_key( (c_ip, c_port) ):
     769
     770                    self.gmetric_send_instances[ (c_ip, c_port) ] = Gmetric( c_ip, c_port )
     771
     772                self.gmetric_send_instances[ (c_ip, c_port) ].send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
    762773
    763774        elif GMETRIC_TARGET:
     
    770781            debug_msg( 10, printTime() + ' ' + metric_debug)
    771782
    772             gm = Gmetric( GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT )
    773 
    774             gm.send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
     783            if not self.gmetric_send_instances.has_key( (GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT) ):
     784
     785                self.gmetric_send_instances[ (GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT) ] = Gmetric( GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT )
     786
     787            self.gmetric_send_instances[ (GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT) ].send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
    775788
    776789        else:
     
    19831996        self.tmax       = 60
    19841997
     1998    def __del__( self ):
     1999
     2000        self.socket.close()
     2001
    19852002    def checkHostProtocol( self, ip ):
    19862003
Note: See TracChangeset for help on using the changeset viewer.