设为首页 收藏本站
查看: 1871|回复: 1

nagios监控插件 nagios_oracle_health+check_linux_stats.pl

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-6-24 08:52:35 | 显示全部楼层 |阅读模式
一.安装nagios_oracle_health插件项目地址:https://labs.consol.de/nagios/check_mysql_health/
1.查看perl包有没有安装。
[iyunv@DB02 ~]# rpm -qa|grep perl
perl-Test-Simple-0.92-136.el6.x86_64
perl-ExtUtils-MakeMaker-6.55-136.el6.x86_64
perl-version-0.77-136.el6.x86_64
perl-ExtUtils-ParseXS-2.2003.0-136.el6.x86_64
perl-libs-5.10.1-136.el6.x86_64
perl-5.10.1-136.el6.x86_64
perl-CGI-3.51-136.el6.x86_64
perl-devel-5.10.1-136.el6.x86_64
perl-Pod-Escapes-1.04-136.el6.x86_64
perl-Pod-Simple-3.13-136.el6.x86_64
perl-Test-Harness-3.17-136.el6.x86_64
perl-Module-Pluggable-3.90-136.el6.x86_64
[iyunv@DB02 ~]# perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
Copyright 1987-2009, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

从执行上面的两个命令好,可以看到perl包安装正常

2.安装DBI
tar -zxvf DBI-1.636.tar.gz
cd DBI-1.636
perl Makefile.PL
make all
make install

3.安装DBD-Oracle

tar -zxvf DBD-Oracle-1.74.tar.gz
cd DBD-Oracle-1.74
perl Makefile.PL

执行命令报错如下:
[iyunv@DB01 DBD-Oracle-1.74]# perl Makefile.PL
Multiple copies of Driver.xst found in: /usr/local/lib64/perl5/auto/DBI/ /usr/lib64/perl5/auto/DBI/ at Makefile.PL line 39
Using DBI 1.636 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/local/lib64/perl5/auto/DBI/

Configuring DBD::Oracle for perl 5.010001 on linux (x86_64-linux-thread-multi)

Remember to actually *READ* the README file! Especially if you have any problems.

Trying to find an ORACLE_HOME
Your LD_LIBRARY_PATH env var is set to ''

      The ORACLE_HOME environment variable is not set and I couldn't guess it.
      It must be set to hold the path to an Oracle installation directory
      on this machine (or a machine with a compatible architecture).
      See the appropriate README file for your OS for more information.
      ABORTED!

解决方法:在root的bash_profile里面添加下面的代码#这里是现网的数据库的环境变量的配置
ORACLE_BASE=/u01/oracle/app
ORACLE_HOME=$ORACLE_BASE/product/11g/dbhome_1
ORACLE_SID=kdzfw
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin:$ORACLE_HOME/OPatch
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH
source .bash_profile
重新执行命令perl Makefile.PL
make all
make install



登录数据库,建个nagios帐号,并授予一些权限。
create user nagios identified by oradbmon;grant create session to nagios;grant select any dictionary to nagios;grant select on V_$SYSSTAT to nagios;grant select on V_$INSTANCE to nagios;grant select on V_$LOG to nagios;grant select on SYS.DBA_DATA_FILES to nagios;grant select on SYS.DBA_FREE_SPACE to nagios;



4.安装check_oracle_health
tar -zxvf check_oracle_health-2.1.3.5.tar.gz
cd check_oracle_health-2.1.3.5
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-mymodules-dir=/usr/local/nagios/libexec --with-mymodules-dyn-dir=/usr/local/nagios/libexec
make all
make install

5.使用oracle用户运行测试脚本:如下的输出说明插件工作正常。
./check_oracle_health --connect=orcl --username=nagios --password= oradbmon --mode=tnsping
OK - connection established to orcl.

6.把oracle下面的环境变量复制到root下的bash_profile里面,并执行source bash_profile使配置立即生效。

7.在被监控机上定义一个服务,监控表空间,在客户机的nrpe.cfg里配置监控命令。
command[check_tablespace]=/usr/local/nagios/libexec/check_oracle_health --connect kdzfw --username nagios --password oradbmon --warning 95 --critical 98 --mode tablespace-usage
注意:把nrpe.cfg配置文件里的dont_blame_nrpe=1,允许命令后可以带一些参数。


使用脚本在本地测试使用脚本监控表空间,显示正常,如下所示:

[oracle@DB01 libexec]$ /usr/local/nagios/libexec/check_oracle_health --connect kdzfw --username nagios --password oradbmon --warning 95 --critical 98 --mode tablespace-usage
OK - tbs VIPC usage is 0.00%, tbs USERS usage is 0.90%, tbs UNDOTBS1 usage is 0.05%, tbs TEMP usage is 0.01%, tbs SYSTEM usage is 2.65%, tbs SYSAUX usage is 2.65%, tbs SPTESTREADER usage is 0.00%, tbs SPTESTIM usage is 0.36%, tbs MAINTAIN usage is 0.05%, tbs INDX usage is 29.67%, tbs BTEST usage is 51.32% | 'tbs_vipc_usage_pct'=0.00%;95;98 'tbs_vipc_usage'=1MB;31129;32112;0;32767 'tbs_vipc_alloc'=1024MB;;;0;32767 'tbs_users_usage_pct'=0.90%;95;98 'tbs_users_usage'=294MB;31129;32112;0;32767 'tbs_users_alloc'=310MB;;;0;32767 'tbs_undotbs1_usage_pct'=0.05%;95;98 'tbs_undotbs1_usage'=16MB;31129;32112;0;32767 'tbs_undotbs1_alloc'=825MB;;;0;32767 'tbs_temp_usage_pct'=0.01%;95;98 'tbs_temp_usage'=2MB;31129;32112;0;32767 'tbs_temp_alloc'=1203MB;;;0;32767 'tbs_system_usage_pct'=2.65%;95;98 'tbs_system_usage'=869MB;31129;32112;0;32767 'tbs_system_alloc'=930MB;;;0;32767 'tbs_sysaux_usage_pct'=2.65%;95;98 'tbs_sysaux_usage'=867MB;31129;32112;0;32767 'tbs_sysaux_alloc'=920MB;;;0;32767 'tbs_sptestreader_usage_pct'=0.00%;95;98 'tbs_sptestreader_usage'=1MB;31129;32112;0;32767 'tbs_sptestreader_alloc'=1024MB;;;0;32767 'tbs_sptestim_usage_pct'=0.36%;95;98 'tbs_sptestim_usage'=119MB;31129;32112;0;32767 'tbs_sptestim_alloc'=1024MB;;;0;32767 'tbs_maintain_usage_pct'=0.05%;95;98 'tbs_maintain_usage'=1MB;1945;2007;0;2048 'tbs_maintain_alloc'=1024MB;;;0;2048 'tbs_indx_usage_pct'=29.67%;95;98 'tbs_indx_usage'=9721MB;31129;32112;0;32767 'tbs_indx_alloc'=11024MB;;;0;32767 'tbs_btest_usage_pct'=51.32%;95;98 'tbs_btest_usage'=50451MB;93388;96337;0;98303 'tbs_btest_alloc'=71680MB;;;0;98303


8.服务端使用的是nagiosql管理工具,在里面配置相应的服务。

QQ截图20160624085055.png

9.nagios展示的效果:

wKioL1drtrWjsuVdAAASjGxf194418.png-wh_500x0-wm_3-wmp_4-s_980054430.jpg
QQ截图20160624085100.png

二.安装check_linux_stats.pl脚本
1.先安装perl-UNIVERSAL-require-0.13-1.el6.rf.noarch.rpm,这里是rpm包。

[iyunv@DB02 huaxia]# rpm -ivh perl-UNIVERSAL-require-0.13-1.el6.rf.noarch.rpm
warning: perl-UNIVERSAL-require-0.13-1.el6.rf.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...                ########################################### [100%]
   1:perl-UNIVERSAL-require ########################################### [100%]
[iyunv@DB02 huaxia]# rpm -qa|grep perl-UNIVERSAL-require
perl-UNIVERSAL-require-0.13-1.el6.rf.noarch

2.安装Sys-Statistics-Linux
tar -zxvf Sys-Statistics-Linux-0.66.tar.gz
cd Sys-Statistics-Linux-0.66
[iyunv@DB02 Sys-Statistics-Linux-0.66]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Time::HiRes 0 not found.#报错!
Writing Makefile for Sys::Statistics::Linux

解决方法:yum -y install perl-Time-HiRes

重新执行:
[iyunv@DB02 Sys-Statistics-Linux-0.66]# perl Makefile.PL
Writing Makefile for Sys::Statistics::Linux

make all
make install

3.下载check_linux_stats.pl监控脚本,并把脚本放到/usr/local/nagios/libexec的插件目录里
执行./check_linux_stats.pl,可以看到该脚本可以监控很多参数。

[oracle@DB02 libexec]$ ./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

[oracle@DB02 libexec]$ ./check_linux_stats.pl -M -w 90 -c 95#测试了下内存,显示正常。
MEMORY CRITICAL : Mem used: 97.96%, Swap used: 0.96% |MemUsed=97.96%;90;95 SwapUsed=0.96;; MemCached=91.65 SwapCached=0.21 Active=60.85

4.在客户机的nrpe.cfg里面加入几项监控的服务。

command[check_HA_servhamachine]=/usr/local/nagios/libexec/check_procs -w $ARG1$ -c $ARG2$ -C $ARG3$
command[check_linux_stats_root]=/usr/local/nagios/libexec/check_linux_stats.pl -D -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_linux_stats_load]=/usr/local/nagios/libexec/check_linux_stats.pl -L -w $ARG1$ -c $ARG2$            
command[check_linux_stats_cpu]=/usr/local/nagios/libexec/check_linux_stats.pl -C -w $ARG1$ -c $ARG2$ -s $ARG3$
command[check_linux_stats_mem]=/usr/local/nagios/libexec/check_linux_stats.pl -M -w $ARG1$ -c $ARG2$

5.服务器端用的是nagiosql,在里面把这几个监控项加一下。
QQ截图20160624085109.png
QQ截图20160624085115.png
QQ截图20160624085120.png
QQ截图20160624085125.png
6.nagios服务端的展示效果。
QQ截图20160624085130.png



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-234389-1-1.html 上篇帖子: nagios添加主机组,服务组,联系组 下篇帖子: nagios自定义监控硬盘脚本 监控
累计签到:4 天
连续签到:1 天
发表于 2016-8-5 10:36:45 | 显示全部楼层
nagiosql这个好像是个好东西 哪里有下载?

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表