Add a queue monitor for zuul.

Change-Id: I94b361fdc3c4e2aa57d63a69d3780d7e9de8cdc6
This commit is contained in:
Michael Still 2013-12-30 21:07:08 +11:00
parent 81ebd10bdf
commit ae9ec2f6c7
2 changed files with 57 additions and 0 deletions

View File

@ -31,6 +31,7 @@ console_scripts =
turbo-hipster = turbo_hipster.worker_server:main
turbo-hipster-analyse = turbo_hipster.analyse_historical:main
turbo-hipster-report = turbo_hipster.report_historical:main
turbo-hipster-queue-logger = turbo_hipster.queue_logger:main
[build_sphinx]
source-dir = doc/source

View File

@ -0,0 +1,56 @@
#!/usr/bin/python2
#
# Copyright 2013 Rackspace Australia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import socket
import sys
def main():
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('zuul.rcbops.com', 4730))
client_socket.send('status\n')
data = ''
d = client_socket.recv(1024)
while d:
data += d
if d.split('\n')[-2] == '.':
break
d = client_socket.recv(1024)
queued_count = 0
queued_detail = {}
for line in data.split('\n')[:-2]:
func, total, running, available_workers = line.split('\t')
queued = int(total) - int(running)
if queued > 0:
queued_detail[func] = ('%d (%s workers)'
% (queued, available_workers))
queued_count += queued
print 'There are %d turbo-hipster jobs queued' % queued_count
for job in queued_detail:
print ' %s: %s' % (job, queued_detail[job])
client_socket.close()
if __name__ == '__main__':
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(__file__), '../')))
main()