Hope this proves useful to someone on the list.  This short python script
will decode some of the values in the File.LStat field, or at least the ones
I needed when I wrote this.  Script was written to work with MySQL, but
could easily be changed to query PostgreSQL or whatever else you want.
Would be nice to have something like this included in the tarball, I know I
will be using it a lot.  Was only tested with MySQL 4.1 on a i386 RHEL4 box
with Python 2.5.1.  Enjoy!

Jay

---

#!/bin/env python

import sys
import time
import MySQLdb

jobid = sys.argv[1]

def base64_decode_lstat(record, position):
    b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
    val = 0
    size = record.split(' ')[position]
    for i in range(len(size)):
        val += (b64.find(size[i])) * (pow(64,(len(size)-i)-1))
    return val

db = MySQLdb.connect(host="localhost", user="user", passwd="pass",
db="bacula")
cursor = db.cursor()
cursor.execute("SELECT Path.Path, Filename.Name , File.LStat \
                FROM File, Filename, Path \
                WHERE File.JobId = '%s' \
                    AND Filename.FilenameId = File.FilenameId \
                    AND Path.PathId = File.PathId" % jobid)
result = cursor.fetchall()

for record in result:
    file = record[0] + record[1]
    print '%s is owned by gid %s' % (file, base64_decode_lstat(record[2],
5))
    print '%s is owned by uid %s' % (file, base64_decode_lstat(record[2],
6))
    print '%s is %s bytes in size' % (file, base64_decode_lstat(record[2],
7))
    print '%s blocksize is %s' % (file, base64_decode_lstat(record[2], 8))
    print '%s has %s blocks allocated' % (file,
base64_decode_lstat(record[2], 9))

    atime = time.gmtime(base64_decode_lstat(record[2], 10))
    print '%s has last access time of %s' % (file, time.strftime("%b %d
%H:%M", atime))

    mtime = time.gmtime(base64_decode_lstat(record[2], 11))
    print '%s has last modification time of %s' % (file, time.strftime("%b
%d %H:%M", mtime))

    ctime = time.gmtime(base64_decode_lstat(record[2], 12))
    print '%s has last change time of %s' % (file, time.strftime("%b %d
%H:%M", ctime))
    print
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to