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    


Monitoring MS SQL from *nix (Yes, it really works!)

 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
streaker69
Cacti Pro User


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

PostPosted: Thu Jun 12, 2008 10:49 am    Post subject: Monitoring MS SQL from *nix (Yes, it really works!) Reply with quote

I think many people have been looking for a solution to monitoring your MS SQL databases from Linux but haven't found a good one yet, at least I haven't found a good one yet. Here's an example script that I hope you guys can use as a roadmap to create your own templates. I'm not going to make an example template as I think this is a little too customized per location.

Basically it's rather a simple thing to get running. Your command line will look like this:

perl ms_sql.pl hostname dbinstance dbname1,dbname2,dbname3

Do not put the $ in front of the dbinstance value, the script does that automatically. You can list any number of individual databases seperated by comma's at the end, including the _Total if you want that value.

When you make your Data Input method you'll have to create three input fields, and however many output fields you're expecting. Which is exactly why I'm not creating templates ahead of time.

Feel free to make changes to this code to get whatever values you want. I just did this to provide examples of how to retrieve the values using the check_nt program.

Enjoy

Here's the code:

Code:

#!/usr/bin/perl

# Replace '/usr/local/nagios/libexec/check_nt' with the localtion where your check_nt binary is located

$CheckNTPath='/usr/lib/nagios/plugins';


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

$tempdb = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\MSSQL\$$ARGV[1]:Transactions\\Free Space in tempdb (KB)'`;
chomp $tempdb;

$TActions = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\MSSQL\$$ARGV[1]:Transactions\\Transactions'`;
chomp $TActions;

$Users = `$CheckNTPath/check_nt -H $ARGV[0] -p 1248 -v COUNTER -l '\\MSSQL\$$ARGV[1]:General Statistics\\User Connections'`;
chomp $Users;

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] . "_cache:" . $cache . " ";
push(@PrintVal,$Output1);
push(@PrintVal,$Output2);
$x = $x + 1;
}


print "Users:"     . $Users . " " .
        "Transactions:" . $TActions . " " .
        "TempDb:"       . $tempdb . " " .
        $Output1 .
        $Output2 .
     "\n";
exit 0;
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