Index: /branches/0.4/jobarchived/jobarchived.py
===================================================================
--- /branches/0.4/jobarchived/jobarchived.py	(revision 773)
+++ /branches/0.4/jobarchived/jobarchived.py	(revision 774)
@@ -134,5 +134,5 @@
     global DEBUG_LEVEL, USE_SYSLOG, SYSLOG_LEVEL, SYSLOG_FACILITY, GMETAD_CONF, ARCHIVE_XMLSOURCE
     global ARCHIVE_DATASOURCES, ARCHIVE_PATH, ARCHIVE_HOURS_PER_RRD, ARCHIVE_EXCLUDE_METRICS
-    global JOB_SQL_DBASE, DAEMONIZE, RRDTOOL, JOB_TIMEOUT, MODRRDTOOL
+    global JOB_SQL_DBASE, DAEMONIZE, RRDTOOL, JOB_TIMEOUT, MODRRDTOOL, JOB_SQL_PASSWORD, JOB_SQL_USER
 
     ARCHIVE_PATH        = cfg.get( 'DEFAULT', 'ARCHIVE_PATH' )
@@ -180,4 +180,6 @@
 
     JOB_SQL_DBASE        = cfg.get( 'DEFAULT', 'JOB_SQL_DBASE' )
+    JOB_SQL_USER        = cfg.get( 'DEFAULT', 'JOB_SQL_USER' )
+    JOB_SQL_PASSWORD        = cfg.get( 'DEFAULT', 'JOB_SQL_PASSWORD' )
 
     JOB_TIMEOUT        = cfg.getint( 'DEFAULT', 'JOB_TIMEOUT' )
@@ -328,5 +330,4 @@
         try:
             c.execute(q_str)
-            result = c.oidValue
 
         except psycopg2.Error, details:
@@ -336,5 +337,5 @@
 
         c.close()
-        return result
+        return True
 
     def Commit(self):
@@ -348,8 +349,10 @@
     def __init__( self, hostname, database ):
 
+        global JOB_SQL_USER, JOB_SQL_PASSWORD
+
         self.db_vars = InitVars(DataBaseName=database,
-                User='root',
+                User=JOB_SQL_USER,
                 Host=hostname,
-                Password='',
+                Password=JOB_SQL_PASSWORD,
                 Dictionary='true')
 
@@ -508,5 +511,5 @@
         elif action == 'update':
 
-            self.setDatabase( "UPDATE jobs SET %s WHERE job_id=%s" %(update_str, job_id) )
+            self.setDatabase( "UPDATE jobs SET %s WHERE job_id='%s'" %(update_str, job_id) )
 
         if len( ids ) > 0:
@@ -540,5 +543,5 @@
     def addJobNode( self, jobid, nodeid ):
 
-        self.setDatabase( "INSERT INTO job_nodes (job_id,node_id) VALUES ( %s,%s )" %(jobid, nodeid) )
+        self.setDatabase( "INSERT INTO job_nodes (job_id,node_id) VALUES ( '%s',%s )" %(jobid, nodeid) )
 
     def storeJobInfo( self, jobid, jobattrs ):
@@ -790,4 +793,6 @@
 
             my_data    = self.myXMLSource.getData()
+            #print my_data
+            #print "size my data: %d" %len( my_data )
 
             debug_msg( 1, 'torque_xml_thread(): Done retrieving.' )
@@ -799,4 +804,7 @@
 
                 debug_msg( 1, 'ganglia_parse_thread(): Done parsing.' )
+            else:
+                debug_msg( 1, 'torque_xml_thread(): Got no data.' )
+
                 
             debug_msg( 1, 'torque_xml_thread(): Sleeping.. (%ss)' %(str( self.config.getLowestInterval() ) ) )
@@ -814,4 +822,5 @@
         self.jobs_processed    = [ ]
         self.jobs_to_store    = [ ]
+        debug_msg( 1, "XML: Handler created" )
 
     def startDocument( self ):
@@ -819,4 +828,5 @@
         self.heartbeat    = 0
         self.elementct    = 0
+        debug_msg( 1, "XML: Start document" )
 
     def startElement( self, name, attrs ):
@@ -844,5 +854,5 @@
             elif metricname.find( 'zplugin_monarch_job' ) != -1:
 
-                job_id    = metricname.split( 'zplugin_monarch_job_' )[1].split( '_' )[0]
+                job_id    = metricname.split( 'zplugin_monarch_job_' )[1].split( '_' )[1]
                 val    = str( attrs.get( 'VAL', "" ) )
 
@@ -1331,7 +1341,7 @@
         # Store metrics somewhere between every 360 and 640 seconds
         #
-        if DEBUG_LEVEL > 2:
-            #STORE_INTERVAL = 60
-            STORE_INTERVAL = random.randint( 360, 640 )
+        if DEBUG_LEVEL >= 1:
+            STORE_INTERVAL = 60
+            #STORE_INTERVAL = random.randint( 360, 640 )
         else:
             STORE_INTERVAL = random.randint( 360, 640 )
@@ -1352,7 +1362,7 @@
         if store_metric_thread.isAlive():
 
-            debug_msg( 1, 'ganglia_store_thread(): storemetricthread() still running, waiting to finish..' )
+            debug_msg( 1, 'ganglia_store_thread(): storemetricthread() still running, waiting to terminate..' )
             store_metric_thread.join( STORE_TIMEOUT ) # Maximum time is for storing thread to finish
-            debug_msg( 1, 'ganglia_store_thread(): Done waiting.' )
+            debug_msg( 1, 'ganglia_store_thread(): Done waiting: terminated storemetricthread()' )
 
         debug_msg( 1, 'ganglia_store_thread(): finished.' )
@@ -1376,4 +1386,6 @@
         """Process XML"""
 
+        debug_msg( 5, "Entering processXML()")
+
         try:
             parsethread = threading.Thread( None, self.parseThread, 'parsethread' )
@@ -1391,9 +1403,11 @@
         if parsethread.isAlive():
 
-            debug_msg( 1, 'ganglia_xml_thread(): parsethread() still running, waiting (%ss) to finish..' %PARSE_TIMEOUT )
+            debug_msg( 1, 'ganglia_xml_thread(): parsethread() still running, waiting (%ss) to terminate..' %PARSE_TIMEOUT )
             parsethread.join( PARSE_TIMEOUT ) # Maximum time for XML thread to finish
-            debug_msg( 1, 'ganglia_xml_thread(): Done waiting.' )
+            debug_msg( 1, 'ganglia_xml_thread(): Done waiting. parsethread() terminated' )
 
         debug_msg( 1, 'ganglia_xml_thread(): finished.' )
+
+        debug_msg( 5, "Leaving processXML()")
 
         return 0
@@ -1406,4 +1420,5 @@
         
         my_data    = self.myXMLSource.getData()
+        debug_msg( 1, 'ganglia_parse_thread(): data size %d.' %len(my_data) )
 
         debug_msg( 1, 'ganglia_parse_thread(): Done retrieving.' )
