blob: 3e35bcd2f1d1f60416a06d2892ba96089aacf8a3 [file] [log] [blame]
Michael Stillae9ec2f2013-12-30 21:07:08 +11001#!/usr/bin/python2
2#
3# Copyright 2013 Rackspace Australia
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17
18import os
19import socket
20import sys
21
22
23def main():
24 client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
25 client_socket.connect(('zuul.rcbops.com', 4730))
26 client_socket.send('status\n')
27
28 data = ''
29
30 d = client_socket.recv(1024)
31 while d:
32 data += d
33 if d.split('\n')[-2] == '.':
34 break
35 d = client_socket.recv(1024)
36
37 queued_count = 0
38 queued_detail = {}
39 for line in data.split('\n')[:-2]:
40 func, total, running, available_workers = line.split('\t')
41 queued = int(total) - int(running)
42 if queued > 0:
43 queued_detail[func] = ('%d (%s workers)'
44 % (queued, available_workers))
45 queued_count += queued
46
47 print 'There are %d turbo-hipster jobs queued' % queued_count
48 for job in queued_detail:
49 print ' %s: %s' % (job, queued_detail[job])
50
51 client_socket.close()
52
53if __name__ == '__main__':
54 sys.path.insert(0, os.path.abspath(
55 os.path.join(os.path.dirname(__file__), '../')))
56 main()