monitoring.rst 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ==================
  2. Monitoring Guide
  3. ==================
  4. .. contents::
  5. :local:
  6. Events
  7. ======
  8. Describe events
  9. Snapshots
  10. ---------
  11. Describe snapshots
  12. Custom Camera
  13. ~~~~~~~~~~~~~
  14. .. code-block:: python
  15. from pprint import pformat
  16. from celery.events.snapshot import Polaroid
  17. class DumpCam(Polaroid):
  18. def shutter(self, state):
  19. if not state.event_count:
  20. # No new events since last snapshot.
  21. return
  22. print("Workers: %s" % (pformat(state.workers, indent=4), ))
  23. print("Tasks: %s" % (pformat(state.tasks, indent=4), ))
  24. print("Total: %s events, %s tasks" % (
  25. state.event_count, state.task_count))
  26. Now you can use this cam with ``celeryev`` by specifying
  27. it with the ``-c`` option::
  28. $ celeryev -c myapp.DumpCam --frequency=2.0
  29. Or you can use it programatically like this::
  30. from celery.events import EventReceiver
  31. from celery.messaging import establish_connection
  32. from celery.events.state import State
  33. from myapp import DumpCam
  34. def main():
  35. state = State()
  36. with establish_connection() as connection:
  37. recv = EventReceiver(connection, handlers={"*": state.event})
  38. with DumpCam(state, freq=1.0):
  39. recv.capture(limit=None, timeout=None)
  40. if __name__ == "__main__":
  41. main()
  42. Tools
  43. =====
  44. celerymon
  45. =========
  46. Describe celerymon
  47. celeryev
  48. ========
  49. Describe celeryev
  50. RabbitMQ
  51. ========
  52. Describe rabbitmq tools. rabbitmqctl, Alice, etc...
  53. Django Admin
  54. ============
  55. Describe the snapshot camera django-celery ships with.
  56. Munin
  57. =====
  58. Maintain a list of related munin plugins