1 | *** jobmond.py 2014-01-20 10:24:08.000000000 -0600 |
---|
2 | --- /usr/local/sbin/jobmond.py 2015-06-13 09:01:27.709623838 -0500 |
---|
3 | *************** |
---|
4 | *** 375,380 **** |
---|
5 | --- 375,382 ---- |
---|
6 | if not self.conf_dict.has_key( 'udp_send_channel' ): |
---|
7 | return None |
---|
8 | |
---|
9 | + bind_hostname = "no" |
---|
10 | + |
---|
11 | for u in self.conf_dict[ 'udp_send_channel' ]: |
---|
12 | |
---|
13 | if u.has_key( 'mcast_join' ): |
---|
14 | *************** |
---|
15 | *** 385,393 **** |
---|
16 | |
---|
17 | ip = u['host'][0] |
---|
18 | |
---|
19 | port = u['port'][0] |
---|
20 | |
---|
21 | ! udp_send_channels.append( ( ip, port ) ) |
---|
22 | |
---|
23 | if len( udp_send_channels ) == 0: |
---|
24 | return None |
---|
25 | --- 387,399 ---- |
---|
26 | |
---|
27 | ip = u['host'][0] |
---|
28 | |
---|
29 | + if u.has_key( 'bind_hostname' ): |
---|
30 | + |
---|
31 | + bind_hostname = u['bind_hostname'][0] |
---|
32 | + |
---|
33 | port = u['port'][0] |
---|
34 | |
---|
35 | ! udp_send_channels.append( ( ip, port, bind_hostname ) ) |
---|
36 | |
---|
37 | if len( udp_send_channels ) == 0: |
---|
38 | return None |
---|
39 | *************** |
---|
40 | *** 759,773 **** |
---|
41 | |
---|
42 | if GMOND_UDP_SEND_CHANNELS: |
---|
43 | |
---|
44 | ! for c_ip, c_port in GMOND_UDP_SEND_CHANNELS: |
---|
45 | |
---|
46 | ! metric_debug = "[gmetric %s:%s] name: %s - val: %s - dmax: %s" %( str(c_ip), str(c_port), str( metricname ), str( metricval ), str( self.dmax ) ) |
---|
47 | |
---|
48 | debug_msg( 10, printTime() + ' ' + metric_debug) |
---|
49 | |
---|
50 | if not self.gmetric_send_instances.has_key( (c_ip, c_port) ): |
---|
51 | |
---|
52 | ! self.gmetric_send_instances[ (c_ip, c_port) ] = Gmetric( c_ip, c_port ) |
---|
53 | |
---|
54 | self.gmetric_send_instances[ (c_ip, c_port) ].send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units ) |
---|
55 | |
---|
56 | --- 765,779 ---- |
---|
57 | |
---|
58 | if GMOND_UDP_SEND_CHANNELS: |
---|
59 | |
---|
60 | ! for c_ip, c_port, c_bind_hostname in GMOND_UDP_SEND_CHANNELS: |
---|
61 | |
---|
62 | ! 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 ) ) |
---|
63 | |
---|
64 | debug_msg( 10, printTime() + ' ' + metric_debug) |
---|
65 | |
---|
66 | if not self.gmetric_send_instances.has_key( (c_ip, c_port) ): |
---|
67 | |
---|
68 | ! self.gmetric_send_instances[ (c_ip, c_port) ] = Gmetric( c_ip, c_port, c_bind_hostname ) |
---|
69 | |
---|
70 | self.gmetric_send_instances[ (c_ip, c_port) ].send( str( metricname ), str( metricval ), str( self.dmax ), valtype, units ) |
---|
71 | |
---|
72 | *************** |
---|
73 | *** 1963,1978 **** |
---|
74 | GMETRIC_DEFAULT_HOST = '127.0.0.1' |
---|
75 | GMETRIC_DEFAULT_PORT = '8649' |
---|
76 | GMETRIC_DEFAULT_UNITS = '' |
---|
77 | |
---|
78 | class Gmetric: |
---|
79 | |
---|
80 | ! global GMETRIC_DEFAULT_HOST, GMETRIC_DEFAULT_PORT |
---|
81 | |
---|
82 | slope = { 'zero' : 0, 'positive' : 1, 'negative' : 2, 'both' : 3, 'unspecified' : 4 } |
---|
83 | type = ( '', 'string', 'uint16', 'int16', 'uint32', 'int32', 'float', 'double', 'timestamp' ) |
---|
84 | protocol = ( 'udp', 'multicast' ) |
---|
85 | |
---|
86 | ! def __init__( self, host=GMETRIC_DEFAULT_HOST, port=GMETRIC_DEFAULT_PORT ): |
---|
87 | |
---|
88 | global GMETRIC_DEFAULT_TYPE |
---|
89 | |
---|
90 | --- 1969,1985 ---- |
---|
91 | GMETRIC_DEFAULT_HOST = '127.0.0.1' |
---|
92 | GMETRIC_DEFAULT_PORT = '8649' |
---|
93 | GMETRIC_DEFAULT_UNITS = '' |
---|
94 | + GMETRIC_DEFAULT_BIND_HOSTNAME = '' |
---|
95 | |
---|
96 | class Gmetric: |
---|
97 | |
---|
98 | ! global GMETRIC_DEFAULT_HOST, GMETRIC_DEFAULT_PORT, GMETRIC_DEFAULT_BIND_HOSTNAME |
---|
99 | |
---|
100 | slope = { 'zero' : 0, 'positive' : 1, 'negative' : 2, 'both' : 3, 'unspecified' : 4 } |
---|
101 | type = ( '', 'string', 'uint16', 'int16', 'uint32', 'int32', 'float', 'double', 'timestamp' ) |
---|
102 | protocol = ( 'udp', 'multicast' ) |
---|
103 | |
---|
104 | ! def __init__( self, host=GMETRIC_DEFAULT_HOST, port=GMETRIC_DEFAULT_PORT, bind_hostname=GMETRIC_DEFAULT_BIND_HOSTNAME ): |
---|
105 | |
---|
106 | global GMETRIC_DEFAULT_TYPE |
---|
107 | |
---|
108 | *************** |
---|
109 | *** 1990,1995 **** |
---|
110 | --- 1997,2007 ---- |
---|
111 | # Set multicast options |
---|
112 | # |
---|
113 | self.socket.setsockopt( socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 20 ) |
---|
114 | + self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_BINDTODEVICE, device ) |
---|
115 | + |
---|
116 | + if bind_hostname == 'yes': |
---|
117 | + |
---|
118 | + self.socket.bind( (socket.getfqdn(), 0) ) |
---|
119 | |
---|
120 | self.hostport = ( host, int( port ) ) |
---|
121 | self.slopestr = 'both' |
---|