Hello,
I'm trying to use the Win32:
erfmon module to gather some performance metrics off a windows host. For some reason, i cannot get anything out of the "PhysicalDisk" counter.
When I do a PerfObj->ListCounters("PhysicalDisk"), it always errors out with a "A required argument is invalid or a reserved argument is not NULL".
And I get nothing out of the counter value.
Can anybody please help me figure this out. Here is my code -
**********************************
use Win32:
erfMon;
use strict;
my $ret = undef;
my $err = undef;
my $xxx = Win32:
erfMon->new("\\\\MyServer");
if($xxx != undef)
{
print "\n***List of Performance Counters***\n";
my $Data= $xxx->ListCounters("PhysicalDisk");
foreach my $cntr (@$Data) { print "$cntr\n"; }
# Here is where I get the error
$ret = $xxx->AddCounter("PhysicalDisk", "Avg. Disk Bytes/Read", -1);
if($ret != 0)
{
$ret = $xxx->CollectData();
if($ret != 0)
{
my $secs = $xxx->GetCounterValue("PhysicalDisk", "Avg. Disk Bytes/Read", -1);
if($secs > -1)
{
print "Avg Disk Bytes Read = [$secs]\n";
}
else
{
$err = $xxx->GetErrorText();
print "Failed to get the counter data ", $err, "\n";
}
}
else
{
$err = $xxx->GetErrorText();
print "Failed to collect the perf data ", $err, "\n";
}
}
else
{
$err = $xxx->GetErrorText();
print "Failed to add the counter ", $err, "\n";
}
}
else
{
print "Failed to create the perf object\n";
}
******************************************
I'm trying to use the Win32:

When I do a PerfObj->ListCounters("PhysicalDisk"), it always errors out with a "A required argument is invalid or a reserved argument is not NULL".
And I get nothing out of the counter value.
Can anybody please help me figure this out. Here is my code -
**********************************
use Win32:

use strict;
my $ret = undef;
my $err = undef;
my $xxx = Win32:

if($xxx != undef)
{
print "\n***List of Performance Counters***\n";
my $Data= $xxx->ListCounters("PhysicalDisk");
foreach my $cntr (@$Data) { print "$cntr\n"; }
# Here is where I get the error
$ret = $xxx->AddCounter("PhysicalDisk", "Avg. Disk Bytes/Read", -1);
if($ret != 0)
{
$ret = $xxx->CollectData();
if($ret != 0)
{
my $secs = $xxx->GetCounterValue("PhysicalDisk", "Avg. Disk Bytes/Read", -1);
if($secs > -1)
{
print "Avg Disk Bytes Read = [$secs]\n";
}
else
{
$err = $xxx->GetErrorText();
print "Failed to get the counter data ", $err, "\n";
}
}
else
{
$err = $xxx->GetErrorText();
print "Failed to collect the perf data ", $err, "\n";
}
}
else
{
$err = $xxx->GetErrorText();
print "Failed to add the counter ", $err, "\n";
}
}
else
{
print "Failed to create the perf object\n";
}
******************************************