You are hereForums / Support / Query videocache queue?

Finally, the wait is over!!! Videocache 2.0.0 is here :-) Check changelog for changes and new features in this version. Contact Us for your free upgrade!!

Query videocache queue?


2 replies [Last post]
Offline
Joined: Feb 15 2009
Query videocache queue?

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.

Offline
Joined: Jun 19 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.py
+++ videocache/videocache.py
@@ -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.

#!/bin/sh
# get videocache queue size
VCACHE='videocache.domain.tld'
 
tmp=`mktemp -t vc`  #|| exit 1
echo "<?xml version=\"1.0\"?>
<methodCall>
    <methodName>get_queue_size</methodName>
    <params>
    </params>
</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

Offline
Joined: Feb 22 2011

Or you can use python script like this one after you add get_queue_size to videocache.py. 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

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

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <code>
  • Lines and paragraphs break automatically.
  • HTML tags will be transformed to conform to HTML standards.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

CAPTCHA
Are you a human visitor ?
Image CAPTCHA
Enter the characters shown in the image.

My Book on Squid

Purchase/Renew

Go to Pricing page to purchase a new license or renew your existing license.

Recent comments

Who's online

There are currently 0 users and 203 guests online.