Created
October 8, 2012 15:12
-
-
Save thanos/3853039 to your computer and use it in GitHub Desktop.
get total message traffic from a rabbitmq vhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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