nagios外掛程式指令碼check_linux_stats.pl 安裝

來源:互聯網
上載者:User

標籤: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 <pattern> -w <warning> -c <critical> [-s <sleep>] [-u <unit>] [-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,eth1...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

 

運行正常!

 

 

 

 

本文出自 “伺服器營運” 部落格,請務必保留此出處http://shamereedwine.blog.51cto.com/5476890/1768235

nagios外掛程式指令碼check_linux_stats.pl 安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.