1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-05 10:03:45 +01:00
nagios-plugins/check_mssql/trunk/check_mssql_dbsize.pl

35 lines
1.1 KiB
Perl
Raw Normal View History

2010-08-25 18:43:54 +02:00
#!/usr/bin/perl
#
# This script will check MSSQL Database size via check_nrpe and NSclient. returns performance data in Nagios format
# Author Pall Sigurdsson <palli@opensource.is>
#
$HOSTNAME=$ARGV[0];
2010-09-08 18:07:48 +02:00
$databases = `/usr/lib/nagios/plugins/check_nrpe -H $HOSTNAME -t 60 -c listCounterInstances -a "SQLServer:Databases"`;
2010-08-25 18:43:54 +02:00
@array1 = split(/\,/, $databases);
#[root@nagios ~]# check_nrpe -H $HOSTNAME -c CheckCounter -a "Counter:Vanskilaskra=\SQLServer:Databases(Vanskilaskra)\Data File(s) Size (KB)"# OK all counters within bounds.|'Vanskilaskra'=30996480;0;0;
$num_databases = 0;
$perfdata = "";
foreach $database (@array1)
{
# Strip whitespace
$database =~ s/^\s*(.*?)\s*$/$1/;
# Call check_nrpe
2010-09-08 18:07:48 +02:00
$dbSize = `/usr/lib/nagios/plugins/check_nrpe -H $HOSTNAME -t 60 -c CheckCounter -a 'Counter:$database=\\SQLServer:Databases($database)\\Data File(s) Size (KB)'`;
2010-08-25 18:43:54 +02:00
# Strip everything but the performance data
$dbSize =~ s/^.*\|(.*?)$/$1/;
chomp($dbSize);
$perfdata = $perfdata . " " . $dbSize;
$num_databases = $num_databases + 1;
}
2010-08-25 19:00:14 +02:00
print "$num_databases databases found in $HOSTNAME | $perfdata \n";