Пример #1
0
 def monitor_connect(self, task_id):
     self.debug('Monitor for task %d has connected.' % task_id)
     db = Session()
     task = self.running_tasks[task_id]
     db.add(task)
     db.add(task.log)
     task_data = {}
     task_data['command'] = task.run_command
     tries = 0
     while tries < 3:
         try:
             task_data['gid'] = pwd.getpwnam(task.job.owner)[3]
             task_data['uid'] = pwd.getpwnam(task.job.owner)[2]
             break
         except KeyError:
             tries += 1
     task_data['stdout_file_path'] = task.log._stdout_file_path()
     task_data['stderr_file_path'] = task.log._stderr_file_path()
     db.close()
     return task_data
Пример #2
0
 def monitor_probe(self, task_id, probes):
     self.debug("Logging probe for %d" % task_id)
     task = self.running_tasks[task_id]
     db = Session()
     probe = TaskProbe()
     db.add(probe)
     cattle = self.cattle
     probe.task_id = task_id
     probe.memory = probes['memory']
     probe.pcpu = probes['pcpu']
     probe.pid = probes['pid']
     #probe.cattle_id = task.log.cattle_id
     probe.time = datetime.datetime.now()
     probe.probes = probes
     probe.cattle_id = cattle.id
     probe.task_log_id = task.log.id
     db.commit()
     probe_id = probe.id
     db.expunge(probe)
     db.close()
     return probe_id