尊龙凯时人生就是博

LinuxϵÄʵʱÈÕÖ¾¼à¿ØÓëÆÊÎö

linuxϵÄʵʱÈÕÖ¾¼à¿ØÓëÆÊÎö

ÔÚÒ»Ñùƽ³£µÄϵͳÖÎÀíºÍ¹ÊÕÏÅŲéÖÐ £¬ÈÕÖ¾ÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄÊý¾ÝȪԴ¡£Í¨¹ý¶ÔϵͳÈÕÖ¾µÄʵʱ¼à¿ØºÍÆÊÎö £¬ÎÒÃÇ¿ÉÒÔʵʱ·¢Ã÷Òì³£ÇéÐβ¢¾ÙÐÐÏìÓ¦µÄ´¦Àí¡£±¾ÎĽ«ÏÈÈÝLinuxÏÂÔõÑù¾ÙÐÐʵʱÈÕÖ¾¼à¿ØºÍÆÊÎö £¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

Ò»¡¢ÊµÊ±ÈÕÖ¾¼à¿Ø

ÔÚLinuxÏ £¬×î³£ÓõÄÈÕ־ϵͳÊÇrsyslog¡£Í¨¹ýÉèÖÃrsyslog £¬ÎÒÃÇ¿ÉÒÔʵÏÖ½«²î±ðÓ¦ÓóÌÐòµÄÈÕÖ¾Êä³öµ½Ö¸¶¨µÄÎļþÖÐ £¬²¢Í¨¹ýtailÏÂÁîʵʱ¼à¿ØÕâЩÈÕÖ¾Îļþ¡£

Ê×ÏÈ £¬ÐèҪȷ±£rsyslogÒѾ­×°Öò¢ÔËÐС£Í¨¹ýÒÔÏÂÏÂÁî¿ÉÒÔ¼ì²érsyslogµÄ״̬£º

systemctl status rsyslog

µÇ¼ºó¸´ÖÆ

±à¼­rsyslogÉèÖÃÎļþ/etc/rsyslog.conf £¬½«ÐèÒª¼à¿ØµÄÈÕÖ¾Êä³öµ½Ö¸¶¨ÎļþÖС£ÀýÈç £¬ÎÒÃÇÒª¼à¿Ø/var/log/messagesÎļþ£º

#½«/var/log/messagesÎļþµÄÈÕÖ¾Êä³öµ½/var/log/monitored.log
:msg,contains,"kernel" /var/log/monitored.log
#ÆäËûÈÕ־ĬÈÏÊä³öµ½/var/log/messages
*.info;mail.none;authpriv.none;cron.none /var/log/messages

µÇ¼ºó¸´ÖÆ

ÖØÆôrsyslogЧÀÍʹÉèÖÃÉúЧ£º

service rsyslog restart

µÇ¼ºó¸´ÖÆ

ʹÓÃtailÏÂÁî¶ÔÖ¸¶¨µÄÈÕÖ¾Îļþ¾ÙÐÐʵʱ¼à¿Ø¡£ÀýÈç £¬ÎÒÃÇÒª¼à¿Ø/var/log/monitored.logÎļþ£º

tail -f /var/log/monitored.log

µÇ¼ºó¸´ÖÆ

ͨ¹ýÒÔÉÏ°ì·¨ £¬ÎÒÃǾͿÉÒÔʵʱ¼à¿ØÖ¸¶¨µÄÈÕÖ¾ÎļþÁË¡£

¶þ¡¢ÊµÊ±ÈÕÖ¾ÆÊÎö

ʵʱÈÕÖ¾¼à¿ØÖ»ÊǵÚÒ»²½ £¬¸üÖ÷ÒªµÄÊǶÔÈÕÖ¾¾ÙÐÐʵʱÆÊÎö £¬ÒÔ±ãʵʱ·¢Ã÷ÎÊÌâ²¢½ÓÄÉÏìÓ¦µÄ²½·¥¡£ÔÚLinuxÏ £¬ÎÒÃÇ¿ÉÒÔʹÓÃһЩ¹¤¾ßÀ´ÊµÏÖÈÕÖ¾ÆÊÎö¡£

awk

awkÊÇÒ»ÖÖÇ¿Ê¢µÄÎÄÌìÖ°Îö¹¤¾ß £¬ÔÚʵʱÈÕÖ¾ÆÊÎöÖо­³£±»Ê¹Óá£Í¨¹ýawk £¬ÎÒÃÇ¿ÉÒÔƾָ֤¶¨µÄÌõ¼þ¶ÔÈÕÖ¾¾ÙÐйýÂ˺ʹ¦Àí¡£

ÀýÈç £¬ÎÒÃÇÒª¹ýÂ˳öº¬ÓÐÌض¨Òªº¦×ÖµÄÈÕÖ¾ÐÐ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

tail -f /var/log/monitored.log | awk '/Òªº¦×Ö/'

µÇ¼ºó¸´ÖÆ

grep

grepÊÇÁíÒ»¸ö³£ÓõÄÎı¾ËÑË÷¹¤¾ß £¬¿ÉÒÔ¿ìËÙ²éÕÒ°üÀ¨Ö¸¶¨Òªº¦×ÖµÄÈÕÖ¾ÐС£

ÀýÈç £¬ÎÒÃÇÒª²éÕÒº¬ÓÐÒªº¦×Ö”error”µÄÈÕÖ¾ÐÐ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

tail -f /var/log/monitored.log | grep "error"

µÇ¼ºó¸´ÖÆ

sed

sedÊÇÒ»ÖÖÁ÷ʽÎı¾±à¼­Æ÷ £¬¿ÉÒÔƾָ֤¶¨µÄ¹æÔò¶ÔÎı¾¾ÙÐд¦Àí¡£Í¨¹ýsed £¬ÎÒÃÇ¿ÉÒÔ¶ÔÈÕÖ¾¾ÙÐÐÌæ»»¡¢É¾³ýµÈ²Ù×÷¡£

ÀýÈç £¬ÎÒÃÇÒª½«ÈÕÖ¾ÐÐÖеÄÒªº¦×Ö”warning”Ì滻Ϊ”ÖÒÑÔ” £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

tail -f /var/log/monitored.log | sed 's/warning/ÖÒÑÔ/g'

µÇ¼ºó¸´ÖÆ

ͨ¹ýÒÔÉϹ¤¾ßµÄ×éºÏʹÓà £¬ÎÒÃÇ¿ÉÒÔ¾ÙÐÐÔ½·¢ÖØ´óµÄʵʱÈÕÖ¾ÆÊÎö¡£

×ܽ᣺

ʵʱÈÕÖ¾¼à¿ØºÍÆÊÎöÔÚϵͳÖÎÀíºÍ¹ÊÕÏÅŲéÖÐÆð×ÅÖ÷ÒªµÄ×÷Óá£Í¨¹ýÉèÖÃrsyslogºÍʹÓù¤¾ßÈçawk¡¢grep¡¢sedµÈ £¬ÎÒÃÇ¿ÉÒÔʵÏÖ¶ÔLinuxϵͳÈÕÖ¾µÄʵʱ¼à¿ØºÍÆÊÎö¡£ÕâʹµÃÎÒÃÇÄܹ»ÊµÊ±·¢Ã÷ϵͳÒì³£²¢½ÓÄÉÏìÓ¦µÄ²½·¥ £¬È·±£ÏµÍ³µÄÕý³£ÔËÐС£

ÒÔÉÏÊǹØÓÚlinuxϵÄʵʱÈÕÖ¾¼à¿ØÓëÆÊÎöµÄÏÈÈÝ £¬Ï£Íû¶Ô¶ÁÕßÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇLinuxϵÄʵʱÈÕÖ¾¼à¿ØÓëÆÊÎöµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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