ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÍøÂç´æ´¢¼à¿Ø
ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÍøÂç´æ´¢¼à¿Ø
ÔÚÏÖ´úµÄITÇéÐÎÖУ¬ÍøÂç´æ´¢ÊÇÒ»¸öÒªº¦×é¼þ£¬ÓÃÓÚ´æ´¢ºÍÖÎÀíº£Á¿µÄÊý¾Ý¡£ÎªÁËÈ·±£Êý¾ÝµÄ¿É¿¿ÐԺ͸߿ÉÓÃÐÔ£¬¶ÔÍøÂç´æ´¢µÄ¼à¿ØºÍ¹ÊÕϻָ´ÊǺÜÊÇÖ÷ÒªµÄ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÍøÂç´æ´¢¼à¿Ø£¬²¢Ìṩ´úÂëʾÀý¡£
µÚÒ»²½£º×°Öüà¿Ø¹¤¾ß
ÔÚLinuxÉÏ£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒ»¸ö¿ªÔ´µÄ¼à¿Ø¹¤¾ßÀ´¼à¿ØÍøÂç´æ´¢£¬ºÃ±ÈNagios¡£Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃNagios¡£
·¿ªÖնˣ¬²¢ÒÔÖÎÀíÔ±Éí·ÝÖ´ÐÐÒÔÏÂÏÂÁî×°ÖÃNagios£º
sudo apt-get install nagios3
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬ÎÒÃÇÐèÒªÉèÖÃNagios¡£¿ÉÒÔÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁî±à¼ÉèÖÃÎļþ£º
sudo nano /etc/nagios3/nagios.cfg
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÔÚÉèÖÃÎļþÖУ¬ÎÒÃÇÐèÒªÉèÖüà¿ØÄ¿µÄ¡¢²å¼þ·¾¶µÈ¡£Æ¾Ö¤ÍøÂç´æ´¢µÄÏêϸÇéÐξÙÐÐÏìÓ¦µÄÉèÖá£
ÉúÑIJ¢¹Ø±ÕÉèÖÃÎļþ£¬È»ºóÖØÆôNagiosЧÀÍ£º
sudo service nagios3 restart
µÇ¼ºó¸´ÖÆ
µÚ¶þ²½£ºÉèÖüà¿ØÄ¿µÄ
ÔÚ×°ÖúÍÉèÖúÃNagiosºó£¬ÎÒÃÇÐèÒªÉèÖüà¿ØÄ¿µÄ¡£ÒÔÏÂÊÇÒ»¸öʾÀýÉèÖÃÎļþ£¬ÓÃÓÚ¼à¿ØÒ»¸öÍøÂç´æ´¢×°±¸£º
define host { use linux-server host_name network_storage alias Network Storage address 192.168.1.100 } define service { use generic-service host_name network_storage service_description Ping check_command check_ping!100.0,20%!500.0,60% } define service { use generic-service host_name network_storage service_description Disk Usage check_command check_disk!20%!10%!/ } define service { use generic-service host_name network_storage service_description CPU Load check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0 } define service { use generic-service host_name network_storage service_description Memory Usage check_command check_memory!90%!95% }
µÇ¼ºó¸´ÖÆ
ÉÏÊöÉèÖÃÎļþÊÇÒ»¸öʾÀýÉèÖ㬿ÉÒÔƾ֤ÏÖÕæÏàÐξÙÐÐÐ޸ġ£ÔÚÉèÖÃÎļþÖУ¬ÎÒÃÇÉèÖÃÁ˼à¿ØÄ¿µÄµÄÃû³Æ¡¢IPµØµã£¬ÒÔ¼°Òª¼à¿ØµÄЧÀÍÀàÐÍ£¨ÈçPing¡¢Ó²ÅÌʹÓÃÂÊ¡¢CPU¸ºÔØ¡¢ÄÚ´æʹÓÃÂʵȣ©¡£ÕâÑù£¬Nagios¾Í»áͨ¹ý°´ÆÚÖ´ÐÐÕâЩ¼ì²éÏÂÁîÀ´¼à¿ØÍøÂç´æ´¢×°±¸µÄ״̬¡£
µÚÈý²½£ºÉèÖùÊÕϻָ´
µ±±¬·¢¹ÊÕÏʱ£¬ÎÒÃÇÏ£ÍûÄܹ»×Ô¶¯¾ÙÐйÊÕϻָ´¡£ÔÚNagiosÖУ¬¿ÉÒÔʹÓÃÊÂÎñ´¦ÀíÆ÷À´ÊµÏÖ¹ÊÕϻָ´µÄ×Ô¶¯»¯¡£
½¨ÉèÒ»¸öÊÂÎñ´¦ÀíÆ÷¾ç±¾£¬ÒÔ±ãÔÚ±¬·¢¹ÊÕÏʱִÐлָ´²Ù×÷¡£ÒÔÏÂÊÇÒ»¸öʾÀý¾ç±¾£º
#!/bin/bash case "$1" in HOST) /etc/init.d/network_storage_recovery restart ;; *) echo "Unknown type: $1" exit 1 ;; esac exit 0
µÇ¼ºó¸´ÖÆ
ÉÏÊö¾ç±¾Æ¾Ö¤²î±ðµÄ¹ÊÕÏÀàÐÍÖ´Ðвî±ðµÄ¹ÊÕϻָ´²Ù×÷¡£¾ç±¾ÐèҪƾ֤ÏÖÕæÏàÐξÙÐÐÐ޸ģ¬ÒÔÈ·±£ÔÚ±¬·¢¹ÊÕÏʱ¿ÉÒÔÓÐÓõػָ´Ð§ÀÍ¡£
±à¼NagiosÉèÖÃÎļþ£¬½«ÊÂÎñ´¦ÀíÆ÷¾ç±¾Ìí¼Óµ½ÉèÖÃÎļþÖС£ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁ
sudo nano /etc/nagios3/nagios.cfg
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÔÚÉèÖÃÎļþÖУ¬ÕÒµ½ÒÔÏÂÐУº
event_handler_enabled=0
µÇ¼ºó¸´ÖÆ
½«Æä¸ÄΪ£º
event_handler_enabled=1
µÇ¼ºó¸´ÖÆ
È»ºóÕÒµ½ÒÔÏÂÐУº
event_handler=/path/to/event_handler
µÇ¼ºó¸´ÖÆ
½«Æä¸ÄΪ£º
event_handler=/path/to/event_handler_script
µÇ¼ºó¸´ÖÆ
ÉúÑIJ¢¹Ø±ÕÉèÖÃÎļþ£¬²¢ÖØÐÂÆô¶¯NagiosЧÀÍ¡£
ͨ¹ýÉÏÊö°ì·¨£¬ÎÒÃÇ¿ÉÒÔÔÚLinuxÉÏÉèÖø߿ÉÓõÄÍøÂç´æ´¢¼à¿Ø¡£Ê¹ÓÃNagios×÷Ϊ¼à¿Ø¹¤¾ß£¬ÎÒÃÇ¿ÉÒÔ°´ÆÚ¼ì²éÍøÂç´æ´¢×°±¸µÄ״̬£¬²¢ÔÚ±¬·¢¹ÊÕÏʱ¾ÙÐÐ×Ô¶¯µÄ¹ÊÕϻָ´¡£ÕâÑù¿ÉÒÔÈ·±£ÍøÂç´æ´¢µÄ¿ÉÓÃÐÔºÍÊý¾ÝµÄÇå¾²ÐÔ¡£
±¾ÎÄÌṩÁËÒ»¸ö»ù±¾µÄÉèÖÃʾÀý£¬¶ÁÕß¿ÉÒÔƾ֤ÏÖÕæÏàÐξÙÐÐÏìÓ¦µÄÐ޸ĺÍÀ©Õ¹¡£Í¨¹ýʹÓÃÊʵ±µÄ¼à¿Ø¹¤¾ßºÍÏà¹ØÉèÖ㬿ÉÒÔÌá¸ßÍøÂç´æ´¢µÄ¿É¿¿ÐԺ͸߿ÉÓÃÐÔ£¬±£»¤Ö÷ÒªÊý¾ÝµÄÇå¾²¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÍøÂç´æ´¢¼à¿ØµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡