nginxÔõôÉó²éÔËÐÐ״̬
Éó²é nginx ÔËÐÐ״̬µÄÒªÁìÓУºÊ¹Óà ps ÏÂÁîÉó²éÀú³Ì״̬£»Éó²é nginx ÉèÖÃÎļþ /etc/nginx/nginx.conf£»Ê¹Óà nginx ״̬ģ¿éÆôÓÃ״̬¶Ëµã£»Ê¹Óà prometheus¡¢zabbix »ò nagios µÈ¼à¿Ø¹¤¾ß¡£
ÔõÑùÉó²é Nginx ÔËÐÐ״̬
Éó²éÀú³Ì״̬
×î¼òÆÓµÄÒªÁìÊÇʹÓà ps ÏÂÁîÉó²é Nginx Àú³ÌµÄÔËÐÐ״̬£º
ps aux | grep nginx
µÇ¼ºó¸´ÖÆ
´ËÏÂÁÁгöËùÓÐÕýÔÚÔËÐеÄÀú³Ì£¬°üÀ¨ Nginx Àú³Ì¡£Êä³öЧ¹û½«ÏÔʾ Nginx Àú³ÌµÄÀú³Ì ID (PID)¡¢CPU ºÍÄÚ´æʹÓÃÇéÐεÈÐÅÏ¢¡£
Éó²éÉèÖÃÎļþ
Nginx µÄÉèÖÃÎļþͨ³£Î»ÓÚ /etc/nginx/nginx.conf¡£Äú¿ÉÒÔʹÓÃÎı¾±à¼Æ÷£¨Èç vim »ò nano£©·¿ª´ËÎļþ²¢Éó²éÉèÖÃÐÅÏ¢¡£
ÔÚÉèÖÃÎļþÖУ¬Äú¿ÉÒÔÕÒµ½ÓÐ¹Ø Nginx ¼àÌý¶Ë¿Ú¡¢ÐéÄâÖ÷»úºÍ¹ýʧÈÕÖ¾µÈÐÅÏ¢¡£
ʹÓà Nginx ״̬ģ¿é
Nginx ״̬ģ¿éÔÊÐíÄúͨ¹ý HTTP ¶ËµãÉó²éЧÀÍÆ÷״̬¡£ÒªÆôÓôËÄ£¿é£¬ÇëÔÚ Nginx ÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÐУº
load_module modules/ngx_status_module.so;
µÇ¼ºó¸´ÖÆ
²¢Ìí¼ÓÒ»¸öÐ嵀 Nginx ЧÀÍÆ÷¿éÒÔ¹ûÕæ״̬¶Ëµã£º
location /nginx-status { stub_status on; access_log off; }
µÇ¼ºó¸´ÖÆ
È»ºó£¬Äú¿ÉÒÔͨ¹ýä¯ÀÀ´Ë¶ËµãÀ´Éó²é Nginx ЧÀÍÆ÷µÄ״̬ÐÅÏ¢£º
http://<nginx_server_address>/nginx-status</nginx_server_address>
µÇ¼ºó¸´ÖÆ
ʹÓüà¿Ø¹¤¾ß
ÉÐÓÐһЩ¼à¿Ø¹¤¾ß¿ÉÒÔ×ÊÖúÄúÉó²é Nginx µÄÔËÐÐ״̬£¬ÀýÈ磺
Prometheus
Zabbix
Nagios
ÕâЩ¹¤¾ß¿ÉÒÔ°´ÆÚÍøÂçºÍÏÔʾ Nginx µÄÖ¸±ê£¬ÀýÈçÇëÇóÂÊ¡¢ÏìӦʱ¼äºÍÄÚ´æÕ¼ÓÃÇéÐΡ£
ÒÔÉϾÍÊÇnginxÔõôÉó²éÔËÐÐ״̬µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡