Index: branches/0.4/jobmond/jobmond.py
===================================================================
--- branches/0.4/jobmond/jobmond.py	(revision 699)
+++ branches/0.4/jobmond/jobmond.py	(revision 700)
@@ -1691,22 +1691,8 @@
                 del self.jobs[ id ]
 
-#
-# Gmetric by Nick Galbreath - nickg(a.t)modp(d.o.t)com
-# Version 1.0 - 21-April2-2007
-# http://code.google.com/p/embeddedgmetric/
-#
-# Modified by: Ramon Bastiaans
-# For the Job Monarch Project, see: https://subtrac.sara.nl/oss/jobmonarch/
-#
-# added: DEFAULT_TYPE for Gmetric's
-# added: checkHostProtocol to determine if target is multicast or not
-# changed: allow default for Gmetric constructor
-# changed: allow defaults for all send() values except dmax
-#
-
 GMETRIC_DEFAULT_TYPE    = 'string'
 GMETRIC_DEFAULT_HOST    = '127.0.0.1'
 GMETRIC_DEFAULT_PORT    = '8649'
-GMETRIC_DEFAULT_UNITS    = ''
+GMETRIC_DEFAULT_UNITS   = ''
 
 class Gmetric:
@@ -1714,14 +1700,15 @@
     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' )
+    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
 
         self.prot       = self.checkHostProtocol( host )
-        self.msg    = xdrlib.Packer()
+        self.data_msg   = xdrlib.Packer()
+        self.meta_msg   = xdrlib.Packer()
         self.socket     = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
 
@@ -1747,5 +1734,5 @@
         MULTICAST_ADDRESS_MAX   = ( "239", "255", "255", "255" )
 
-        ip_fields           = ip.split( '.' )
+        ip_fields               = ip.split( '.' )
 
         if ip_fields >= MULTICAST_ADDRESS_MIN and ip_fields <= MULTICAST_ADDRESS_MAX:
@@ -1758,14 +1745,19 @@
 
         if len( units ) == 0:
-            units        = GMETRIC_DEFAULT_UNITS
+            units       = GMETRIC_DEFAULT_UNITS
 
         if len( typestr ) == 0:
-            typestr        = GMETRIC_DEFAULT_TYPE
-
-        msg         = self.makexdr( name, value, typestr, units, self.slopestr, self.tmax, dmax )
-
-        return self.socket.sendto( msg, self.hostport )
-
-    def makexdr( self, name, value, typestr, unitstr, slopestr, tmax, dmax ):
+            typestr     = GMETRIC_DEFAULT_TYPE
+
+        (meta_msg, data_msg) = self.makexdr( name, value, typestr, units, self.slopestr, self.tmax, dmax )
+
+        meta_rt = self.socket.sendto( meta_msg, self.hostport )
+        data_rt = self.socket.sendto( data_msg, self.hostport )
+
+        return ( meta_rt, data_rt )
+
+    def makexdr( self, name, value, typestr, unitstr, slopestr, tmax, dmax, group=None, spoof=None ):
+
+        hostname = "unset"
 
         if slopestr not in self.slope:
@@ -1781,15 +1773,52 @@
             raise ValueError( "Name must be non-empty" )
 
-        self.msg.reset()
-        self.msg.pack_int( 0 )
-        self.msg.pack_string( typestr )
-        self.msg.pack_string( name )
-        self.msg.pack_string( str( value ) )
-        self.msg.pack_string( unitstr )
-        self.msg.pack_int( self.slope[ slopestr ] )
-        self.msg.pack_uint( int( tmax ) )
-        self.msg.pack_uint( int( dmax ) )
-
-        return self.msg.get_buffer()
+        self.meta_msg.reset()
+        self.meta_msg.pack_int( 128 )
+
+        if not spoof:
+            self.meta_msg.pack_string( hostname )
+        else:
+            self.meta_msg.pack_string( spoof )
+
+        self.meta_msg.pack_string( name )
+
+        if not spoof:
+            self.meta_msg.pack_int( 0 )
+        else:
+            self.meta_msg.pack_int( 1 )
+            
+        self.meta_msg.pack_string( typestr )
+        self.meta_msg.pack_string( name )
+        self.meta_msg.pack_string( unitstr )
+        self.meta_msg.pack_int( self.slope[ slopestr ] )
+        self.meta_msg.pack_uint( int( tmax ) )
+        self.meta_msg.pack_uint( int( dmax ) )
+
+        if not group:
+            self.meta_msg.pack_int( 0 )
+        else:
+            self.meta_msg.pack_int( 1 )
+            self.meta_msg.pack_string( "GROUP" )
+            self.meta_msg.pack_string( group )
+
+        self.data_msg.reset()
+        self.data_msg.pack_int( 128+5 )
+
+        if not spoof:
+            self.data_msg.pack_string( hostname )
+        else:
+            self.data_msg.pack_string( spoof )
+
+        self.data_msg.pack_string( name )
+
+        if not spoof:
+            self.data_msg.pack_int( 0 )
+        else:
+            self.data_msg.pack_int( 1 )
+
+        self.data_msg.pack_string( "%s" )
+        self.data_msg.pack_string( str( value ) )
+
+        return ( self.meta_msg.get_buffer(), self.data_msg.get_buffer() )
 
 def printTime( ):
