nagios監控執行個體

來源:互聯網
上載者:User

標籤:nagios監控執行個體

前面我們寫了nagios的server端和client端的安裝過程,這裡我們寫一下nagios的監控範例


添加監控本機伺服器磁碟,監控/dev/sda3,即/分區

[[email protected] ~]# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/sda3              97G  1.6G   90G   2% /tmpfs                 495M     0  495M   0% /dev/shm/dev/sda1             194M   28M  156M  16% /boot#編輯相應設定檔[[email protected] ~]# vim /usr/local/nagios/etc/objects/commands.cfg #從這個檔案中我們知道該監控指令碼需要3個參數define command{        command_name    check_local_disk        command_line    $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$        }#修改檔案,添加要監控的分區[[email protected] ~]# vim /usr/local/nagios/etc/objects/localhost.cfg define service{        use                             local-service        host_name                       localhost        service_description             disk_monitor        check_command                   check_local_disk!30%!20!/dev/sda3        notifications_enabled           1        }#用命令進行調試[[email protected] ~]# /usr/local/nagios/libexec/check_disk -w 30% -c 20% /dev/sda3DISK OK - free space: / 92072 MB (98% inode=99%);| /=1544MB;69038;78900;0;98626#檢查設定檔[[email protected] ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #重啟nagios服務[[email protected] ~]# service nagios restartRunning configuration check...done.Stopping nagios: done.Starting nagios: done.

    查看結果

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/5F/wKioL1Vi1-3Db99aAAXkpjIDy3I769.jpg" title="disk.jpg" alt="wKioL1Vi1-3Db99aAAXkpjIDy3I769.jpg" />


這裡我們監控我們前一篇文章中的nagios-client:192.168.3.72的sdb

#編輯檔案[[email protected] ~]# vim /usr/local/nagios/etc/nrpe.cfgcommand[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1#添加sdb這一行command[check_sdb]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sdbcommand[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Zcommand[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200 #重啟nrped服務[[email protected] ~]# service nrped restartStopping NRPE daemon... done.Starting NRPE daemon... done.[[email protected] ~]# netstat -anpt |grep nrpetcp        0      0 192.168.3.72:5666           0.0.0.0:*                   LISTEN      1492/nrpe

    在nagios-server:192.168.3.71進行配置

[[email protected] objects]# pwd/usr/local/nagios/etc/objects[[email protected] objects]# vim commands.cfg#在末尾添加如下內容define command{        command_name check_nrpe        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$        }[[email protected] etc]# pwd/usr/local/nagios/etc[[email protected] etc]# vim nagios.cfg#在第36行添加cfg_file=/usr/local/nagios/etc/objects/192.168.3.72.cfg[[email protected] objects]# pwd/usr/local/nagios/etc/objects[[email protected] objects]# cat 192.168.3.72.cfg define host{uselinux-serverhost_name192.168.3.72aliasnagios-clientaddress192.168.3.72}define hostgroup{hostgroup_nameclientsaliaslinux-serversmembers192.168.3.72}define service{uselocal-servicehost_name192.168.3.72service_descriptioncheck_disk_sdbcheck_commandcheck_local_disk!30%!20!/dev/sdbnotifications_enabled1        }#檢查設定檔[[email protected] objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #重啟nagios服務[[email protected] objects]# service nagios restartRunning configuration check...done.Stopping nagios: done.Starting nagios: done.

    查看結果

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/60/wKioL1Vi3V-AX0l7AAGIYp48SZs328.jpg" title="72.jpg" alt="wKioL1Vi3V-AX0l7AAGIYp48SZs328.jpg" />

1

本文出自 “ly36843營運” 部落格,請務必保留此出處http://ly36843.blog.51cto.com/3120113/1654981

nagios監控執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.