[REQUEST] MSSQL DB size

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

Moderators: Developers, Moderators

Post Reply
rtyler778
Posts: 8
Joined: Fri Jul 11, 2008 9:17 am

[REQUEST] MSSQL DB size

Post by rtyler778 »

I am looking for a way to monitor MSSQL database size...

I need to graph DB growth on databases on multiple MSSQL 2000 servers.

I am not needing specific table growth, just overal DB size...

Thank you in advance for any help
rtyler778
Posts: 8
Joined: Fri Jul 11, 2008 9:17 am

Post by rtyler778 »

Edit...

My cacti is running on the latest ubuntu...

MSSQL is running on Win2k3 Serv Ent R2

Thanks again!
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Post by streaker69 »

Here's a script that I wrote a while ago and never did anything with. It will output a list of database sizes as well as cache hit ratio. If you don't need the cache hit ration, just comment those lines out or don't bother mapping them in your dataquery.

Code: Select all

#!/usr/bin/perl 

# Replace '/usr/local/nagios/libexec/check_nt' with the localtion where your check_nt binary is located 
# Usage: perl ms_dbsize.pl <hostname> <MSSQL Instance Name> <Database1,database2,database3>
# eg: perl ms_dbsize.pl server SQLSDE USERS,COLLECTIONS,MAINTENANCE


$CheckNTPath='/usr/local/nagios/libexec';

@array1 = split(/\,/, $ARGV[2]);

foreach $dbname (@array1)
{
$dbSize = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\MSSQL\$$ARGV[1]:Databases($dbname)\\Data File(s) Size (KB)'`;
chomp $dbSize;
$cache = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\MSSQL\$$ARGV[1]:Catalog Metadata($dbname)\\Cache Hit Ratio'`;
chomp $cache;
$Output1 .= @array1[$x] . "_size:" . $dbSize . " ";
$Output2 .= @array1[$x] . "_hits:" . $cache . " ";
push(@PrintVal,$Output1);
push(@PrintVal,$Output2);
$x = $x + 1;
}


print   $Output1 .
        $Output2 .
     "\n";
exit 0;
[b]Cacti Version[/b] - 0.8.7d
[b]Plugin Architecture[/b] - 2.4
[b]Poller Type[/b] - Cactid v
[b]Server Info[/b] - Linux 2.6.18-128.1.6.el5
[b]Web Server[/b] - Apache/2.2.3 (CentOS)
[b]PHP[/b] - 5.2.9
[b]MySQL[/b] - 5.0.45-log
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.3.2.2
[b]Plugins[/b]PHP Network Managing v0.6.1, Global Plugin Settings v0.6,thold v0.4.1,XMLPort v0.3.5,CactiCam v0.1.5,NetTools v0.1.5,pollperf v0.32,RRD Cleaner v1.1,sqlqueries v0.2,superlinks v0.8,syslog v0.5.2,update v0.4,discovery v0.9,zond v0.34a,hostinfo v0.2,Bloom v0.6.5,mactrack v1.1,weathermap v0.96a,mobile v0.1
rtyler778
Posts: 8
Joined: Fri Jul 11, 2008 9:17 am

Post by rtyler778 »

I had just found this after I posted....

That is what I get for being a newb.

Thank you, and I will get back to you if I can get it working!

Thanks
rtyler778
Posts: 8
Joined: Fri Jul 11, 2008 9:17 am

Post by rtyler778 »

Hey,

When I run the script manually from my unix box, I receive :Connection refused could not fetch information from server...

Do I have to some how pass credentials for the sql server?
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Post by streaker69 »

rtyler778 wrote:Hey,

When I run the script manually from my unix box, I receive :Connection refused could not fetch information from server...

Do I have to some how pass credentials for the sql server?
You need to have the NSclient running on your Windows box.
[b]Cacti Version[/b] - 0.8.7d
[b]Plugin Architecture[/b] - 2.4
[b]Poller Type[/b] - Cactid v
[b]Server Info[/b] - Linux 2.6.18-128.1.6.el5
[b]Web Server[/b] - Apache/2.2.3 (CentOS)
[b]PHP[/b] - 5.2.9
[b]MySQL[/b] - 5.0.45-log
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.3.2.2
[b]Plugins[/b]PHP Network Managing v0.6.1, Global Plugin Settings v0.6,thold v0.4.1,XMLPort v0.3.5,CactiCam v0.1.5,NetTools v0.1.5,pollperf v0.32,RRD Cleaner v1.1,sqlqueries v0.2,superlinks v0.8,syslog v0.5.2,update v0.4,discovery v0.9,zond v0.34a,hostinfo v0.2,Bloom v0.6.5,mactrack v1.1,weathermap v0.96a,mobile v0.1
rtyler778
Posts: 8
Joined: Fri Jul 11, 2008 9:17 am

Post by rtyler778 »

I'm an idiot.

kthanks.
Flinx
Posts: 3
Joined: Thu May 03, 2007 5:09 am

instance name

Post by Flinx »

Hi,

thank you for the scipt. I try to connect to a standard instance of a MSSQL2000 Server. But i can't get any informations. How can i ask the standard instance? MSSQLSERVER and local don't work.

Thank you.
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Re: instance name

Post by streaker69 »

Flinx wrote:Hi,

thank you for the scipt. I try to connect to a standard instance of a MSSQL2000 Server. But i can't get any informations. How can i ask the standard instance? MSSQLSERVER and local don't work.

Thank you.
Here ya go:

Code: Select all

#!/usr/bin/perl

# Replace '/usr/local/nagios/libexec/check_nt' with the localtion where your check_nt binary is located
# Usage: perl ms_dbsize.pl <hostname> <Database1,database2,database3>
# eg: perl ms_dbsize.pl server USERS,COLLECTIONS,MAINTENANCE


$CheckNTPath='/usr/local/nagios/libexec';

@array1 = split(/\,/, $ARGV[1]);

foreach $dbname (@array1)
{
$dbSize = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\SQLServer:Databases($dbname)\\Data File(s) Size (KB)'`;
chomp $dbSize;
$Output1 .= @array1[$x] . "_size:" . $dbSize . " ";
push(@PrintVal,$Output1);
$x = $x + 1;
}


print   $Output1 .
     "\n";
exit 0;
You may need to modify it slightly if yours is not named SQLServer, but otherwise it should work. Make sure you change the path to check_nt to reflect where it is on your system.
[b]Cacti Version[/b] - 0.8.7d
[b]Plugin Architecture[/b] - 2.4
[b]Poller Type[/b] - Cactid v
[b]Server Info[/b] - Linux 2.6.18-128.1.6.el5
[b]Web Server[/b] - Apache/2.2.3 (CentOS)
[b]PHP[/b] - 5.2.9
[b]MySQL[/b] - 5.0.45-log
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.3.2.2
[b]Plugins[/b]PHP Network Managing v0.6.1, Global Plugin Settings v0.6,thold v0.4.1,XMLPort v0.3.5,CactiCam v0.1.5,NetTools v0.1.5,pollperf v0.32,RRD Cleaner v1.1,sqlqueries v0.2,superlinks v0.8,syslog v0.5.2,update v0.4,discovery v0.9,zond v0.34a,hostinfo v0.2,Bloom v0.6.5,mactrack v1.1,weathermap v0.96a,mobile v0.1
Flinx
Posts: 3
Joined: Thu May 03, 2007 5:09 am

Modification for not named SQLServer

Post by Flinx »

Hi,

thank you, but I'm a little bit confused about the MSSQL name scheme. What should I modify? I think the name of the standard instance ist MSSQLSERVER, so I modified:

$dbSize = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\MSSQLServer:Databases($dbname)\\Data File(s) Size (KB)'`;

But the result is the same. The output ist 0.
And the result in NSC.log is:

11.09.2008 09:18:15: debug:.\NSClient++.cpp:353: Injecting: checkCounter: \MSSQLServer:Databases(VCDB)\Data File(s) Size (KB), nsclient
11.09.2008 09:18:15: debug:.\NSClient++.cpp:373: Injected Result: UNKNOWN -- Unknown argument: \MSSQLServer
11.09.2008 09:18:15: debug:.\NSClient++.cpp:374: Injected Performance Result:

Same problem with SQLSERVER. Sorry for this, but I'm not very familiar with the MSSQL Server. ;-(

Thanks.
erwan.l
Cacti User
Posts: 138
Joined: Tue Jan 22, 2008 4:36 am
Contact:

Post by erwan.l »

Hi,
I currently monitor some of my databases filesize.

For this I use my own tool (see here : http://forums.cacti.net/viewtopic.php?t=25600).

Install the snmp agent mentionned in the thread, create a c:\counters.ini and in there put the following text :

[1.3.6.1.4.1.15.1]
counter=SQLServer:Databases\Data File(s) Size (KB)\iptools

Then query the oid : 1.3.6.1.4.1.15.1 .
"iptools" is the dbname.
If you have sql instances, then the syntax will be MSSQL$Instance_Name

Regards,
Erwan.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests