use CGI qw(:standard *table fatalsToBrowser);
use Win32::AdminMisc;
use Text::CSV_XS;

Win32::AdminMisc::LogonAsUser("DOMAIN", "USER", "PASSWORD") || die "Can't Logon";


open (DISKSLIST, "E:\\inetpub\\wwwroot\\cgi-bin\\DiskList");
$csv = Text::CSV_XS->new();

print header;
print start_html("Space Monitor");
print start_html( -title=>'Space Monitor',
		-style=>{-src=>'http://hostname/include/style.css',
		-code=>$newStyle})
		;
print ('<!--#include "http://hostname/include/header.htm" -->');
print h1("Space Check");
print br();
print table({-border=>"0"});
print th({-align=>LEFT,-valign=>TOP},['Drive Name','Limit', 'Free Space','Comment ','Warning']);

while (<DISKSLIST>) {
	$status = $csv->parse($_);
	@Columns = $csv->fields();
	$Drive=$Columns[0];
	$Limit=$Columns[1];
	$Comment=$Columns[2];
	($total,$Free)=Win32::AdminMisc::GetDriveSpace($Drive);
	if ($Free < $Limit ) { $FreeStatus="<strong>Space Problem</strong>"};
	print Tr([
		td([$Drive,$Limit,$Free,$Comment,$FreeStatus])
		]
		);
	print ("\n");
	$FreeStatus="";
	}
print end_table;
print end_html;
Win32::AdminMisc::LogoffAsUser(0);
close DISKSLIST;

