ÔõÑù¾ÙÐÐLinuxÔËάÊÂÇéµÄϵͳ¼à¿ØºÍ¹ÊÕÏɨ³ý
ÎÊÌ⣺LinuxÔËάÊÂÇéµÄϵͳ¼à¿ØºÍ¹ÊÕÏɨ³ýÏê½â
СÐò£º
×÷ΪLinuxϵͳÖÎÀíÔ±£¬ÏµÍ³¼à¿ØºÍ¹ÊÕÏɨ³ýÊÇÒ»Ñùƽ³£ÊÂÇéÖбز»¿ÉÉÙµÄÒ»²¿·Ö¡£ÔÚÏÖʵÔËάÖУ¬ÎÒÃÇÐèҪͨ¹ý¼à¿ØϵͳÀ´²¶»ñÒì³££¬²¢¾ÙÐÐʵʱµÄ¹ÊÕÏɨ³ý¡£±¾ÎĽ«ÏêϸÏÈÈÝLinuxÔËάÊÂÇéÖеÄϵͳ¼à¿ØºÍ¹ÊÕÏɨ³ýÒªÁ죬²¢ÌṩÏà¹ØµÄ´úÂëʾÀý¡£
Ò»¡¢ÏµÍ³¼à¿Ø
CPUʹÓÃÂʼà¿Ø
CPUÊÇϵͳµÄ½¹µã×ÊÔ´Ö®Ò»£¬Í¨¹ý¼à¿ØCPUʹÓÃÂÊ¿ÉÒÔʵʱ·¢Ã÷CPU¸ºÔعý¸ßµÄÎÊÌâ¡£¿ÉÒÔʹÓÃÈçϵĴúÂëƬ¶Ï¾ÙÐмà¿Ø£º
#!/bin/bash cpu_usage=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}') echo "Ä¿½ñCPUʹÓÃÂÊ£º${cpu_usage}%" if [[ $(bc <<< "${cpu_usage} > 80") -eq 1 ]]; then echo "ÖÒÑÔ£ºÄ¿½ñCPUʹÓÃÂʹý¸ß£¡" fi
µÇ¼ºó¸´ÖÆ
ÄÚ´æʹÓÃÂʼà¿Ø
ÄÚ´æÒ²ÊÇϵͳ×ÊÔ´ÖеÄÖ÷Òª²¿·Ö£¬Í¨¹ý¼à¿ØÄÚ´æʹÓÃÂÊ¿ÉÒÔʵʱ·¢Ã÷ÄÚ´æȱ·¦µÄÇéÐΡ£¿ÉÒÔʹÓÃÈçϵĴúÂëƬ¶Ï¾ÙÐмà¿Ø£º
#!/bin/bash total_memory=$(free -m | awk '/Mem:/{print $2}') used_memory=$(free -m | awk '/Mem:/{print $3}') memory_usage=$(bc <<< "scale=2;${used_memory}/${total_memory}*100") echo "Ä¿½ñÄÚ´æʹÓÃÂÊ£º${memory_usage}%" if [[ $(bc <<< "${memory_usage} > 80") -eq 1 ]]; then echo "ÖÒÑÔ£ºÄ¿½ñÄÚ´æʹÓÃÂʹý¸ß£¡" fi
µÇ¼ºó¸´ÖÆ
´ÅÅÌʹÓÃÂʼà¿Ø
´ÅÅÌ¿Õ¼äÒ²ÊÇÐèÒª±»¼à¿ØµÄÖ÷Òª×ÊÔ´Ö®Ò»£¬Í¨¹ý¼à¿Ø´ÅÅÌʹÓÃÂÊ¿ÉÒÔʵʱ·¢Ã÷´ÅÅÌ¿Õ¼äȱ·¦µÄÇéÐΡ£¿ÉÒÔʹÓÃÈçϵĴúÂëƬ¶Ï¾ÙÐмà¿Ø£º
#!/bin/bash disk_usage=$(df -h | awk '//$/{print $(NF-1)}' | sed 's/%//') echo "Ä¿½ñ´ÅÅÌʹÓÃÂÊ£º${disk_usage}%" if [[ ${disk_usage} -gt 80 ]]; then echo "ÖÒÑÔ£ºÄ¿½ñ´ÅÅÌʹÓÃÂʹý¸ß£¡" fi
µÇ¼ºó¸´ÖÆ
¶þ¡¢¹ÊÕÏɨ³ý
Éó²éϵͳÈÕÖ¾
ϵͳÈÕÖ¾ÊǹÊÕÏɨ³ýµÄÖ÷ÒªÒÀ¾ÝÖ®Ò»£¬¿ÉÒÔʹÓÃÈçϵÄÏÂÁîÉó²éϵͳÈÕÖ¾£º
tail -n 100 /var/log/messages
µÇ¼ºó¸´ÖÆ
Éó²éÀú³Ì״̬
Àú³ÌÒì³£ÊǹÊÕϵij£¼ûÔµ¹ÊÔÓÉÖ®Ò»£¬¿ÉÒÔʹÓÃÈçϵÄÏÂÁîÉó²éÀú³Ì״̬£º
ps -ef | grep <Àú³ÌÃû>
µÇ¼ºó¸´ÖÆ
¼ì²âÍøÂçÅþÁ¬
ÍøÂçÎÊÌâÒ²Êdz£¼ûµÄ¹ÊÕÏÖ®Ò»£¬¿ÉÒÔʹÓÃÈçϵÄÏÂÁî¼ì²âÍøÂçÅþÁ¬ÇéÐΣº
ping -c 4 <Ä¿µÄIPµØµã>
µÇ¼ºó¸´ÖÆ
¼ì²éЧÀÍ״̬
ЧÀÍÒì³£Ò²ÊǹÊÕϵij£¼ûÔµ¹ÊÔÓÉÖ®Ò»£¬¿ÉÒÔʹÓÃÈçϵÄÏÂÁî¼ì²éЧÀÍ״̬£º
systemctl status <ЧÀÍÃû>
µÇ¼ºó¸´ÖÆ
½áÂÛ£º
ͨ¹ýϵͳ¼à¿ØºÍ¹ÊÕÏɨ³ý£¬¿ÉÒÔʵʱ·¢Ã÷²¢½â¾öLinuxϵͳÖеÄÒì³£ÎÊÌ⣬°ü¹ÜϵͳµÄÎȹÌÐԺͿɿ¿ÐÔ¡£±¾ÎÄÌṩÁËһЩ³£Óõļà¿ØÒªÁìºÍ¹ÊÕÏɨ³ý°ì·¨£¬²¢ÌṩÁËÏà¹ØµÄ´úÂëʾÀý£¬Ï£Íû¶ÔLinuxÔËάÊÂÇéµÄͬÑâÓÐËù×ÊÖú¡£Í¬Ê±£¬ÔÚÏÖʵÊÂÇéÖУ¬ÐèҪƾ֤ÏêϸµÄ³¡¾°ºÍÐèÇó£¬ÎÞаÔËÓÃÕâЩҪÁìºÍ¹¤¾ßÀ´¾ÙÐÐϵͳ¼à¿ØºÍ¹ÊÕÏɨ³ý¡£
ÒÔÉϾÍÊÇÔõÑù¾ÙÐÐLinuxÔËάÊÂÇéµÄϵͳ¼à¿ØºÍ¹ÊÕÏɨ³ýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡