SQL Server 2005 Templates

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

Moderators: Developers, Moderators

Post Reply
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

aleu:
I suspect that if you comment out line 10 (the one with 'error_reporting(0);') and re-run the script, you should see some sort of error that will point you in the right direction. Post the results here and we'll see what we can do.

denyingthetruth:
The Proccesses Blocked graph doesn't do anything if you are running it against SQL 2000. The counters are only there in 2005 and up.
To test it, run this against master and post the results:

Code: Select all

SELECT [counter_name], [cntr_value] FROM sys.dm_os_performance_counters
WHERE ([instance_name] = '' OR [instance_name] = '_Total') AND (
([object_name] LIKE ('%Plan Cache%') AND [counter_name] IN 
  ('Cache Hit Ratio', 'Cache Hit Ratio Base')) OR 
([object_name] LIKE ('%Buffer Manager%') AND [counter_name] IN 
  ('Buffer Cache Hit Ratio', 'Buffer Cache Hit Ratio Base', 'Page reads/sec', 'Page writes/sec')) OR 
([object_name] LIKE ('%General Statistics%') AND [counter_name] IN 
  ('Active Temp Tables', 'User Connections', 'Processes blocked')) OR 
([object_name] LIKE ('%Databases%') AND [counter_name] IN 
  ('Transactions/sec', 'Log Cache Hit Ratio', 'Log Cache Hit Ratio Base', 'Log Flushes/sec', 
    'Log Bytes Flushed/sec', 'Backup/Restore Throughput/sec')) OR 
([object_name] LIKE ('%Access Methods%') AND [counter_name] IN 
  ('Full Scans/sec', 'Range Scans/sec', 'Probe Scans/sec', 'Index Searches/sec', 'Page Splits/sec')) OR 
([object_name] LIKE ('%Memory Manager%') AND [counter_name] IN 
  ('Target Server Memory (KB)', 'Target Server Memory(KB)', 'Total Server Memory (KB)')) OR
([object_name] LIKE ('%SQL Statistics%') AND [counter_name] IN 
  ('SQL Compilations/sec', 'SQL Re-Compilations/sec'))
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

lints wrote:aleu:
I suspect that if you comment out line 10 (the one with 'error_reporting(0);') and re-run the script, you should see some sort of error that will point you in the right direction. Post the results here and we'll see what we can do.
Thanks Lints, I see some errors now. Here is the command I run from CLI:

Code: Select all

/usr/bin/php /var/www/cacti/scripts/ss_win_mssql.php ss_win_mssql 10.27.10.42:1397 scans CactiUser CactiPWD
The error says:

Code: Select all

PHP Notice:  Undefined offset: 1 in /var/www/cacti/scripts/ss_win_mssql.php on line 17
PHP Warning:  mssql_connect(): Unable to connect to server: ss_win_mssql:1433 in /var/www/cacti/scripts/ss_win_mssql.php on line 24
After commenting out (deleting) the memcached piece of code my line 17 says:

Code: Select all

list($host, $port) = explode(':', $hostname);
Thus, my two questions. 1) How come the output shows the hardcoded port entry from the php script despite providing 1397 as an input? 2) Why am I seeing the "Undefined offset"? Your help is much appreciated.
denyingthetruth
Posts: 23
Joined: Wed May 26, 2010 9:13 pm

Post by denyingthetruth »

lints wrote:aleu:
I suspect that if you comment out line 10 (the one with 'error_reporting(0);') and re-run the script, you should see some sort of error that will point you in the right direction. Post the results here and we'll see what we can do.

denyingthetruth:
The Proccesses Blocked graph doesn't do anything if you are running it against SQL 2000. The counters are only there in 2005 and up.
To test it, run this against master and post the results:

Code: Select all

SELECT [counter_name], [cntr_value] FROM sys.dm_os_performance_counters
WHERE ([instance_name] = '' OR [instance_name] = '_Total') AND (
([object_name] LIKE ('%Plan Cache%') AND [counter_name] IN 
  ('Cache Hit Ratio', 'Cache Hit Ratio Base')) OR 
([object_name] LIKE ('%Buffer Manager%') AND [counter_name] IN 
  ('Buffer Cache Hit Ratio', 'Buffer Cache Hit Ratio Base', 'Page reads/sec', 'Page writes/sec')) OR 
([object_name] LIKE ('%General Statistics%') AND [counter_name] IN 
  ('Active Temp Tables', 'User Connections', 'Processes blocked')) OR 
([object_name] LIKE ('%Databases%') AND [counter_name] IN 
  ('Transactions/sec', 'Log Cache Hit Ratio', 'Log Cache Hit Ratio Base', 'Log Flushes/sec', 
    'Log Bytes Flushed/sec', 'Backup/Restore Throughput/sec')) OR 
([object_name] LIKE ('%Access Methods%') AND [counter_name] IN 
  ('Full Scans/sec', 'Range Scans/sec', 'Probe Scans/sec', 'Index Searches/sec', 'Page Splits/sec')) OR 
([object_name] LIKE ('%Memory Manager%') AND [counter_name] IN 
  ('Target Server Memory (KB)', 'Target Server Memory(KB)', 'Total Server Memory (KB)')) OR
([object_name] LIKE ('%SQL Statistics%') AND [counter_name] IN 
  ('SQL Compilations/sec', 'SQL Re-Compilations/sec'))
the query returns this:

Code: Select all

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.dm_os_performance_counters'.
When I replace "sys.dm_os_performance_counters" with "sysperfinfo", the query return this data
Image

So do you mean that we can't use your script against MS SQL 2000?
Is there another way to monitor this locks process in MS SQL 2000?

Thx.
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

denyingthetruth:
The Proccesses Blocked graph doesn't do anything if you are running it against SQL 2000
I don't think that this counter is exposed under SQL2000. My guess is that SNMP Informant SQL edition will do this, but beware - $$$$ = NOT CHEAP
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 »

aleu:
If you're testing the script from the command line, you'd have to use

Code: Select all

/usr/bin/php -q /var/www/cacti/scripts/ss_win_mssql.php 10.27.10.42:1397 scans CactiUser CactiPWD
The command you gave is trying to use 'ss_win_mssql' as the hostname and '10.27.10.42:1397' as the data to output.

denyingthetruth:
As far as I can tell, there's no 'blocked processes' counter on SQL2000 available via the performance counters view.

mcutting/denyingthetruth:
I don't even know if SNMP Informant would be able to expose anything because from my experience, it just uses the counters provided through WMI. The views I query in the script are basically just SQL representations of the classes from WMI, so it might not be of any help. That said, I've never tried the SNMP Informant module for SQL Server, so for all I know it might work.
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

lints wrote:aleu:
If you're testing the script from the command line, you'd have to use

Code: Select all

/usr/bin/php -q /var/www/cacti/scripts/ss_win_mssql.php 10.27.10.42:1397 scans CactiUser CactiPWD
The command you gave is trying to use 'ss_win_mssql' as the hostname and '10.27.10.42:1397' as the data to output.
Hmm, it is throwing the below error:

Code: Select all

PHP Warning:  mssql_connect(): Unable to connect to server: 10.27.10.42:1397 in /var/www/cacti/scripts/ss_win_mssql.php.orig on line 31
Line 31 says:

Code: Select all

if (! $link = mssql_connect($host.':'.$port, $username, $password) )
Do you guys have any idea why?
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

aleu wrote:
lints wrote:aleu:
If you're testing the script from the command line, you'd have to use

Code: Select all

/usr/bin/php -q /var/www/cacti/scripts/ss_win_mssql.php 10.27.10.42:1397 scans CactiUser CactiPWD
The command you gave is trying to use 'ss_win_mssql' as the hostname and '10.27.10.42:1397' as the data to output.
Hmm, it is throwing the below error:

Code: Select all

PHP Warning:  mssql_connect(): Unable to connect to server: 10.27.10.42:1397 in /var/www/cacti/scripts/ss_win_mssql.php.orig on line 31
Line 31 says:

Code: Select all

if (! $link = mssql_connect($host.':'.$port, $username, $password) )
Do you guys have any idea why?
You appear to be missing the mssql libraries. If you're using Ubuntu, you can do

sudo apt-get install php5-sybase

This will give you the required libraries.
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

mcutting wrote:You appear to be missing the mssql libraries. If you're using Ubuntu, you can do

sudo apt-get install php5-sybase

This will give you the required libraries.
Per my first post, I have them installed:

Code: Select all

apt-get install php5-sybase
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-sybase is already the newest version.
Here is what techsupport shows:

Code: Select all

mssql
--------------------------------------------------------------------------------

MSSQL Support enabled 
Active Persistent Links  0  
Active Links  0  
Library version  FreeTDS  

Directive Local Value Master Value 
mssql.allow_persistent On On 
mssql.batchsize 0 0 
mssql.charset no value no value 
mssql.compatability_mode Off Off 
mssql.connect_timeout 5 5 
mssql.datetimeconvert On On 
mssql.max_links Unlimited Unlimited 
mssql.max_persistent Unlimited Unlimited 
mssql.max_procs Unlimited Unlimited 
mssql.min_error_severity 10 10 
mssql.min_message_severity 10 10 
mssql.secure_connection Off Off 
mssql.textlimit Server default Server default 
mssql.textsize Server default Server default 
mssql.timeout 60 60 
I do not know whether I need to do something else, though.
denyingthetruth
Posts: 23
Joined: Wed May 26, 2010 9:13 pm

Post by denyingthetruth »

lints wrote: denyingthetruth:
As far as I can tell, there's no 'blocked processes' counter on SQL2000 available via the performance counters view.

mcutting/denyingthetruth:
I don't even know if SNMP Informant would be able to expose anything because from my experience, it just uses the counters provided through WMI. The views I query in the script are basically just SQL representations of the classes from WMI, so it might not be of any help. That said, I've never tried the SNMP Informant module for SQL Server, so for all I know it might work.
but maybe there's something in "sysperfinfo" table that we can use to graph lock process?
here I found some counter names when I run this query:
Image

can we use "number of deadlocks" or the other counter names there?
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

lints wrote:aleu:
If you're testing the script from the command line, you'd have to use

Code: Select all

/usr/bin/php -q /var/www/cacti/scripts/ss_win_mssql.php 10.27.10.42:1397 scans CactiUser CactiPWD
The command you gave is trying to use 'ss_win_mssql' as the hostname and '10.27.10.42:1397' as the data to output.
OK, made some tiny progress (after a number of install/uninstall operations of FreeTDS and php5-sybase):

Code: Select all

09:10:01.689913 IP 10.27.10.90.37040 > 10.27.10.42.1397: Flags [.], ack 1, win 92, options [nop,nop,TS val 37306704 ecr 0], length 0
09:10:01.689913 IP 10.27.10.90.37040 > 10.27.10.42.1397: Flags [P.], seq 1:589, ack 1, win 92, options [nop,nop,TS val 37306704 ecr 0], length 588
09:10:01.689913 IP 10.27.10.42.1397 > 10.27.10.90.37040: Flags [F.], seq 1, ack 589, win 65535, options [nop,nop,TS val 20742488 ecr 37306704], length 0
09:10:01.693914 IP 10.27.10.90.37040 > 10.27.10.42.1397: Flags [.], ack 2, win 92, options [nop,nop,TS val 37306705 ecr 20742488], length 0
09:10:01.693914 IP 10.27.10.90.37040 > 10.27.10.42.1397: Flags [F.], seq 589, ack 2, win 92, options [nop,nop,TS val 37306705 ecr 20742488], length 0
09:10:01.693914 IP 10.27.10.42.1397 > 10.27.10.90.37040: Flags [.], ack 590, win 65535, options [nop,nop,TS val 20742488 ecr 37306705], length 0
As you can see, my Cacti box (10.27.10.90) is now at least sending something out to my SQL server 2005. However, the error I get is still the same:

Code: Select all

/usr/bin/php /var/www/cacti/scripts/ss_win_mssql.php.orig 10.27.10.42:1397 buffercache CactiUser CactiPWD
PHP Warning:  mssql_connect(): Unable to connect to server: 10.27.10.42:1397 in /var/www/cacti/scripts/ss_win_mssql.php.orig on line 31
I am slowly giving up on this one as I cannot figure out why this is happening :cry:
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

This might sound kind of dumb, but do you have a valid login on the SQL box to collect this data ?
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

mcutting wrote:This might sound kind of dumb, but do you have a valid login on the SQL box to collect this data ?
Yes, I have tried a couple of different credentials (all have been granted sufficient rights in MSSQL. The same users can run the queries in MS SQL Manager just fine. The more I think about it, the more I believe that the errors I am seeing are caused becaused of the enabled SSL encryption).

Here is the freetds log:

Code: Select all

token.c:312:tds_process_login_tokens()
util.c:334:tdserror(0x95cc988, 0x9815d68, 20017, 115)
dblib.c:7782:dbperror(0x9814930, 20017, 115)
dblib.c:7835:20017: "Unexpected EOF from the server"
dblib.c:7856:"Unexpected EOF from the server", client returns 2 (INT_CANCEL)
util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:389:tdserror: returning TDS_INT_CANCEL(2)
util.c:162:Changed query state from IDLE to DEAD
token.c:316:looking for login token, got  0()
token.c:108:tds_process_default_tokens() marker is 0()
token.c:111:leaving tds_process_default_tokens() connection dead
util.c:334:tdserror(0x95cc988, 0x9815d68, 20002, 0)
dblib.c:7782:dbperror(0x9814930, 20002, 0)
dblib.c:7835:20002: "Adaptive Server connection failed"
dblib.c:7856:"Adaptive Server connection failed", client returns 2 (INT_CANCEL)
util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:389:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1372:dbclose(0x9814930)
dblib.c:256:dblib_del_connection(0xb7690a00, 0x9815d68)
mem.c:563:tds_free_all_results()
dblib.c:303:dblib_release_tds_ctx(1)
dblib.c:5727:dbfreebuf(0x9814930)
dblib.c:718:dbloginfree(0x9814828)
dblib.c:1442:dbexit(void)
dblib.c:1442:dbexit(void)
dblib.c:303:dblib_release_tds_ctx(1)
Guys, I do not want to waste your time, but would love to hear if someone with forced SSL SQL encryption (MS SQL server 2005 ENT x65) managed to monitor his system from a Linux machine.
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

aleu:
I don't know if you can connect to an SSL encrypted instance of SQL Server from PHP because I've never tried. Have you tried turning off forced SSL encyrption and seeing if it works, even just for a few minutes?
That said, I wouldn't be too surprised if you couldn't get it working with SSL since nothing I've seen online says you can.

denyingthetruth:
You could use the Deadlock counters, but that won't give you the processed blocked because obviously they're different.
As for the other lock counters, they aren't representative of a blocking SPID. Locks are acquired/released on almost every INSERT/UPDATE/DELETE statement to ensure data integrity, so the counters would run up much faster than the blocked process gauge. Also, as with the deadlock counters, this isn't what you're looking for.
I don't know if you're going to find what you need anywhere in SQL 2000.
peterclo
Posts: 4
Joined: Mon Jun 28, 2010 12:18 pm

Post by peterclo »

I'm having the same issue, aleu. I get this error when running the script from the command line under Windows 2003 with PHP 4.4.9 and the mssql lib loaded :
PHP Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-c
onnect</a>]: Unable to connect to server: 192.168.1.18:1433 in c:\Inetpub\wwwroot\Cacti\scripts\ss_win_mssql.php on line 24
I'm not using SSL.
lints
Cacti User
Posts: 107
Joined: Thu Nov 08, 2007 2:00 pm
Location: Ottawa, Canada

Post by lints »

peterclo wrote:I'm having the same issue, aleu. I get this error when running the script from the command line under Windows 2003 with PHP 4.4.9 and the mssql lib loaded :
PHP Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-c
onnect</a>]: Unable to connect to server: 192.168.1.18:1433 in c:\Inetpub\wwwroot\Cacti\scripts\ss_win_mssql.php on line 24
I'm not using SSL.
Can you and aleu change lines 34-35 from:

Code: Select all

if (! $link = mssql_connect($host.':'.$port, $username, $password) )
    return;
to:

Code: Select all

if (! $link = mssql_connect($host.':'.$port, $username, $password) )
    return mssql_get_last_message();
This should spit out some extra messages so we know what's going wrong.
Cacti Version - 0.8.7e
Plugin Architecture - 2.4
Poller Type - Cactid v
Server Info - Linux
Web Server - Apache/2.2.3 (CentOS)
PHP - 5.2.10
MySQL - 5.1.35-log
RRDTool - 1.4.4
------------------------------
As of March 23rd:
Hosts - 564
Graphs - 15274
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests