ÔõÑù¾ÙÐÐLinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀí
LinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀíÊÇϵͳÖÎÀíÔ±Ò»Ñùƽ³£ÊÂÇéÖбز»¿ÉÉÙµÄÒ»²¿·Ö¡£ÔÚ¾ÙÐÐÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀíʱ£¬ÐèҪȷ¶¨ÏµÍ³µÄÓ¦ÓóÌÐòºÍЧÀÍËùÐèµÄÓ²¼þ×ÊÔ´£¬Í¬Ê±°ü¹ÜϵͳµÄÎȹ̺͸߿ÉÓÃÐÔ¡£±¾ÎĽ«ÏÈÈÝÔõÑù¾ÙÐÐLinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀí£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£
È·¶¨ÏµÍ³×ÊÔ´ÐèÇó
ÔÚ¾ÙÐÐÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀí֮ǰ£¬ÐèÒªÏàʶϵͳµÄÓ²¼þÉèÖúÍÔËÐÐÇéÐΡ£Õâ°üÀ¨CPU¡¢ÄÚ´æ¡¢´ÅÅ̺ÍÍøÂçµÈÓ²¼þ×ÊÔ´µÄÊýÄ¿ºÍÖÊÁ¿µÈÐÅÏ¢¡£±ðµÄ£¬»¹ÐèÒªÏàʶϵͳËùÔËÐеÄÓ¦ÓóÌÐòºÍЧÀ͵Ä×ÊÔ´ÐèÇó£¬ÀýÈçCPUÕ¼ÓÃÂÊ¡¢ÄÚ´æʹÓÃÁ¿¡¢´ÅÅ̶ÁдËÙÂʺÍÍøÂç´ø¿íµÈ¡£
×îºÃͨ¹ý¼à¿ØºÍÐÔÄܲâÊԵȹ¤¾ßÀ´ÏàʶϵͳµÄÏÖʵ¸ºÔØÇéÐκÍÕ¹ÍûδÀ´µÄ¸ºÔØÇéÐΡ£ÕâЩ¹¤¾ß½«×ÊÖúÖÎÀíԱȷ¶¨LinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀíËùÐèµÄÓ²¼þ×ÊÔ´¡£
ÈÝÁ¿ÍýÏë
ÔÚÈ·¶¨ÏµÍ³×ÊÔ´ÐèÇóºó£¬ÐèÒª¾ÙÐÐÈÝÁ¿ÍýÏ룬ÒÔÈ·¶¨ÏµÍ³ÐèҪʹÓõÄÓ²¼þ×ÊÔ´ÀàÐͺÍÊýÄ¿¡£ÈÝÁ¿ÍýÏëÊÇÒ»¸öÖ÷ÒªµÄÊÂÇ飬Ëû¹Øϵµ½ÏµÍ³µÄÕý³£ÔËÐкͿÉÓÃÐÔ¡£
ÈÝÁ¿ÍýÏëµÄÖ÷ҪĿµÄÊÇÈ·±£ÏµÍ³¾ßÓÐ×ã¹»µÄÓ²¼þ×ÊÔ´À´Ö§³ÖÆäÄ¿µÄÓ¦ÓóÌÐòºÍЧÀ͵ÄÐèÇó¡£ÀýÈ磬ÈôÊÇÄúÕýÔÚÔËÐÐÒ»¸öWebÓ¦ÓóÌÐò£¬ÄúÐèҪȷ±£ÓµÓÐ×ã¹»µÄCPU¿É´¦Öóͷ£ËùÓÐÒ»Á¬Óû§ÇëÇóºÍ×ã¹»µÄÄÚ´æÀ´»º´æËùÓÐWebÄÚÈÝ¡£
ÒÔÏÂÊÇÍýÏëCPU×ÊÔ´µÄʾÀý´úÂ룺
# Éó²éCPU½¹µãÊýÄ¿ cat /proc/cpuinfo | grep processor | wc -l # Éó²éCPUʹÓÃÇéÐÎ top # ¶¯Ì¬Éó²éÿ¸öÀú³ÌµÄCPUʹÓÃÇéÐΣ¬²¢Æ¾Ö¤CPUʹÓÃÂÊÅÅÐò top -bn1 | awk '{if (NR > 7) {print $9}}' | sort -nr | head -n 10
µÇ¼ºó¸´ÖÆ
ÒÔÏÂÊÇÍýÏëÄÚ´æ×ÊÔ´µÄʾÀý´úÂ룺
# Éó²éÄÚ´æÐÅÏ¢ free -m # Éó²éÿ¸öÀú³ÌµÄÄÚ´æʹÓÃÇéÐÎ top -o RES -n 1 -b # Éó²éÒÑʹÓÃÄÚ´æ×î¶àµÄ10¸öÀú³Ì ps aux --sort=-%mem | head -n 11
µÇ¼ºó¸´ÖÆ
ÒÔÏÂÊÇÍýÏë´ÅÅÌ×ÊÔ´µÄʾÀý´úÂ룺
# ÁгöÄ¿½ñÊÂÇéĿ¼ÏµÄÎļþºÍÎļþ¼Ð ls -la # Éó²é´ÅÅÌʹÓÃÇéÐÎ df -h # Éó²éÿ¸öÀú³ÌµÄ´ÅÅÌIOʹÓÃÇéÐÎ iotop -o -b # Éó²éÒÑÓÃÈÝÁ¿×î´óµÄ10¸öÎļþ/Îļþ¼Ð du -a | sort -n -r | head -n 11
µÇ¼ºó¸´ÖÆ
×ÊÔ´ÖÎÀí
ÔÚÈ·ÈÏϵͳµÄÈÝÁ¿ÍýÏëÖ®ºó£¬ÐèÒª½ÓÄÉÏìÓ¦µÄ×ÊÔ´ÖÎÀí²½·¥£¬ÒÔÈ·±£ÏµÍ³µÄ¿ÉÓÃÐÔºÍÐÔÄÜ¡£ÀýÈ磬¿ÉÒÔÉèÖÃÖÖÖÖÏÞÖÆ¡¢¼à¿ØºÍ¾¯±¨¹¤¾ßµÈµÈÀ´È·±£ÏµÍ³×ÊÔ´µÄÕý³£ÔËÐС£
ÒÔÏÂÊÇ×ÊÔ´ÖÎÀíµÄʾÀý´úÂ룺
# ÉèÖÃ×î´óÎļþ·¿ªÊýÄ¿ÏÞÖÆ ulimit -n 2048 # ÉèÖÃϵͳ±£´æ¶Ë¿ÚÊýÄ¿ echo 1024 65535 >/proc/sys/net/ipv4/ip_local_port_range # ÉèÖÃsyslogÈÕ־ЧÀÍÆ÷ echo "*.* @10.0.0.1:514" >> /etc/rsyslog.conf # ÉèÖÃÓʼþ¾¯±¨Ð§ÀÍ echo "To: admin@example.com" >> /etc/mail.rc echo "Subject: Alert!" >> /etc/mail.rc echo "Hello Admin," >> /etc/mail.rc echo "System Usage Is Too High." >> /etc/mail.rc echo "Regards," >> /etc/mail.rc echo "Your Linux System" >> /etc/mail.rc # ׼ʱ¼ì²éϵͳ²¢ÌìÉú±¨¸æ 0 * * * * root /usr/local/bin/system_check.sh
µÇ¼ºó¸´ÖÆ
ÉÏÃæµÄ´úÂëÖ»ÊÇһЩʾÀý¡£ÖÎÀíÔ±ÐèҪƾ֤ÐèҪѡÔñÊʵ±µÄ×ÊÔ´ÖÎÀí²½·¥£¬ÒÔÈ·±£ÏµÍ³µÄ¸ß¿ÉÓÃÐÔºÍÐÔÄÜ¡£
½áÂÛ
×ܵÄÀ´Ëµ£¬LinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀíÊÇϵͳÖÎÀíÔ±µÄÒ»ÏîÖ÷ÒªÊÂÇé¡£Òª¾ÙÐÐÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀí£¬ÖÎÀíÔ±ÐèÒªÏàʶϵͳµÄÓ²¼þ×ÊÔ´ºÍÔËÐÐÇéÐΣ¬È·¶¨ËùÐèµÄ×ÊÔ´ÀàÐͺÍÊýÄ¿£¬²¢½ÓÄÉÏìÓ¦µÄ×ÊÔ´ÖÎÀí²½·¥ÒÔÈ·±£ÏµÍ³µÄÕý³£ÔËÐкͿÉÓÃÐÔ¡£±¾ÎÄÌṩÁËһЩ´úÂëʾÀýÒÔ×ÊÖúÖÎÀíԱʵÏÖLinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀí¡£
ÒÔÉϾÍÊÇÔõÑù¾ÙÐÐLinuxϵͳµÄÈÝÁ¿ÍýÏëºÍ×ÊÔ´ÖÎÀíµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡