Page 1 of 2

check_pdm.exe 100% full disk says "Drive information problem

Posted: Tue Sep 22, 2020 8:46 pm
by cbeattie-unitrends
Hello,

I've configured a 64-bit Windows Server 2012 R2 Standard computer to be monitored with NRDP. Every check is coming back to Nagios XI (5.6.14) as expected, except there is one drive (G:) that is 100% full. The host was previously configured to use NCSA which reported G: at 100% as expected. However, check_pdm.exe is returning an UNKNOWN state for this drive. Other drives are being reported correctly. Here's a sample from NRDS_Debug.log:

Code: Select all

9/22/2020 7:16:07 PM command to be run : C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive F: -w 80 -c 90
9/22/2020 7:16:07 PM command line executing : cmd /c C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive F: -w 80 -c 90 > %temp%\output.txt
9/22/2020 7:16:07 PM return results from plugin : DISK+OK+%2D+usage%3A+F%3A+7242931%2E9+MB+%2869%2E07%25+of+total+10485630%2E0+MB%29%7C%27disk+in+use%27%3D7242931%2E9MB%3B+%27disk+usage%27%3D69%2E07%25%3B80%3B90%3B+%27disk+total%27%3D10485630%2E0MB%3B
9/22/2020 7:16:07 PM return code from plugin : 0
9/22/2020 7:16:07 PM command to be run : C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive G: -w 80 -c 90
9/22/2020 7:16:07 PM command line executing : cmd /c C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive G: -w 80 -c 90 > %temp%\output.txt
9/22/2020 7:16:07 PM return results from plugin : DISK+UNKNOWN+%2D+Drive+information+problem
9/22/2020 7:16:07 PM return code from plugin : 3
9/22/2020 7:16:07 PM command to be run : C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive H: -w 80 -c 90
9/22/2020 7:16:07 PM command line executing : cmd /c C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive H: -w 80 -c 90 > %temp%\output.txt
9/22/2020 7:16:07 PM return results from plugin : DISK+OK+%2D+usage%3A+H%3A+26506744%2E2+MB+%2850%2E56%25+of+total+52428670%2E0+MB%29%7C%27disk+in+use%27%3D26506744%2E2MB%3B+%27disk+usage%27%3D50%2E56%25%3B80%3B90%3B+%27disk+total%27%3D52428670%2E0MB%3B
9/22/2020 7:16:07 PM return code from plugin : 0

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Wed Sep 23, 2020 4:43 pm
by cdienger
Is this the same plugin as the one hosted at https://itefix.net/check_pdm ?

Do you get the same results if you try to run the plugin directly on the Windows command line(instead of through NRDS):

Code: Select all

C:\PROGRA~1\Nagios\NRDS_Win\plugins\check_pdm.exe --disk --drive G: -w 80 -c 90
?

I'm not finding the source for the exe but it looks like there is a perl version available that I would try to test with. If you get the same behavior then at least the code is available to dig in to.

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Thu Sep 24, 2020 9:55 am
by cbeattie-unitrends
I downloaded and extracted the files from the link you supplied. The executable file was the same size, so I ran fc /b to compare the binaries. They're the same.

I get the same results when I run check_pdm.exe from the command line. All the other drives work, just not the full one.

Unfortunately, this is a production Windows server. I can't install Perl on it to check the script. I'll see if I can find a different Windows box to do this on.

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Thu Sep 24, 2020 1:24 pm
by cbeattie-unitrends
I added a 10MB disk to a different Windows VM and ran a PowerShell command to fill the disk up. This VM is Windows 10 instead of a server version, but the result was the same with the exe file.
(Run as Administrator)

Code: Select all

[io.file]::Create("D:\foo.txt").SetLength((gwmi Win32_LogicalDisk -Filter "DeviceID='D:'").FreeSpace).Close
I then installed a Perl interpreter on the Windows 10 box to see if the script did any better. It did not. These are the results of back-to-back runs with only the PowerShell to fill the disk between them:

Code: Select all

C:\Program Files\Nagios\NRDS_Win\plugins>perl "c:\Program Files\Nagios\NRDS_Win\plugins\check_pdm.pl" --disk --drive D: -w 80 -c 90
DISK OK - usage: D: 3.7 MB (52.37% of total 7.0 MB)|'disk in use'=3.7MB; 'disk usage'=52.37%;80;90; 'disk total'=7.0MB;
C:\Program Files\Nagios\NRDS_Win\plugins>perl "c:\Program Files\Nagios\NRDS_Win\plugins\check_pdm.pl" --disk --drive D: -w 80 -c 90
DISK UNKNOWN - Drive information problem
C:\Program Files\Nagios\NRDS_Win\plugins>
I feel like I have ruled out anything in my environment that could be an issue, and I am concerned that this is a bug in check_pdm itself. I downloaded another copy of check_pdm from Nagios https://assets.nagios.com/downloads/nag ... ck_pdm.exe but fc /b conf confirmed it was the same file.

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Fri Sep 25, 2020 9:23 am
by cdienger
There are three sections in the perl script that could cause the error. My thought is that it is likely failing in the first spot due to the wmi query failing, but it would be worth modify the error mesages slightly just determine where exactly it is failing:

Code: Select all

##### CheckDisk #####
sub CheckDisk
{
	my ($drive, $warning, $critical) = @_;
	
	my $wmi = Win32::OLE->GetObject("winmgmts://$hostname/root/CIMV2");
	$wmi || ExitProgram($UNKNOWN, "WMI Problem");
	
	my $drivelist = $wmi->ExecQuery("select * from Win32_LogicalDisk where Name='$drive' And DriveType=3");
	$drivelist || ExitProgram($UNKNOWN, "Drive information problem 1");

	my @tmp = in($drivelist);
	my $driveinfo = pop @tmp;
	$driveinfo || ExitProgram($UNKNOWN, "Drive information problem 2");
	
	($driveinfo->{FreeSpace} and $driveinfo->{Size}) || ExitProgram($UNKNOWN, "Drive information problem 3");

	my $diskinuse = $driveinfo->{Size} - $driveinfo->{FreeSpace};	
	my $diskusepct = ($diskinuse /  $driveinfo->{Size}) * 100;
	my $inusemb = $diskinuse / (1024*1024);
	my $totalmb = $driveinfo->{Size} / (1024*1024);
	
	my $resultcode = $OK;
	$warning && ($diskusepct > $warning) && ($resultcode = $WARNING);
	$critical && ($diskusepct > $critical) && ($resultcode = $CRITICAL);
	
	my $resultmsg = sprintf "usage: $drive %.1f MB (%.2f%% of total %.1f MB)", $inusemb, $diskusepct, $totalmb;
	$resultmsg .= 
		"|'disk in use'=" . sprintf ("%.1f", $inusemb) . "MB;" . 
		" 'disk usage'=" . sprintf ("%.2f", $diskusepct) . "%;" .
		((defined $warning ? $warning : "") . ";" . (defined $critical ? $critical : "") . ";") .
		" 'disk total'=" . sprintf ("%.1f", $totalmb) . "MB;";		
	
	ExitProgram($resultcode, $resultmsg);
}

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Fri Sep 25, 2020 2:05 pm
by cbeattie-unitrends
I patched the script with your changes, and got this:

Code: Select all

C:\Program Files\Nagios\NRDS_Win\plugins>perl "c:\Program Files\Nagios\NRDS_Win\plugins\check_pdm.pl" --disk --drive D: -w 80 -c 90
DISK UNKNOWN - Drive information problem 3
Does that mean if the drive is 100% full that WMI returns the free space or size differently?

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Mon Sep 28, 2020 2:16 pm
by cdienger
It looks like it is having issues parsing what data it is able to get about the drive. I'd be curious to see what is stored in $drivelist and $driveinfo.

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Tue Sep 29, 2020 1:27 pm
by cbeattie-unitrends
The drive information problem 3 line needs to be an "or" instead of an "and", or removed altogether. If there is no free space the FreeSpace property gets set to 0 (as it should) but that triggers this conditional.

($driveinfo->{FreeSpace} and $driveinfo->{Size}) || ExitProgram($UNKNOWN, "Drive information problem 3");

With that line changed to

($driveinfo->{FreeSpace} or $driveinfo->{Size}) || ExitProgram($UNKNOWN, "Drive information problem 3");

The script works as expected:

Code: Select all

C:\Program Files\Nagios\NRDS_Win\plugins>perl "c:\Program Files\Nagios\NRDS_Win\plugins\check_pdm.pl" --disk -w 80 -c 90 --drive D:
DISK CRITICAL - usage: D: 7.0 MB (100.00% of total 7.0 MB)|'disk in use'=7.0MB; 'disk usage'=100.00%;80;90; 'disk total'=7.0MB;
Can this be turned into an executable file to replace the buggy version?

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Wed Sep 30, 2020 3:42 pm
by cdienger
There do appear to be tools available to do this but I don't have an environment to do it. I will file a bug with our dev team to take a look into this.

Re: check_pdm.exe 100% full disk says "Drive information pro

Posted: Wed Oct 14, 2020 3:05 pm
by cbeattie-unitrends
I just realized I copy-pasted the same line twice above, so I have corrected it to reflect the "or" comparison I was talking about.