【celery】常用記錄

查詢所有active的任務記錄:python manage.py celery status

sh-4.2# python manage.py celery status
/usr/lib/python2.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
“”")
celery@sync_oesrm_worker_nfvo-lcm-nfvo-lcm-staticserver-1-g9qpm: OK
celery@task_worker_nfvo-lcm-nfvo-lcm-taskworker-1-vn5vw: OK
查詢所有active任務的參數配置:python manage.py celery inspect active

sh-4.2# python manage.py celery inspect active
/usr/lib/python2.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
“”")
-> celery@sync_oesrm_worker_nfvo-lcm-nfvo-lcm-staticserver-1-g9qpm: OK
- empty -
-> celery@task_worker_nfvo-lcm-nfvo-lcm-taskworker-1-vn5vw: OK
- empty -
查詢當前active隊列的具體信息:python manage.py celery inspect active_queues

sh-4.2# python manage.py celery inspect active_queues
/usr/lib/python2.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
“”")
-> celery@sync_oesrm_worker_nfvo-lcm-nfvo-lcm-staticserver-1-g9qpm: OK
* {u’exclusive’: False, u’name’: u’sync_oesrm’, u’exchange’: {u’name’: u’sync_oesrm’, u’durable’: True, u’delivery_mode’: 2, u’passive’: False, u’arguments’: None, u’type’: u’direct’, u’auto_delete’: False}, u’durable’: True, u’routing_key’: u’sync_oesrm’, u’no_ack’: False, u’alias’: None, u’queue_arguments’: None, u’binding_arguments’: None, u’bindings’: [], u’auto_delete’: False}
-> celery@task_worker_nfvo-lcm-nfvo-lcm-taskworker-1-vn5vw: OK
* {u’exclusive’: False, u’name’: u’task’, u’exchange’: {u’name’: u’task’, u’durable’: True, u’delivery_mode’: 2, u’passive’: False, u’arguments’: None, u’type’: u’direct’, u’auto_delete’: False}, u’durable’: True, u’routing_key’: u’task’, u’no_ack’: False, u’alias’: None, u’queue_arguments’: None, u’binding_arguments’: None, u’bindings’: [], u’auto_delete’: False}
查詢當前任務的內存佔用量:python manage.py celery inspect memdump

sh-4.2# python manage.py celery inspect memdump
/usr/lib/python2.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
“”")
-> celery@task_worker_nfvo-lcm-nfvo-lcm-taskworker-1-vn5vw: ERROR
AttributeError("‘Process’ object has no attribute ‘get_memory_info’",)
-> celery@sync_oesrm_worker_nfvo-lcm-nfvo-lcm-staticserver-1-g9qpm: ERROR
AttributeError("‘Process’ object has no attribute ‘get_memory_info’",)
輸出woker的統計信息:python manage.py celery inspect stats

sh-4.2# python manage.py celery inspect stats
/usr/lib/python2.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
“”")
-> celery@task_worker_nfvo-lcm-nfvo-lcm-taskworker-1-vn5vw: OK
{
“broker”: {
“alternates”: [],
“connect_timeout”: null,
“heartbeat”: 0,
“hostname”: “2019:0:3:199::3”,
“insist”: false,
“login_method”: null,
“port”: 24010,
“ssl”: false,
“transport”: “redis”,
“transport_options”: {},
“uri_prefix”: null,
“userid”: null,
“virtual_host”: “0”
},
“clock”: “2599667”,
“pid”: 20,
“pool”: {},
“prefetch_count”: 400,
“rusage”: {
“idrss”: 0,
“inblock”: 24072,
“isrss”: 0,
“ixrss”: 0,
“majflt”: 16,
“maxrss”: 156664,
“minflt”: 90582,
“msgrcv”: 0,
“msgsnd”: 0,
“nivcsw”: 15740,
“nsignals”: 0,
“nswap”: 0,
“nvcsw”: 1039263,
“oublock”: 2024,
“stime”: 31.361913,
“utime”: 309.686037
},
“total”: {
“nfvpub.tasks.run”: 235,
“nfvpub.tasks.run_lcm”: 3
}
}
-> celery@sync_oesrm_worker_nfvo-lcm-nfvo-lcm-staticserver-1-g9qpm: OK
{
“broker”: {
“alternates”: [],
“connect_timeout”: 4,
“heartbeat”: null,
“hostname”: “2019:0:3:199::3”,
“insist”: false,
“login_method”: null,
“port”: 24010,
“ssl”: false,
“transport”: “redis”,
“transport_options”: {},
“uri_prefix”: null,
“userid”: null,
“virtual_host”: “0”
},
“clock”: “2599667”,
“pid”: 168,
“pool”: {
“max-concurrency”: 1,
“max-tasks-per-child”: “N/A”,
“processes”: [
234
],
“put-guarded-by-semaphore”: false,
“timeouts”: [
0,
0
],
“writes”: {
“all”: “100.00%”,
“avg”: “100.00%”,
“inqueues”: {
“active”: 0,
“total”: 1
},
“raw”: “462”,
“total”: 462
}
},
“prefetch_count”: 4,
“rusage”: {
“idrss”: 0,
“inblock”: 2256,
“isrss”: 0,
“ixrss”: 0,
“majflt”: 1,
“maxrss”: 140888,
“minflt”: 83370,
“msgrcv”: 0,
“msgsnd”: 0,
“nivcsw”: 13924,
“nsignals”: 0,
“nswap”: 0,
“nvcsw”: 1709041,
“oublock”: 160,
“stime”: 38.284968,
“utime”: 279.845308
},
“total”: {
“nfvpub.tasks.run_sync_oesrm”: 462
}
}
其中celery inspect還有很多功能,參見下面:

sh-4.2# python manage.py celery inspect --help
/usr/lib/python2.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
“”")
Usage: manage.py celery inspect [options] [arg1 … argN]

Inspect the worker at runtime.

Availability: RabbitMQ (amqp), Redis, and MongoDB transports.

Examples::

celery inspect active --timeout=5
celery inspect scheduled -d [email protected]
celery inspect revoked -d [email protected],[email protected]

Options:
-A APP, --app=APP app instance to use (e.g. module.attr_name)
-b BROKER, --broker=BROKER
url to broker. default is ‘amqp://guest@localhost//’
–loader=LOADER name of custom loader class to use.
–config=CONFIG Name of the configuration module
–workdir=WORKING_DIRECTORY
Optional directory to change to after detaching.
-C, --no-color
-q, --quiet
-t TIMEOUT, --timeout=TIMEOUT
Timeout in seconds (float) waiting for reply
-d DESTINATION, --destination=DESTINATION
Comma separated list of destination node names.
–version show program’s version number and exit
-h, --help show this help message and exit

[Commands]
| active
| dump active tasks (being processed)
| active_queues
| dump queues being consumed from
| clock
| get value of logical clock
| conf None
| dump worker configuration
| memdump
| dump memory samples (requires psutil)
| memsample
| sample memory (requires psutil)
| objgraph None
| create object graph (requires objgraph)
| ping
| ping worker(s)
| registered
| dump of registered tasks
| report
| get bugreport info
| reserved
| dump reserved tasks (waiting to be processed)
| revoked
| dump of revoked task ids
| scheduled
| dump scheduled tasks (eta/countdown/retry)
| stats
| dump worker statistics
如果任務堆積過多導致celery掛死,可以通過下面的指令來清空隊列

python manage.py celery purge -Q [queue_name]

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章