Пример #1
0
	def log_header(self,job_num):
		header = "# --------------------- RSYNC LOG ---------------------\n"
		header+= "#%24s: %s      \n" % ('Date',dateutil.legible_date(datetime.today(),12))
		header+= "#%24s: %s (of %s)\n" % ('Queue entry',job_num+1,len(self.queue))
		header+= "#%24s: %s\n" % ('Source',self.queue[job_num]['source'])
		header+= "#%24s: %s\n" % ('Destination',self.queue[job_num]['destination'])
		self.log.write(header)
Пример #2
0
    def format_df(self):
        """
		Calculate some space attributes and attach 
		them to the object
		"""
        if not self.data.has_key('bytes'):
            self.data['bytes'] = None
        try:
            self.frames_self = self.data['frames']
            self.frames_shared = self.data['frames_shared']
            self.frames_total = self.data['frames'] + self.data['frames_shared']
            self.bytes_self = self.data['bytes']
            self.bytes_shared = self.data['bytes_shared']
            self.bytes_total = self.data['bytes'] + self.data['bytes_shared']
            self.dsp_bytes_self = numberutil.humanize(self.bytes_self,
                                                      scale='bytes')
            self.dsp_bytes_shared = numberutil.humanize(self.bytes_shared,
                                                        scale='bytes')
            self.dsp_bytes_total = numberutil.humanize(self.bytes_total,
                                                       scale='bytes')
            self.dsp_poll_date = dateutil.legible_date(self.data['poll_date'],
                                                       16)
        except:
            self.frames_self = 0
            self.frames_shared = 0
            self.frames_total = 0
            self.bytes_self = 0
            self.bytes_shared = 0
            self.bytes_total = 0
            self.dsp_bytes_self = '0'
            self.dsp_bytes_shared = '0'
            self.dsp_bytes_total = '0'
            self.dsp_poll_date = ''
Пример #3
0
	def run(self):
		stamp = dateutil.legible_date(datetime.today(),20)
		for db in self.databases:
			bck_file = "%s/%s/%s_%s" % (self.backup_dir,db,db,stamp)
			command = "mysqldump -u root %s" % (db)
			output = commands.getoutput(command)
			if not os.path.exists("%s.bz2" % bck_file):
				print "Backing up db: %s to %s.bz2" % (db,bck_file)
				bz_file = bz2.BZ2File("%s.bz2" % bck_file,'w')
				bz_file.write(output)
				bz_file.close()
Пример #4
0
    def poll(self, sanstone=None, timestamp=None):
        """
		Get the # of concurrent users at the given
		timestamp for each stone
		"""
        if not timestamp:
            timestamp = int(round(time.time(), 0))
        log.info("timestamp:%s" % timestamp)
        log.info("Getting stones")
        if not sanstone:
            # get current stones
            stones = Framestore.find(status='active')
        else:
            stones = Framestore.find(name=sanstone, status='active')
        # find the concurrent users for each stone
        for stone in stones:
            fs_uid = stone.data['uid']
            log.info("Getting user count for stone uid: %s" % fs_uid)
            sel = """	select
						count(l.uid)
					from
						ledger as l
					left join
						dl_projects as dlp
						on l.dl_project_uid=dlp.uid
					where
						dlp.framestore_uid=%s
						and unix_timestamp(start_time) < %s
						and ( unix_timestamp(stop_time) > %s
							or stop_time is null)
				""" % (fs_uid, timestamp, timestamp)
            dt = datetime.fromtimestamp(timestamp)
            ldt = dateutil.legible_date(dt, 24)
            count = db.select_single(database='a52_discreet', statement=sel)
            log.info("Count at %s: %s: %s" % (ldt, stone.data['name'], count))
            stone.concurrent_users = count
            stone.timestamp = timestamp
        return stones
Пример #5
0
	def stop_log(self):
		stoptime = dateutil.legible_date(datetime.today(),12)
		self.log.write("\n\n# DONE at %s \n" % (stoptime))
		self.log.close()
Пример #6
0
	def start_log(self):
		log = "/tmp/rsync_log_%s" % (dateutil.legible_date(datetime.today(),19))
		print "Logging to:",log
		#log = self.queue[job_num]['logfile']
		self.log = open(log,'a')