Changeset 707 for branches/0.4/jobmond


Ignore:
Timestamp:
03/21/13 18:05:40 (11 years ago)
Author:
ramonb
Message:
  • support for multiple udp send channels
File:
1 edited

Legend:

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

    r705 r707  
    353353
    354354        self.checkConfDict()
    355         return self.conf_dict[ 'udp_send_channel' ]
     355
     356        udp_send_channels = [ ] # IP:PORT
     357
     358        if not self.conf_dict.has_key( 'udp_send_channel' ):
     359            return None
     360
     361        for u in self.conf_dict[ 'udp_send_channel' ]:
     362
     363            if u.has_key( 'mcast_join' ):
     364
     365                ip = u['mcast_join'][0]
     366
     367            elif u.has_key( 'host' ):
     368
     369                ip = u['host'][0]
     370
     371            port = u['port'][0]
     372
     373            udp_send_channels.append( ( ip, port ) )
     374
     375        if len( udp_send_channels ) == 0:
     376            return None
     377
     378        return udp_send_channels
    356379
    357380    def getSectionLastOption( self, section, option ):
     
    459482    global BATCH_API, QUEUE, GMETRIC_TARGET, USE_SYSLOG
    460483    global SYSLOG_LEVEL, SYSLOG_FACILITY, GMETRIC_BINARY
    461     global METRIC_MAX_VAL_LEN
     484    global METRIC_MAX_VAL_LEN, GMOND_UDP_SEND_CHANNELS
    462485
    463486    DEBUG_LEVEL = cfg.getint( 'DEFAULT', 'DEBUG_LEVEL' )
     
    531554        GMOND_CONF          = '/etc/ganglia/gmond.conf'
    532555
    533     ganglia_cfg     = GangliaConfigParser( GMOND_CONF )
    534 
    535     # Let's try to find the GMETRIC_TARGET ourselves first from GMOND_CONF
    536     #
    537     gmetric_dest_ip = ganglia_cfg.getStr( 'udp_send_channel', 'mcast_join' )
    538 
    539     if not gmetric_dest_ip:
    540 
    541         # Maybe unicast target then
    542         #
    543         gmetric_dest_ip = ganglia_cfg.getStr( 'udp_send_channel', 'host' )
    544 
    545     gmetric_dest_port   = ganglia_cfg.getStr( 'udp_send_channel', 'port' )
    546 
    547     #TODO: use multiple udp send channels (if found)
    548     if gmetric_dest_ip and gmetric_dest_port:
    549 
    550         GMETRIC_TARGET  = '%s:%s' %( gmetric_dest_ip, gmetric_dest_port )
    551     else:
     556    ganglia_cfg             = GangliaConfigParser( GMOND_CONF )
     557    GMETRIC_TARGET          = None
     558
     559    GMOND_UDP_SEND_CHANNELS = ganglia_cfg.getUdpSendChannels()
     560
     561    if not GMOND_UDP_SEND_CHANNELS:
    552562
    553563        debug_msg( 0, "WARNING: Can't parse udp_send_channel from: '%s' - Trying: %s" %( GMOND_CONF, JOBMOND_CONF ) )
     
    637647            self.binary = binary
    638648
    639         if not self.binary and not GMETRIC_TARGET:
     649        if not self.binary and not GMETRIC_TARGET and not GMOND_UDP_SEND_CHANNELS:
    640650            self.binary = GMETRIC_BINARY
    641651
     
    649659        self.dmax = str( int( int( BATCH_POLL_INTERVAL ) * 2 ) )
    650660
    651         if GMOND_CONF and not GMETRIC_TARGET:
     661        if GMOND_CONF and not GMETRIC_TARGET and not GMOND_UDP_SEND_CHANNELS:
    652662
    653663            incompatible = self.checkGmetricVersion()
     
    706716        cmd = self.binary
    707717
    708         if GMETRIC_TARGET:
     718        if GMOND_UDP_SEND_CHANNELS:
     719
     720            for c_ip, c_port  in GMOND_UDP_SEND_CHANNELS:
     721
     722                metric_debug        = "[gmetric %s:%s] name: %s - val: %s - dmax: %s" %( str(c_ip), str(c_port), str( metricname ), str( metricval ), str( self.dmax ) )
     723
     724                debug_msg( 10, printTime() + ' ' + metric_debug)
     725
     726                gm = Gmetric( c_ip, c_port )
     727
     728                gm.send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units )
     729
     730        elif GMETRIC_TARGET:
    709731
    710732            GMETRIC_TARGET_HOST    = GMETRIC_TARGET.split( ':' )[0]
Note: See TracChangeset for help on using the changeset viewer.