@@ -0,0 +1,2363 @@
+#!/usr/bin/env python %0A%0Aimport sys%0Aimport time%0Aimport re%0Aimport MySQLdb%0A%0Adef usage():%0A    print %22diff the tokudb engine status%22%0A    print %22%5B--host=HOSTNAME%5D (default: localhost)%22%0A    print %22%5B--port=PORT%5D%22%0A    print %22%5B--sleeptime=SLEEPTIME%5D (default: 10 seconds)%22%0A    return 1%0A%0Adef printit(stats, rs, sleeptime):%0A    # print rs%0A    for t in rs:%0A        l = len(t) # grab the last 2 fields in t%0A        k = t%5Bl-2%5D%0A        v = t%5Bl-1%5D%0A        # print k, v%0A        if stats.has_key(k):%0A            oldv = stats%5Bk%5D%0A            if v != oldv:%0A                print k, %22%7C%22, oldv, %22%7C%22, v,%0A                try:%0A                    vi = int(v)%0A                    oldvi = int(oldv)%0A                    d = vi - oldvi%0A                    if d %3C= 0 or d %3C sleeptime:%0A                        raise %22invalid%22%0A                    print %22%7C%22, d, %22%7C%22, d / sleeptime%0A                except:%0A                    print%0A        stats%5Bk%5D = v%0A    print%0A%0Adef main():%0A    host = None%0A    port = None%0A    user = None%0A    passwd = None%0A    sleeptime = 10%0A    q = 'show engine tokudb status'%0A%0A    for a in sys.argv%5B1:%5D:%0A        if a == %22-h%22 or a == %22-?%22 or a == %22--help%22:%0A            return usage()%0A        match = re.match(%22--(.*)=(.*)%22, a)%0A        if match:%0A            exec %22%25s='%25s'%22 %25 (match.group(1),match.group(2))%0A            continue%0A        return usage()%0A%0A    connect_parameters = %7B%7D%0A    if host is not None:%0A        if host%5B0%5D == '/':%0A            connect_parameters%5B'unix_socket'%5D = host%0A        else:%0A            connect_parameters%5B'host'%5D = host%0A            if port is not None:%0A                connect_parameters%5B'port'%5D = int(port)%0A    if user is not None:%0A        connect_parameters%5B'user'%5D = user%0A    if passwd is not None:%0A        connect_parameters%5B'passwd'%5D = passwd%0A%0A    try:%0A        db = MySQLdb.connect(**connect_parameters)%0A    except:%0A        print sys.exc_info()%0A        return 1%0A%0A    print %22connected%22%0A%0A    stats = %7B%7D%0A    while 1:%0A        try:%0A            c = db.cursor()%0A            n = c.execute(q)%0A            rs = c.fetchall()%0A            db.commit()%0A            c.close()%0A        except:%0A            print %22db%22, sys.exc_info()%0A            return 2%0A%0A        try:%0A            printit(stats, rs, int(sleeptime))%0A            time.sleep(int(sleeptime))%0A        except:%0A            print %22printit%22, sys.exc_info()%0A            return 3%0A%0A%0A    return 0%0A%0Asys.exit(main())%0A

copy tokustat.py from subversion. dont care about history.