问题描述:
今天想有没有监控主机内存的插件可以供nagios来使用,然后找到一个插件check_linux_stats.pl
但是在将脚本上传之后,执行的时候报错
[root@testvm02 libexec]# ./check_linux_stats.pl -T -w 2000000000 -c 3000000000 -p /var/run/jonas.pid Can't locate Sys/Statistics/Linux.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 ./check_linux_stats.pl line 35. BEGIN failed--compilation aborted at ./check_linux_stats.pl line 35.
处理过程:
1.通过以上分析应该是少了perl的模块,下载perl-Sys-Statistics-Linux-0.59-3.el6.noarch.rpm软件包,并且安装
[root@testvm03 software]# rpm -ivh perl-Sys-Statistics-Linux-0.59-3.el6.noarch.rpm warning: perl-Sys-Statistics-Linux-0.59-3.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY error: Failed dependencies: perl(Time::HiRes) is needed by perl-Sys-Statistics-Linux-0.59-3.el6.noarch
备注:通过以上信息,发现又少了依赖包perl-Time-HiRes-1.9721-144.el6.x86_64.rpm
perl-Sys-Statistics-Linux RPM包下载地址:
http://rpmfind.net/linux/epel/6/x86_64/Packages/p/perl-Sys-Statistics-Linux-0.59-3.el6.noarch.rpm
2.下载并且安装perl-Time-HiRes-1.9721-144.el6.x86_64.rpm(这个RPM包在系统镜像ISO里面有)
[root@testvm03 software]# rpm -ivh perl-Time-HiRes-1.9721-136.el6.x86_64.rpm warning: perl-Time-HiRes-1.9721-136.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:perl-Time-HiRes ########################################### [100%]
再安装perl-Sys-Statistics包:
[root@testvm03 software]# rpm -ivh perl-Sys-Statistics-Linux-0.59-3.el6.noarch.rpm warning: perl-Sys-Statistics-Linux-0.59-3.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:perl-Sys-Statistics-Lin########################################### [100%]
备注:脚本执行需要依赖的软件包安装完成.
3.执行脚本(插件命令)
[root@testvm03 libexec]# ./check_linux_stats -M -w 99,50 -c 100,50 #备注:原脚本后缀为.pl,为了使用方便已经通过mv将后缀去掉了. MEMORY OK : Mem used: 6.96%, Swap used: 0.00% |MemUsed=6.96%;99;100 SwapUsed=0.00%;50;50 MemCached=5.58% SwapCached=0.00% Active=4.11%
备注:命令执行成功,那么就可以把这个脚本加入nagios的命令中了.
插件check_linux_stats/details地址(下载和基本使用):
https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_linux_stats/details
文档创建时间:2018年8月14日11:03:38