-
-
Save wangbin/756017 to your computer and use it in GitHub Desktop.
munin plugin for beanstalkd status, python version
This file contains 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
# coding: utf-8 | |
#!/usr/bin/env python | |
import sys | |
import beanstalkc | |
HOST = '127.0.0.1' | |
PORT = 14711 | |
def main(): | |
if len(sys.argv) > 1 and sys.argv[1] == 'config': | |
print '''graph_category Beanstalkd | |
graph_title Beanstalk Queue Size | |
graph_vlabel watching | |
watching.label Watching | |
graph_vlabel reserved | |
reserved.label Reserved | |
graph_vlabel ready | |
ready.label Ready | |
graph_vlabel using | |
using.label Using | |
graph_vlabel buried | |
buried.label Buried | |
graph_vlabel waiting | |
waiting.label Waiting | |
graph_vlabel delayed | |
delayed.label Delayed | |
graph_vlabel urgent | |
urgent.label Urgent''' | |
return | |
try: | |
beanstalk = beanstalkc.Connection(host=HOST, port=PORT, parse_yaml=False) | |
stats_tube = beanstalk.stats_tube('default').split('\n')[2:-1] | |
beanstalk.close() | |
for stats in stats_tube: | |
k, v = stats.split(':') | |
if k.startswith('current'): | |
print '%s.value ' %k.split('-')[-1], v | |
except beanstalkc.SocketError: | |
exit(-1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment