nagios 监控sql server 数据库

1、下载需要的插件并安装

wget http://labs.consol.de/download/shinken-nagios-plugins/check_mssql_health-1.5.19.1.tar.gz

安装:check_mssql_health

tar zxvf check_mssql_health-1.5.19.1.tar.gz

cd check_mssql_health-1.5.19.1

./configure -–with-nagios-user=nagios -–with-nagios-group=nagcmd–-prefix=/usr/local/nagios/

make

make install

2、安装与sqlserver通信需要的软件

1、安装freetds

安装包:freetds-0.91.tar.zip

unzip freetds-0.91.tar.zip

tar zxvf freetds-0.91.tar.gz

cd freetds-0.91

./configure –prefix=/usr/local/freetds–with-tdsver=8.0 –enable-msdblib

make && make install

2、设置环境变量并安装freetds-devlibdbd-freetds

vim /etc/profile   添加如下行

export SYBASE=/usr/local/freetds


source /etc/profile 让配置立即生效

echo “/usr/local/freetds/lib/” >/etc/ld.so.conf.d/freetds.conf

/sbin/ldconfig


apt-get install freetds-dev libdbd-freetds

3、安装DBI

tar zxvf DBI-1.627.tar.gz

cd DBI-1.627

perl Makefile.PL

make

make test (测试是否正确可不测试)

make install

4、安装DBD-Sybase

tar zxvf DBD-Sybase-1.15.tar.gz

cd DBD-Sybase-1.15

perl Makefile.PL

make

make test

make install

5、修改配置文件

vim /usr/local/freetds/etc/freetds.conf

[global]


;       tds version = 8.0

;       dump file =/tmp/freetds.log

;       debug flags = 0xffff


       # Command andconnection timeouts

;       timeout = 10

;       connect timeout = 10


       # If you getout-of-memory errors, it may mean that your client

       # is trying toallocate a huge buffer for a TEXT field.

       # Try setting 'textsize' to a more reasonable limit

       text size = 64512



[231sql]

       host =192.168.10.231

       port = 1433

           tds version = 8.0

6、测试

cd /usr/local/nagios/libexec

./check_mssql_health -server 231sql -usernagios -password nagios -mode list-databases

显示如下:

ReportServer

ReportServerTempDB

TSNRReportGuest

master

model

msdb

tempdb

OK - have fun (成功)

本文内容有部分来自网上,经本人整理写出。