Videocache is no longer in development.

Query videocache queue?

by pyromania on 7 May 2009

Is there a way to get a list or a count of how many downloads videocache has in queue? I'm working on restricting how much bandwidth videocache consumes for cache object fetches. Being able to see how large the queue gets for different bandwidth restrictions would be useful.

2 Answers

by blake on 20 Jun 2009

Here's a patch to add a very simple method to videocache's XML-RPC server to report the size of the queue. Save it into a file called queue_size.patch in the untarred videocache directory, then run patch -p0 < queue_size.patch.

--- videocache/
+++ videocache/
@@ -174,6 +174,9 @@ class VideoIDPool:
             return self.queue[video_id]
         return False

+    def get_queue_size(self)
+        return len(self.queue)
     def remove_from_queue(self, video_id):
         """Dequeue a video_id from the download queue."""
         if video_id in self.queue.keys():

And here's a shell script to query the XML-RPC server and return the queue size. This works fine on a default install of FreeBSD 7.2. Your results may vary.

# get videocache queue size

tmp=`mktemp -t vc`  #|| exit 1
echo "<?xml version=\\"1.0\\"?>
</methodCall>" > $tmp

size=`cat $tmp | wc -c`

msg=`mktemp -t vc`
echo "POST / HTTP/1.1
Content-length: $size
" > $msg

cat $tmp >> $msg
rm $tmp
cat $msg | nc $VCACHE 9100 | sed -ne '/value/p' | grep -o '[0-9]'
rm $msg
by pospanko on 22 Apr 2011

Or you can use python script like this one after you add get_queue_size to You should add some timeout and some other stuff to it, but this is basic version to get queue data:

from xmlrpclib import ServerProxy, Error

    server = ServerProxy("")
    print "Queued: " + str(server.get_queue_size()) \\
          + "\\nActive down: " + str(server.get_conn_number()) \\
except Error, v:
    print "ERROR", v