尊龙凯时人生就是博

Nginx¼à¿Øʵʱ״̬ÉèÖà £¬ÊµÊ±Éó²éÍøÕ¾ÔËÐÐ

nginx¼à¿Øʵʱ״̬ÉèÖà £¬ÊµÊ±Éó²éÍøÕ¾ÔËÐÐ

СÐò£º

NginxÊÇÒ»¿îºÜÊÇÊ¢Ðеķ´ÏòÊðÀíЧÀÍÆ÷ £¬Æä¸ßÐÔÄܺ͸߲¢·¢ÄÜÁ¦Ê¹µÃËü³ÉΪÁËÐí¶àÍøÕ¾µÄÊ×Ñ¡ ¡£ÎªÁË°ü¹ÜÍøÕ¾µÄÎȹÌÔËÐÐ £¬ÎÒÃÇÐèҪʱ¿Ì¼à¿ØNginxµÄÔËÐÐ״̬ ¡£±¾ÆªÎÄÕ½«ÏÈÈÝÔõÑùÉèÖÃNginxʵʱ״̬¼à¿Ø £¬²¢Í¨¹ýʾÀý´úÂëÀ´ÈöÁÕ߸üºÃµØÃ÷È· ¡£

Ò»¡¢×°ÖÃNginx״̬¼à¿ØÄ£¿é

ҪʵÏÖNginxµÄʵʱ״̬¼à¿Ø £¬ÐèÒªÔÚNginxÉÏ×°ÖÃngx_http_stub_statusÄ£¿é ¡£Ê×ÏÈ £¬È·±£ÒѾ­×°ÖÃÁËNginx £¬È»ºó½øÈëµ½NginxÔ´ÂëĿ¼ £¬Ö´ÐÐÒÔÏÂÏÂÁ

./configure --prefix=/usr/local/nginx --add-module=../ngx_http_stub_status_module
make
make install

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬ÔÚNginxµÄÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÉèÖÃÏ

location /status {
    stub_status;
    access_log off;
    allow 127.0.0.1;
    deny all;
}

µÇ¼ºó¸´ÖÆ

ÖØÆôNginxʹÉèÖÃÉúЧ£º

/usr/local/nginx/sbin/nginx -s reload

µÇ¼ºó¸´ÖÆ

ÏÖÔھͿÉÒÔͨ¹ý»á¼û”http://yourdomain/status”À´Éó²éNginxµÄʵʱ״̬ÐÅÏ¢ÁË ¡£

¶þ¡¢Nginx״̬¼à¿ØÊý¾ÝÃûÌÃ˵Ã÷

Nginx״̬¼à¿ØÊý¾ÝÊÇÒ»¸ö¼òÆÓµÄÎı¾ÃûÌà £¬°üÀ¨ÁËÄ¿½ñµÄÅþÁ¬Êý¡¢ÇëÇóÊý¡¢¶Áд×Ö½ÚÊýµÈÐÅÏ¢ ¡£ÏÂÃæÊÇÒ»¸öʾÀý£º

Active connections: 10
server accepts handled requests
 10000 10000 10000
Reading: 0 Writing: 1 Waiting: 9

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬¡°Active connections¡±ÌåÏÖÄ¿½ñµÄÔ˶¯ÅþÁ¬Êý £¬¡°Reading¡±ÌåÏÖÕýÔÚ¶ÁÈ¡¿Í»§¶ËÇëÇóµÄÅþÁ¬Êý £¬¡°Writing¡±ÌåÏÖÕýÔÚÏò¿Í»§¶ËдÈëÏìÓ¦µÄÅþÁ¬Êý £¬¡°Waiting¡±ÌåÏÖÕýÔÚÆÚ´ý¿Í»§¶ËÇëÇóµÄ¿ÕÏÐÅþÁ¬Êý ¡£

Èý¡¢Í¨¹ý´úÂëʵʱ»ñÈ¡Nginx״̬

ÏÂÃæÊÇÒ»¸öʹÓÃPython±àдµÄ´úÂëʾÀý £¬¿ÉÒÔʵʱ»ñÈ¡NginxµÄ״̬ÐÅÏ¢ £¬²¢¾ÙÐÐչʾ ¡£

import requests

response = requests.get('http://yourdomain/status')
status = response.text.split('
')

active_connections = status[0].split(':')[1].strip()
reading_connections = status[3].split(':')[1].strip()
writing_connections = status[4].split(':')[1].strip()
waiting_connections = status[5].split(':')[1].strip()

print('Ô˶¯ÅþÁ¬Êý£º', active_connections)
print('ÕýÔÚ¶ÁÈ¡ÅþÁ¬Êý£º', reading_connections)
print('ÕýÔÚдÈëÅþÁ¬Êý£º', writing_connections)
print('ÆÚ´ýÅþÁ¬Êý£º', waiting_connections)

µÇ¼ºó¸´ÖÆ

ͨ¹ýÉÏÊö´úÂë £¬ÎÒÃÇ¿ÉÒÔʵʱ»ñÈ¡NginxµÄÅþÁ¬ÊýµÈÒªº¦ÐÅÏ¢ £¬²¢½«Æä´òÓ¡³öÀ´ ¡£ÄãÒ²¿ÉÒÔƾ֤ÐèÇó¶Ô»ñÈ¡µ½µÄ״̬ÐÅÏ¢¾ÙÐнøÒ»²½´¦Àí £¬ÀýÈ罫ÆäÉúÑĵ½Êý¾Ý¿âÖÐ £¬ÒÔ±¸ºóÐøÆÊÎö ¡£

½áÂÛ£º

NginxµÄʵʱ״̬¼à¿Ø¹ØÓÚ°ü¹ÜÍøÕ¾µÄÎȹÌÔËÐкÜÊÇÖ÷Òª ¡£Í¨¹ý×°Öò¢ÉèÖÃngx_http_stub_statusÄ£¿é £¬ÎÒÃÇ¿ÉÒÔÇáËɵػñÈ¡NginxµÄʵʱ״̬Êý¾Ý ¡£Í¨¹ý´úÂëʾÀý £¬ÎÒÃÇ¿ÉÒÔʵʱ»ñÈ¡²¢Õ¹Ê¾NginxµÄ״̬ÐÅÏ¢ £¬´Ó¶øÈÃÎÒÃǸüºÃµØÏàʶºÍά»¤ÎÒÃǵÄÍøÕ¾ ¡£Ï£Íû±¾ÎĶԸ÷ÈËÔÚNginx״̬¼à¿Ø·½ÃæÓÐËù×ÊÖú£¡

ÒÔÉϾÍÊÇNginx¼à¿Øʵʱ״̬ÉèÖà £¬ÊµÊ±Éó²éÍøÕ¾ÔËÐеÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ