资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

nagios插件脚本check_linux_stats.pl安装-创新互联

有的时候监控CPU内存使用率的情况时,nagios自身多带的插件有一些缺陷。

创新互联公司专注于龙南企业网站建设,响应式网站建设,成都做商城网站。龙南网站建设公司,为龙南等地区提供建站服务。全流程定制网站建设,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务

我们下面使用check_linux_stats.pl这个perl脚本来监控系统运行的一些参数。

我们到https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_linux_stats/details上下载check_linux_stats.pl插件,把插件放到nagios的libexec的目录里。

同时,我们还需要安装Perl插件,下载地址是http://search.cpan.org/CPAN/authors/id/B/BL/BLOONIX/Sys-Statistics-Linux-0.66.tar.gz

执行安装:

 tar -zxvf Sys-Statistics-Linux-0.66.tar.gz

 cd Sys-Statistics-Linux-0.66

 ls

 less INSTALL

 perl Makefile.PL#报错如下

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 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.

解决方法

安装perl-UNIVERSAL-require-0.13-1.el6.rf.noarch.rpm

rpm -ivh perl-UNIVERSAL-require-0.13-1.el6.rf.noarch.rpm

还是报错

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 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.

解决方法

yum install -y perl-devel

然后执行安装

perl Makefile.PL

make

make test#执行该命令可能会报错,不用管

make install

执行/usr/local/nagios/libexec/check_linux_stats.pl,又报错:

Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/nagios/libexec /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 /usr/local/share/perl5/Sys/Statistics/Linux/Processes.pm line 177.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Sys/Statistics/Linux/Processes.pm line 177.
Compilation failed in require at ./check_linux_stats.pl line 34.
BEGIN failed--compilation aborted at ./check_linux_stats.pl line 34.

解决方法

yum -y install perl-Time-HiRes

然后执行:

./check_linux_stats.pl --help
check_linux_stats v1.3.1
Usage: ./check_linux_stats.pl -C|-P|-M|-N|-D|-I|-L|-F|-S|-W|-U -p -w -c [-s ] [-u ] [-V] [-h]
 -h, --help
    print this help message
 -C, --cpu=CPU USAGE
 -P, --procs
 -M, --memory=MEMORY USAGE
 -N, --network=NETWORK USAGE
 -D, --disk=DISK USAGE
 -I, --io=DISK IO USAGE
 -L, --load=LOAD AVERAGE
 -F, --file=FILE STATS
 -S, --socket=SOCKET STATS
 -W, --paging=PAGING AND SWAPPING STATS
 -U, --uptime
 -p, --pattern
  eth0,eth2...sda1,sda2.../usr,/tmp
 -w, --warning
 -c, --critical
 -s, --sleep
 -u, --unit
              %, KB, MB or GB left on disk usage, default : MB
       REQS OR BYTES on disk io statistics, default : REQS
 -V, --version
  version number

 ex :
 Memory usage                   : perl check_linux_stats.pl -M -w 90 -c 95
 Cpu usage                      : perl check_linux_stats.pl -C -w 90 -c 95 -s 5
 Disk usage                     : perl check_linux_stats.pl -D -w 95 -c 100 -u % -p /tmp,/usr,/var
 Load average                   : perl check_linux_stats.pl -L -w 10,8,5 -c 20,18,15
 Paging statistics  : perl check_linux_stats.pl -W -w 10,1000 -c 20,2000 -s 3
 Process statistics             : perl check_linux_stats.pl -P -w 100 -c 200
 I/O statistics on disk device  : perl check_linux_stats.pl -I -w 10 -c 5 -p sda1,sda4,sda5,sda6
 Network usage                  : perl check_linux_stats.pl -N -w 10000 -c 100000000 -p eth0
 Processes virtual memory       : perl check_linux_stats.pl -T -w 9551820 -c 9551890 -p /var/run/sendmail.pid
 Uptime    : perl check_linux_stats.pl -U -w 5

运行正常!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文题目:nagios插件脚本check_linux_stats.pl安装-创新互联
网页地址:http://cdkjz.cn/article/jeshe.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220