LinuxϵÄÈÕÖ¾ÆÊÎö¹¤¾ßÍƼö
linuxϵÄÈÕÖ¾ÆÊÎö¹¤¾ßÍƼö
Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤£¬ÈËÃÇÔÚÒ»Ñùƽ³£ÉúÑÄÖб¬·¢Ô½À´Ô½¶àµÄÊý¾Ý¡£Ð§ÀÍÆ÷ÈÕÖ¾ÊÇÆäÖÐÒ»²¿·ÖÖ÷ÒªµÄÊý¾Ý£¬Ëü¼Í¼ÁËЧÀÍÆ÷ÔËÐÐÀú³ÌÖеÄÖÖÖÖÔ˶¯ºÍÊÂÎñ¡£¹ØÓÚЧÀÍÆ÷ÖÎÀíÔ±ºÍ¿ª·¢Ö°Ô±À´Ëµ£¬ÆÊÎöºÍÃ÷È·ÕâЩÈÕÖ¾ÊǺÜÊÇÖ÷ÒªµÄ£¬¿ÉÒÔ×ÊÖúËûÃÇÈ·±£Ð§ÀÍÆ÷µÄÕý³£ÔËÐÐÒÔ¼°·¢Ã÷DZÔÚµÄÎÊÌâ¡£
ÔÚLinuxÇéÐÎÏ£¬ÓÐÐí¶àÇ¿Ê¢µÄÈÕÖ¾ÆÊÎö¹¤¾ß¿ÉÒÔ×ÊÖúÎÒÃÇ´¦ÀíºÍÆÊÎöЧÀÍÆ÷ÈÕÖ¾¡£±¾ÎĽ«ÏÈÈݼ¸¿îÍƼöµÄÈÕÖ¾ÆÊÎö¹¤¾ß£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£
Logwatch
LogwatchÊÇÒ»¸öÓÃPerl±àдµÄÈÕÖ¾ÆÊÎö¹¤¾ß£¬¿ÉÒÔ½«Ð§ÀÍÆ÷ÈÕ־ת»¯ÎªÒ׶ÁµÄHTML»òÎı¾ÃûÌñ¨¸æ¡£ËüÄܹ»ÆÊÎöApache¡¢Postfix¡¢SquidµÈ³£¼ûЧÀ͵ÄÈÕÖ¾£¬²¢ÌìÉúÏìÓ¦µÄ±¨¸æ¡£×°ÖúÍʹÓÃLogwatchºÜÊǼòÆÓ£¬²¢ÇÒ¿ÉÒÔͨ¹ýÉèÖÃÎļþÀ´¶¨ÖƱ¨¸æÄÚÈÝ¡£
ʾÀý´úÂ룺
# ×°ÖÃLogwatch sudo apt-get install logwatch # ÌìÉúÈÕÖ¾±¨¸æ sudo logwatch
µÇ¼ºó¸´ÖÆ
GoAccess
GoAccessÊÇÒ»¸ö»ùÓÚÏÂÁîÐеÄʵʱÈÕÖ¾ÆÊÎö¹¤¾ß£¬¿ÉÒÔʵʱ¼à¿ØºÍÆÊÎöApache¡¢NginxµÈЧÀÍÆ÷µÄÈÕÖ¾¡£ËüÌṩÁË¿ÉÊÓ»¯µÄ±¨¸æ£¬²¢Ö§³Öƾ֤IPµØµã¡¢URL¡¢»á¼ûʱ¼äµÈ¶àÖÖά¶È¾ÙÐÐÅÅÐòºÍ¹ýÂË¡£
ʾÀý´úÂ룺
# ×°ÖÃGoAccess sudo apt-get install goaccess # ÆÊÎöApache»á¼ûÈÕÖ¾ sudo goaccess /var/log/apache2/access.log
µÇ¼ºó¸´ÖÆ
Elasticsearch + Logstash + Kibana (ELK stack)
ELK stackÊÇÒ»¸öÓÉElasticsearch¡¢LogstashºÍKibana×é³ÉµÄÈÕÖ¾ÆÊÎö½â¾ö¼Æ»®¡£ElasticsearchÊÇÒ»¸öÂþÑÜʽµÄÈ«ÎÄËÑË÷ºÍÆÊÎöÒýÇ棬LogstashÓÃÓÚÈÕÖ¾ÍøÂçºÍ´«Ê䣬KibanaÊÇÒ»¸öÊý¾Ý¿ÉÊÓ»¯¹¤¾ß¡£Í¨¹ýELK stack£¬ÎÒÃÇ¿ÉÒÔʵʱÍøÂç¡¢´¦ÀíºÍÆÊÎöЧÀÍÆ÷ÈÕÖ¾£¬²¢¿ÉÊÓ»¯Õ¹Ê¾Ð§¹û¡£
ʾÀý´úÂ룺
# ×°ÖÃElasticsearch¡¢LogstashºÍKibana Çë²Î¿¼¹Ù·½Îĵµ¾ÙÐÐ×°ÖúÍÉèÖà # ÉèÖÃLogstashÍøÂçApache»á¼ûÈÕÖ¾ input { file { path => "/var/log/apache2/access.log" start_position => "beginning" } } filter { grok { match => { "message" => "%{COMBINEDAPACHELOG}" } } } output { elasticsearch { hosts => ["localhost:9200"] index => "apache-access-%{+YYYY.MM.dd}" } } # ÔÚKibanaÖн¨Éè¿ÉÊÓ»¯ÒDZíÅÌ Çë²Î¿¼¹Ù·½Îĵµ¾ÙÐÐÉèÖúÍÉèÖÃ
µÇ¼ºó¸´ÖÆ
×ܽ᣺
ÒÔÉÏÊǼ¸¿îÔÚLinuxÇéÐÎϵÄÍƼöÈÕÖ¾ÆÊÎö¹¤¾ß£¬Ã¿¸ö¹¤¾ß¶¼ÓÐÆäÌصãºÍÊÊÓó¡¾°¡£Æ¾Ö¤×Ô¼ºµÄÐèÇó£¬Ñ¡ÔñºÏÊʵŤ¾ßÄܹ»×ÊÖúÎÒÃǸüºÃµØÃ÷È·ºÍÆÊÎöЧÀÍÆ÷ÈÕÖ¾£¬²¢ÌáÉýЧÀÍÆ÷µÄÎȹÌÐÔºÍÐÔÄÜ¡£
ËäÈ»±¾ÎÄÌṩÁËÏìÓ¦µÄ´úÂëʾÀý£¬¿ÉÊÇÏÖʵʹÓÃʱÐèҪƾ֤×Ô¼ºµÄÇéÐκÍÐèÇó¾ÙÐÐÊʵ±µÄÉèÖúÍÐ޸ġ£Ï£Íû¶ÁÕßÄܹ»Æ¾Ö¤±¾ÎÄÌṩµÄÐÅÏ¢ºÍʾÀý£¬Ñ¡ÔñÊʺÏ×Ô¼ºµÄÈÕÖ¾ÆÊÎö¹¤¾ß£¬²¢ÔËÓõ½ÏÖʵÊÂÇéÖУ¬Ìá¸ßÊÂÇéЧÂʺÍЧÀÍÆ÷µÄÇå¾²ÐÔºÍÎȹÌÐÔ¡£
ÒÔÉϾÍÊÇLinuxϵÄÈÕÖ¾ÆÊÎö¹¤¾ßÍƼöµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡