cacti监控mssql 2005运行资源情况

概述:SQL Server200020052008本身不支持snmp,使用cacti监控mssql,必须通过php连接mssql来获取SQL 2005性能计算器的值。

操作步骤:

1.php连接mssql的freetds工具

[root@sky9896 /]# yum install freetds –y

2.安装php-mssql驱动

[root@sky9896 /]# yum install php-mysql -y

3.测试mssql的连接

[root@sky9896 /]#php –q test_mssql_connect.php

#详细代码请下载附件

4.下载好插件后配置监控脚本

(1)在sql sever新建一个监控用户账号,              

sql scriptssql_server_2005-2008.sql中的内容导入到sql server2005中,其中用户和密码根据实际情况可以修改,代码详见附件。

(2)测试监控mssql连接:php -q test_mssql_connect.php用户连接:# php  test_dm_os_performance_counters.php

#详细代码,请见附件。

(3)填加监控脚本:将解压后的scriptsss_win_mssql.php上传到cacti服务器的cacti目录下的scripts/下,并赋予权限。

[root@sky9896 scripts]# chmod 755 ss_win_mssql.php

如果没有安装memcached的话。需要将memcached有关的行注释掉。否则无法取到mssql的数据,详见附近。

(4)测试监控脚本:

/usr/bin/php -q /var/www/html/cacti/scripts/ss_win_mssql.php  监控服务IP  connetions 用户名  密码

执行上条语名后,出现以下结果,说明测试成功。

fullscans:4167 rangescans:611197 probescans:130196372 indexsearches:3420215

(5)导入模板:解压后的templatecacti_host_template_windows_-_sql_server.xml导入到cacti中 

Console → Import/Export → Import Templates  → 选择文件 → Import 

导入后的Host Templates名为 Windows - SQL Server

导入后graph templates包含:

    Windows - SQL Server - Backup/Restore I/O

    Windows - SQL Server - Buffer Cache

    Windows - SQL Server - Connections

    Windows - SQL Server - Log Cache

    Windows - SQL Server - Log Flush I/O

    Windows - SQL Server - Log Flushes

    Windows - SQL Server - Memory

    Windows - SQL Server - Page I/O

    Windows - SQL Server - Page Splits

    Windows - SQL Server - Procedure Cache

    Windows - SQL Server - Processes Blocked

    Windows - SQL Server - SQL Compilations

    Windows - SQL Server - Table Scans

    Windows - SQL Server - Temp Tables

    Windows - SQL Server - Transactions

(6)新建devices省略,注意一个问题,在“Graph Templates”中选择要监控的项,点“Create”后出现“Create Graphs from Data Query ”中要求填写sql server的端口号、用户名、密码。此处如果不填写,将直接使用前面在ss_win_mssql.php中填写的端口号、用户名、密码,后续Data Source List 、*Graph List 等操作省略了。

   小结,成功配置cacti监控mssql2005,要注意几个事项:

1.  必须安装好一个freetds工具,一个php-mssql驱动;

2.  数据库端(被监控服务端)通过一段代码增加用户名和密码;

3.  用一小段代码测试数据库和用户的连接;

4.  本生产服务器没有安装memcached,需要将memcached有关的行注释掉,否则无法取到mssql的数据。

5.  对模板的导入,脚本文件的上传修改也要比较熟悉。

              wKioL1ad9eHxLUIFAAD9J-s6SaI986.png

  cacti模版地址:https://forums.cacti.net/viewforum.php?f=12&sid=66aa5b74a320c23ef7d38e190559f952

         https://docs.cacti.net/templates

原文地址:https://www.cnblogs.com/l1pe1/p/7809829.html