Skip to content

Instantly share code, notes, and snippets.

@thanos
Created October 8, 2012 15:12
Show Gist options
  • Select an option

  • Save thanos/3853039 to your computer and use it in GitHub Desktop.

Select an option

Save thanos/3853039 to your computer and use it in GitHub Desktop.
get total message traffic from a rabbitmq vhost
import subprocess
def message_trafic():
recv_oct, recv_cnt, send_oct, send_cnt = 0,0,0,0
pipe = subprocess.Popen("sudo rabbitmqctl list_connections name recv_oct recv_cnt send_oct send_cnt", shell=True, stdout=subprocess.PIPE).stdout
for line in pipe:
record = line.split()... try:
recv_oct += float(record[3])
recv_cnt += float(record[4])
send_oct += float(record[5])
send_cnt += float(record[6])
except:
pass
return recv_oct, recv_cnt, send_oct, send_cnt
if __name__ == '__main__':
import time
print time.ctime(), message_trafic()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment