这几项的监控相对比较简单:
客户端:
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
亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。