I want to expand the functionality on a monitoring script that runs every night for me that summarizes my SQL Server logs for the previous day and wanted to add a drive space monitor. I found the Win32::DriveInfo lib and I thought I installed it properly by copying it in to my C:\Perl\lib\Win32 directory. I copied this code with a little modification and it will return correct information for local drives but only returns zero for remote servers.
I have no clue what's going on. Any suggestions? Thanks in advance! Here's my program:
use Win32::DriveInfo;
print "$s_c\n";
print "Drive Free Tot PctFree\n";
($SectorsPerCluster,
$BytesPerSector,
$NumberOfFreeClusters,
$TotalNumberOfClusters,
$FreeBytesAvailableToCaller,
$TotalNumberOfBytes,
$TotalNumberOfFreeBytes) = Win32::DriveInfo::DriveSpace('\\\\server01\
+\c\$');
$fb = $TotalNumberOfFreeBytes / 1024 / 1024 / 1024;
$tb = $TotalNumberOfBytes / 1024 / 1024 / 1024;
#$pctfree = $fb / $tb;
print "$s_c: $fb $tb $pctfree\n";
$TotalNumberOfBytes = (Win32::DriveInfo::DriveSpace('\\\\server01\\d\$
+\\'))[5];
$TotalNumberOfFreeBytes = (Win32::DriveInfo::DriveSpace('\\\\server01\
+\d\$\\'))[6];
$fb = $TotalNumberOfFreeBytes / 1024 / 1024 / 1024;
$tb = $TotalNumberOfBytes / 1024 / 1024 / 1024;
#$pctfree = $fb / $tb;
print "$s_d: $fb $tb $pctfree\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.