您好,登錄后才能下訂單哦!
這幾項的監控相對比較簡單:
客戶端:
1 安裝支持包
2 賦予腳本權限
3 添加腳本命令到nrpe,并重啟nrpe.
服務端:
1 添加監控命令check_iostat
2 在對應的服務配置文件里增加監控項目并且設置閥值
3 讓nagios重讀配置文件。
---------------客戶端配置-----------------
Nagios-Plugin-0.31.tar.gz
Params-Validate-0.91.tar.gz
Math-Calc-Units-1.06.tar.gz
Regexp-Common-2.122.tar.gz
下載后,解壓安裝:
perl Makefile.PL make make installfu
2 賦予腳本權限:
mv /opt/src/check_io/check_iostat /usr/local/nagios/libexec/ dos2unix /usr/local/nagios/libexec/check_iostat
chmod 755 /usr/local/nagios/libexec/check_iostat chown nagios.nagios /usr/local/nagios/libexec/check_iostat
3 添加腳本命令到nrpe,并重啟nrpe:
vim /usr/local/nagios/etc/nrpe.cfg 在文件里添加如下: command[check_io]=/usr/local/nagios/libexec/check_iostat
重啟nrpe,由于我的是在xinetd 里面所以和大家的可能有出入。
我的: service xinetd restart
--------------服務端配置----------
1 添加監控命令check_iostat:
vim /usr/local/nagios/etc/objects/commands.cfg
#check_iostat define command{ command_name check_iostat command_line $USER1$/check_iostat -w $ARG1$ -c $ARG2$ }
2 在對應的服務配置文件里增加監控項目并且設置閥值
define service{ use generic-service host_name 被控服務器的IP service_description 9.Check_IO check_command check_nrpe!check_iostat!100!200 }
3 讓nagios重讀配置文件。
service nagios reload
-------------測試部分-----------------
本地:
[root@localhost iostat]# /usr/local/nagios/libexec/check_iostat IOSTAT OK - user 1.62 nice 0.00 sys 0.31 iowait 0.08 idle 0.00 | iowait=0.08%;; idle=0.00%;; user=1.62%;; nice=0.00%;; sys=0.31%;;
nrpe遠程:
[root@localhost iostat]# /usr/local/nagios/libexec/check_nrpe -H 10.2.0.16 -c check_iostat IOSTAT OK - user 0.06 nice 0.00 sys 0.03 iowait 0.01 idle 0.00 | iowait=0.01%;; idle=0.00%;; user=0.06%;; nice=0.00%;; sys=0.03%;;
在來看看 nagios 的web界面
看到了把,已經出現了,我們需要的項目。
附件里面帶了check_mysql,check_mem,兩個監控插件,安裝方法一樣
--------------------------------------------------------------------------
安裝軟件太麻煩了,寫個小腳本幫助自己減少工作量:
#!/bin/bash yum install -y perl-dev* perl-CPAN tar -zxvf Nagios-Plugin-0.31.tar.gz cd Nagios-Plugin-0.31 perl Makefile.PL make && make install cd .. tar -zxvf Params-Validate-0.91.tar.gz cd Params-Validate-0.91 perl Makefile.PL make && make install cd .. tar -zxvf Math-Calc-Units-1.06.tar.gz cd Math-Calc-Units-1.06 perl Makefile.PL make && make install cd .. tar -zxvf Regexp-Common-2.122.tar.gz cd Regexp-Common-2.122 perl Makefile.PL make && make install cd .. tar -zxvf Class-Accessor-0.31.tar.gz cd Class-Accessor-0.31 perl Makefile.PL make && make install cd .. tar -zxvf Config-Tiny-2.12.tar.gz cd Config-Tiny-2.12 perl Makefile.PL make && make install cd .. mv /opt/src/check_io/check_iostat /usr/local/nagios/libexec/ dos2unix /usr/local/nagios/libexec/check_iostat chmod 755 /usr/local/nagios/libexec/check_iostat chown nagios.nagios /usr/local/nagios/libexec/check_iostat
這是安裝時用到的所有軟件
check_iostat 所有的軟件包
-----------排錯-----------
1 錯誤:
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 7.
BEGIN failed--compilation aborted at Makefile.PL line 7.
make: *** No targets specified and no makefile found. Stop.
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
解決方法:
yum install perl-dev* perl-CPAN
關于更多的排錯內容可以查看下面這個文章:
http://151wqooo.blog.51cto.com/2610898/1302784
執行 perl -MCPAN -e 'install Bundle::LWP' perl -MCPAN -e 'install Nagios::Plugin' or cpan -i Nagios::Plugin
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。