SQL Server 2005 Templates

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
TeoriABiFo
Posts: 5
Joined: Fri Jun 11, 2010 10:33 am

SQL Server 2005 Templates

Post by TeoriABiFo »

Hi!
Im running Cacti Version 0.8.7e under Red Hat Enterprise Linux Server release 5.4 (Tikanga).

Is there a Template to create graphics for SQL Server 2005?
I've read that Microsoft SQL Server 2005 doesnt have SNMP support anymore so i need to monitor it with WMI.
I've found only:
http://forums.cacti.net/about5225.html
http://forums.cacti.net/about5265.html

Is there something else? Cause it say there that those are for SQL Server 2000.

Thanks in advance.

Regards.
denyingthetruth
Posts: 23
Joined: Wed May 26, 2010 9:13 pm

Post by denyingthetruth »

yeah I really need this too.please help.
I need to monitor process blocking on SQL server 2000 or 2005.
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

SQL Server graphs

Post by lints »

I don't have a graph specifically for blocked processes, but it should be easy to modify my script to provide the right information, and then make the graph from there.

These graphs/data sources don't use WMI, but instead rely on the Script Server and PHP's mssql functions to connect directly to the SQL service and get the performance counters.

Since I don't use FQDNs as hostnames in my installation of Cacti, I connect to the IP and port of the SQL instance instead of hostname/instance name. The port is set to 1433 as the default, but it can be overwritten on a per-data source basis when you create the graph. I've also setup the script to have a hard-coded username/password, but like the port number, it can be overwritten on a per-graph basis.

The login that these graphs use can be either an SQL account, or an NT account with rights on the SQL server. Attached are a couple of SQL scripts (for the 2000, the other for 2005/2008) that will create an SQL login and grant the appropriate permissions to poll the performance counters.

The only other thing to note is that I'm using MemCache to speed up the polling process of the graphs for a given host. The first time the function runs, it fetches the data from the SQL server and stores it in the cache. Subsequent calls to the function will use the data in the cache if it exists. I'll admit that there's no 'lock' process to make sure that only 1 function call at a time polls the server, but I don't think it's needed. In any event, it should be easy to implement.
Attachments
cacti_host_template_windows_-_sql_server.xml
Host Template for the SQL Server. Exported from Cacti 0.8.7e.
(150.74 KiB) Downloaded 2355 times
ss_win_mssql.txt
Script Server script. Change the extension to 'php' and place in the scripts folder on your server.
CHANGE USERNAME AND PASSWORD
(6.26 KiB) Downloaded 2730 times
sql_server_2000.txt
SQL 2000 script to create a login and grant it the permissions needed for the graphs.
CHANGE USERNAME AND PASSWORD
(373 Bytes) Downloaded 1184 times
sql_server_2005-2008.txt
SQL 2005/2008 script to create a login and grant it the permissions needed for the graphs.
CHANGE USERNAME AND PASSWORD
(433 Bytes) Downloaded 2666 times
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

Examples of the graphs the templates create.
Attachments
Backup/Restore I/O<br />Buffer Cache<br />Connections
Backup/Restore I/O
Buffer Cache
Connections
example_1.PNG (66.63 KiB) Viewed 27649 times
Log Cache<br />Log Flushes<br />Log Flush I/O
Log Cache
Log Flushes
Log Flush I/O
example_2.PNG (69.67 KiB) Viewed 27649 times
Memory<br />Page I/O<br />Page Splits
Memory
Page I/O
Page Splits
example_3.PNG (71.23 KiB) Viewed 27649 times
Procedure Cache<br />SQL Compliations<br />Table Scans
Procedure Cache
SQL Compliations
Table Scans
example_4.PNG (79.38 KiB) Viewed 27649 times
Temporary Tables<br />Transactions
Temporary Tables
Transactions
example_5.PNG (49.36 KiB) Viewed 27649 times
denyingthetruth
Posts: 23
Joined: Wed May 26, 2010 9:13 pm

Re: SQL Server graphs

Post by denyingthetruth »

lints wrote:I don't have a graph specifically for blocked processes, but it should be easy to modify my script to provide the right information, and then make the graph from there.

These graphs/data sources don't use WMI, but instead rely on the Script Server and PHP's mssql functions to connect directly to the SQL service and get the performance counters.

Since I don't use FQDNs as hostnames in my installation of Cacti, I connect to the IP and port of the SQL instance instead of hostname/instance name. The port is set to 1433 as the default, but it can be overwritten on a per-data source basis when you create the graph. I've also setup the script to have a hard-coded username/password, but like the port number, it can be overwritten on a per-graph basis.

The login that these graphs use can be either an SQL account, or an NT account with rights on the SQL server. Attached are a couple of SQL scripts (for the 2000, the other for 2005/2008) that will create an SQL login and grant the appropriate permissions to poll the performance counters.

The only other thing to note is that I'm using MemCache to speed up the polling process of the graphs for a given host. The first time the function runs, it fetches the data from the SQL server and stores it in the cache. Subsequent calls to the function will use the data in the cache if it exists. I'll admit that there's no 'lock' process to make sure that only 1 function call at a time polls the server, but I don't think it's needed. In any event, it should be easy to implement.
great job lints.huge thanks for making these scripts.
anyway,what "sql_server_2005-2008.txt" is for? is it a query that we must execute on ms sql server?
sorry for the stupid question.
denyingthetruth
Posts: 23
Joined: Wed May 26, 2010 9:13 pm

Post by denyingthetruth »

also which username and password to change?
maybe you can make the fonts bold on which parts to change.

sorry i'm really new on cacti.
dionvdc
Posts: 46
Joined: Tue Feb 16, 2010 3:54 pm

Re: SQL Server graphs

Post by dionvdc »

denyingthetruth wrote:
great job lints.huge thanks for making these scripts.
anyway,what "sql_server_2005-2008.txt" is for? is it a query that we must execute on ms sql server?
sorry for the stupid question.
that is a txt file with SQL command used to create an USER which is GRANTED right to the performance counters.

You need to import or execute those commands into every SQL server you want to monitor
dionvdc
Posts: 46
Joined: Tue Feb 16, 2010 3:54 pm

Post by dionvdc »

denyingthetruth wrote:also which username and password to change?
maybe you can make the fonts bold on which parts to change.

sorry i'm really new on cacti.
Well the first you could have figured out yourself

{snipped from the 2005/2008 txt file}
CREATE LOGIN [cactistats] WITH PASSWORD=N'CHANGEME', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF

The second one is on line 21 & 22 ine ss_win_mssql_104 txt file.
{[snippet from mentioned file}
$password = ($password == NULL ? 'graphit' : $password);

Don't forget to change the extention to .php as its run by the scriptserver.
User avatar
Linegod
Developer
Posts: 1626
Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:

Post by Linegod »

If you get a chance, please post these to the templates area of the Docs site:

http://docs.cacti.net/templates
http://docs.cacti.net/templates.guidelines
--
Live fast, die young
You're sucking up my bandwidth.

J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

dionvdc wrote:
denyingthetruth wrote:also which username and password to change?
maybe you can make the fonts bold on which parts to change.

sorry i'm really new on cacti.
Well the first you could have figured out yourself

{snipped from the 2005/2008 txt file}
CREATE LOGIN [cactistats] WITH PASSWORD=N'CHANGEME', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF

The second one is on line 21 & 22 ine ss_win_mssql_104 txt file.
{[snippet from mentioned file}
$password = ($password == NULL ? 'graphit' : $password);

Don't forget to change the extention to .php as its run by the scriptserver.
Well it seems my work here is done :). Thanks dionvdc.
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

Linegod wrote:If you get a chance, please post these to the templates area of the Docs site:

http://docs.cacti.net/templates
http://docs.cacti.net/templates.guidelines
Done and done: http://docs.cacti.net/usertemplate:host ... :sqlserver
Last edited by lints on Fri Jun 18, 2010 10:28 am, edited 1 time in total.
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

Interesting thing for me is that I can't seem to get these to return any data. Even running the output from the poller (cache) directly into the command line returns no data ?

Odd...
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

Strange indeed.

No data as in you get all 0's or nothing at all?

Do you have the MSSQL module loaded in PHP?
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

Nothing at all. Don't think I have MSSQL support in PHP, as it's not supported directly in Ubuntu (I think) :(

Is this for Windows ?
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

No, I'm running CentOS 5.4 x64. Besides, it should be platform independent as it relies on the PHP extension and not anything platform specific.

On my system it was just a matter of running 'yum install php-mssql', so it might be the same on Ubuntu (but with apt-get install) instead.

Edit: I just did a quick Google search for some ideas, and it looks like the 'php5-sybase' package has what you need: http://packages.ubuntu.com/lucid/php5-sybase
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests