#!/usr/bin/perl
$CheckNTPath='/usr/lib/nagios/plugins';

$LogGenerationCheckpointDepth  = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database ==> Instances(*)\\Log Generation Checkpoint Depth"`;
chomp $LogGenerationCheckpointDepth;
$DatabasePageFaultStallssec      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database(Information Store)\\Database Page Fault Stalls/sec"`;
chomp $DatabasePageFaultStallssec;
$LogRecordStallssec      = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database(Information Store)\\Log Record Stalls/sec"`;
chomp $LogRecordStallssec;
$LogThreadsWaiting     = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database(Information Store)\\Log Threads Waiting"`;
chomp $LogThreadsWaiting;
$Versionbucketsallocated         = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database(Information Store)\\Version buckets allocated"`;
chomp $Versionbucketsallocated;
$IODatabaseReadsAverageLatency         = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database Instances(*)\\I/O Database Reads Average Latency"`;
chomp $IODatabaseReadsAverageLatency;
$IODatabaseWritesAverageLatency         = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database Instances(*)\\I/O Database Writes Average Latency"`;
chomp $IODatabaseWritesAverageLatency;
$DatabaseCacheSizeMB         = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database(Information Store)\\Database Cache Size (MB)"`;
chomp $DatabaseCacheSizeMB;
$DatabaseCacheHit         = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database(Information Store)\\Database Cache % Hit"`;
chomp $DatabaseCacheHit;
$LogBytesWritesec         = `$CheckNTPath/check_nt -H $ARGV[0] -p 12489 -v COUNTER -l "\\MSExchange Database\\Log Bytes Write/sec"`;
chomp $LogBytesWritesec;


print "LogGenerationCheckpointDepth:"    			  . $LogGenerationCheckpointDepth .
     " DatabasePageFaultStallssec:"   				  . $DatabasePageFaultStallssec .
     " LogRecordStallssec:"   			  		      . $LogRecordStallssec .
     " LogThreadsWaiting:"  	     				  . $LogThreadsWaiting .
     " Versionbucketsallocated:"   				      . $Versionbucketsallocated .
     " IODatabaseReadsAverageLatency:"   		      . $IODatabaseReadsAverageLatency .
     " IODatabaseWritesAverageLatency:"   		      . $IODatabaseWritesAverageLatency .
     " DatabaseCacheSizeMB:"   				  	      . $DatabaseCacheSizeMB .
     " DatabaseCacheHit:"   					      . $DatabaseCacheHit .
     " LogBytesWritesec:"   				    	  . $LogBytesWritesec .	 
     "\n";	 
