*** jobmond.py	2014-01-20 10:24:08.000000000 -0600
--- /usr/local/sbin/jobmond.py	2015-06-13 09:01:27.709623838 -0500
***************
*** 375,380 ****
--- 375,382 ----
          if not self.conf_dict.has_key( 'udp_send_channel' ):
              return None
  
+         bind_hostname = "no"
+ 
          for u in self.conf_dict[ 'udp_send_channel' ]:
  
              if u.has_key( 'mcast_join' ):
***************
*** 385,393 ****
  
                  ip = u['host'][0]
  
              port = u['port'][0]
  
!             udp_send_channels.append( ( ip, port ) )
  
          if len( udp_send_channels ) == 0:
              return None
--- 387,399 ----
  
                  ip = u['host'][0]
  
+             if u.has_key( 'bind_hostname' ):
+ 
+                 bind_hostname = u['bind_hostname'][0]
+ 
              port = u['port'][0]
  
!             udp_send_channels.append( ( ip, port, bind_hostname ) )
  
          if len( udp_send_channels ) == 0:
              return None
***************
*** 759,773 ****
  
          if GMOND_UDP_SEND_CHANNELS:
  
!             for c_ip, c_port  in GMOND_UDP_SEND_CHANNELS:
  
!                 metric_debug        = "[gmetric %s:%s] name: %s - val: %s - dmax: %s" %( str(c_ip), str(c_port), str( metricname ), str( metricval ), str( self.dmax ) )
  
                  debug_msg( 10, printTime() + ' ' + metric_debug)
  
                  if not self.gmetric_send_instances.has_key( (c_ip, c_port) ):
  
!                     self.gmetric_send_instances[ (c_ip, c_port) ] = Gmetric( c_ip, c_port )
  
                  self.gmetric_send_instances[ (c_ip, c_port) ].send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
  
--- 765,779 ----
  
          if GMOND_UDP_SEND_CHANNELS:
  
!             for c_ip, c_port, c_bind_hostname  in GMOND_UDP_SEND_CHANNELS:
  
!                 metric_debug        = "[gmetric %s:%s:%s] name: %s - val: %s - dmax: %s" %( str(c_ip), str(c_port), str(c_bind_hostname), str( metricname ), str( metricval ), str( self.dmax ) )
  
                  debug_msg( 10, printTime() + ' ' + metric_debug)
  
                  if not self.gmetric_send_instances.has_key( (c_ip, c_port) ):
  
!                     self.gmetric_send_instances[ (c_ip, c_port) ] = Gmetric( c_ip, c_port, c_bind_hostname )
  
                  self.gmetric_send_instances[ (c_ip, c_port) ].send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
  
***************
*** 1963,1978 ****
  GMETRIC_DEFAULT_HOST    = '127.0.0.1'
  GMETRIC_DEFAULT_PORT    = '8649'
  GMETRIC_DEFAULT_UNITS   = ''
  
  class Gmetric:
  
!     global GMETRIC_DEFAULT_HOST, GMETRIC_DEFAULT_PORT
  
      slope           = { 'zero' : 0, 'positive' : 1, 'negative' : 2, 'both' : 3, 'unspecified' : 4 }
      type            = ( '', 'string', 'uint16', 'int16', 'uint32', 'int32', 'float', 'double', 'timestamp' )
      protocol        = ( 'udp', 'multicast' )
  
!     def __init__( self, host=GMETRIC_DEFAULT_HOST, port=GMETRIC_DEFAULT_PORT ):
                  
          global GMETRIC_DEFAULT_TYPE
  
--- 1969,1985 ----
  GMETRIC_DEFAULT_HOST    = '127.0.0.1'
  GMETRIC_DEFAULT_PORT    = '8649'
  GMETRIC_DEFAULT_UNITS   = ''
+ GMETRIC_DEFAULT_BIND_HOSTNAME	= ''
  
  class Gmetric:
  
!     global GMETRIC_DEFAULT_HOST, GMETRIC_DEFAULT_PORT, GMETRIC_DEFAULT_BIND_HOSTNAME
  
      slope           = { 'zero' : 0, 'positive' : 1, 'negative' : 2, 'both' : 3, 'unspecified' : 4 }
      type            = ( '', 'string', 'uint16', 'int16', 'uint32', 'int32', 'float', 'double', 'timestamp' )
      protocol        = ( 'udp', 'multicast' )
  
!     def __init__( self, host=GMETRIC_DEFAULT_HOST, port=GMETRIC_DEFAULT_PORT, bind_hostname=GMETRIC_DEFAULT_BIND_HOSTNAME ):
                  
          global GMETRIC_DEFAULT_TYPE
  
***************
*** 1990,1995 ****
--- 1997,2007 ----
              # Set multicast options
              #
              self.socket.setsockopt( socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 20 )
+             self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_BINDTODEVICE, device )
+ 
+         if bind_hostname == 'yes':
+ 
+             self.socket.bind( (socket.getfqdn(), 0) )
  
          self.hostport   = ( host, int( port ) )
          self.slopestr   = 'both'
