Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


[REQUEST] MSSQL DB size

 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
rtyler778



Joined: 11 Jul 2008
Posts: 8

PostPosted: Fri Jul 11, 2008 9:19 am    Post subject: [REQUEST] MSSQL DB size Reply with quote

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
Back to top
rtyler778



Joined: 11 Jul 2008
Posts: 8

PostPosted: Fri Jul 11, 2008 9:24 am    Post subject: Reply with quote

Edit...

My cacti is running on the latest ubuntu...

MSSQL is running on Win2k3 Serv Ent R2

Thanks again!
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Fri Jul 11, 2008 11:22 am    Post subject: Reply with quote

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:

#!/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;
Back to top
rtyler778



Joined: 11 Jul 2008
Posts: 8

PostPosted: Fri Jul 11, 2008 11:49 am    Post subject: Reply with quote

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
Back to top
rtyler778



Joined: 11 Jul 2008
Posts: 8

PostPosted: Fri Jul 11, 2008 11:58 am    Post subject: Reply with quote

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?
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Fri Jul 11, 2008 12:00 pm    Post subject: Reply with quote

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.
Back to top
rtyler778



Joined: 11 Jul 2008
Posts: 8

PostPosted: Fri Jul 11, 2008 2:08 pm    Post subject: Reply with quote

I'm an idiot.

kthanks.
Back to top
Flinx



Joined: 03 May 2007
Posts: 3

PostPosted: Wed Sep 10, 2008 9:06 am    Post subject: instance name Reply with quote

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.
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Wed Sep 10, 2008 10:20 am    Post subject: Re: instance name Reply with quote

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:

#!/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.
Back to top
Flinx



Joined: 03 May 2007
Posts: 3

PostPosted: Thu Sep 11, 2008 2:32 am    Post subject: Modification for not named SQLServer Reply with quote

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.
Back to top
erwan.l
Cacti User


Joined: 22 Jan 2008
Posts: 72

PostPosted: Sat Oct 04, 2008 7:19 am    Post subject: Reply with quote

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group