home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Win32::PerfLib - accessing the Windows NT Performance Counter</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Win32::PerfLib - accessing the Windows NT Performance Counter</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#functions">FUNCTIONS</A></LI>
- <UL>
-
- <LI><A HREF="#note">NOTE</A></LI>
- </UL>
-
- <LI><A HREF="#datastructures">Datastructures</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Win32::PerfLib - accessing the Windows NT Performance Counter</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- use Win32::PerfLib;
- my $server = "";
- Win32::PerfLib::GetCounterNames($server, \%counter);
- %r_counter = map { $counter{$_} => $_ } keys %counter;
- # retrieve the id for process object
- $process_obj = $r_counter{Process};
- # retrieve the id for the process ID counter
- $process_id = $r_counter{'ID Process'};</PRE>
- <PRE>
- # create connection to $server
- $perflib = new Win32::PerfLib($server);
- $proc_ref = {};
- # get the performance data for the process object
- $perflib->GetObjectList($process_obj, $proc_ref);
- $perflib->Close();
- $instance_ref = $proc_ref->{Objects}->{$process_obj}->{Instances};
- foreach $p (sort keys %{$instance_ref})
- {
- $counter_ref = $instance_ref->{$p}->{Counters};
- foreach $i (keys %{$counter_ref})
- {
- if($counter_ref->{$i}->{CounterNameTitleIndex} == $process_id)
- {
- printf( "% 6d %s\n", $counter_ref->{$i}->{Counter},
- $instance_ref->{$p}->{Name}
- );
- }
- }
- }</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>This module allows to retrieve the performance counter of any computer
- (running Windows NT) in the network.</P>
- <P>
- <HR>
- <H1><A NAME="functions">FUNCTIONS</A></H1>
- <P>
- <H2><A NAME="note">NOTE</A></H2>
- <P>All of the functions return FALSE (0) if they fail, unless otherwise noted.
- If the $server argument is undef the local machine is assumed.</P>
- <DL>
- <DT><STRONG><A NAME="item_GetCounterNames">Win32::PerfLib::GetCounterNames($server,$hashref)</A></STRONG><BR>
- <DD>
- Retrieves the counter names and their indices from the registry and stores them
- in the hash reference
- <P></P>
- <DT><STRONG><A NAME="item_GetCounterHelp">Win32::PerfLib::GetCounterHelp($server,$hashref)</A></STRONG><BR>
- <DD>
- Retrieves the counter help strings and their indices from the registry and
- stores them in the hash reference
- <P></P>
- <DT><STRONG><A NAME="item_new">$perflib = Win32::PerfLib->new ($server)</A></STRONG><BR>
- <DD>
- Creates a connection to the performance counters of the given server
- <P></P>
- <DT><STRONG><A NAME="item_GetObjectList">$perflib-><CODE>GetObjectList($objectid,$hashref)</CODE></A></STRONG><BR>
- <DD>
- retrieves the object and counter list of the given performance object.
- <P></P>
- <DT><STRONG><A NAME="item_Close">$perflib-><CODE>Close($hashref)</CODE></A></STRONG><BR>
- <DD>
- closes the connection to the performance counters
- <P></P>
- <DT><STRONG><A NAME="item_GetCounterType">Win32::PerfLib::GetCounterType(countertype)</A></STRONG><BR>
- <DD>
- converts the counter type to readable string as referenced in <EM>calc.html</EM> so
- that it is easier to find the appropriate formula to calculate the raw counter
- data.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="datastructures">Datastructures</A></H1>
- <P>The performance data is returned in the following data structure:</P>
- <DL>
- <DT><STRONG><A NAME="item_Level_1">Level 1</A></STRONG><BR>
- <DD>
- <PRE>
- $hashref = {
- 'NumObjectTypes' => VALUE
- 'Objects' => HASHREF
- 'PerfFreq' => VALUE
- 'PerfTime' => VALUE
- 'PerfTime100nSec' => VALUE
- 'SystemName' => STRING
- 'SystemTime' => VALUE
- }</PRE>
- <DT><STRONG><A NAME="item_Level_2">Level 2</A></STRONG><BR>
- <DD>
- The hash reference $hashref->{Objects} has the returned object <CODE>ID(s)</CODE> as keys and
- a hash reference to the object counter data as value. Even there is only one
- object requested in the call to GetObjectList there may be more than one object
- in the result.
- <PRE>
- $hashref->{Objects} = {
- <object1> => HASHREF
- <object2> => HASHREF
- ...
- }</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_Level_3">Level 3</A></STRONG><BR>
- <DD>
- Each returned object ID has object-specific performance information. If an
- object has instances like the process object there is also a reference to
- the instance information.
- <PRE>
- $hashref->{Objects}->{<object1>} = {
- 'DetailLevel' => VALUE
- 'Instances' => HASHREF
- 'Counters' => HASHREF
- 'NumCounters' => VALUE
- 'NumInstances' => VALUE
- 'ObjectHelpTitleIndex' => VALUE
- 'ObjectNameTitleIndex' => VALUE
- 'PerfFreq' => VALUE
- 'PerfTime' => VALUE
- }</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_Level_4">Level 4</A></STRONG><BR>
- <DD>
- If there are instance information for the object available they are stored in
- the 'Instances' hashref. If the object has no instances there is an 'Counters'
- key instead. The instances or counters are numbered.
- <PRE>
- $hashref->{Objects}->{<object1>}->{Instances} = {
- <1> => HASHREF
- <2> => HASHREF
- ...
- <n> => HASHREF
- }
- or
- $hashref->{Objects}->{<object1>}->{Counters} = {
- <1> => HASHREF
- <2> => HASHREF
- ...
- <n> => HASHREF
- }</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_Level_5">Level 5</A></STRONG><BR>
- <DD>
- <PRE>
- $hashref->{Objects}->{<object1>}->{Instances}->{<1>} = {
- Counters => HASHREF
- Name => STRING
- ParentObjectInstance => VALUE
- ParentObjectTitleIndex => VALUE
- }
- or
- $hashref->{Objects}->{<object1>}->{Counters}->{<1>} = {
- Counter => VALUE
- CounterHelpTitleIndex => VALUE
- CounterNameTitleIndex => VALUE
- CounterSize => VALUE
- CounterType => VALUE
- DefaultScale => VALUE
- DetailLevel => VALUE
- Display => STRING
- }</PRE>
- <DT><STRONG><A NAME="item_Level_6">Level 6</A></STRONG><BR>
- <DD>
- <PRE>
- $hashref->{Objects}->{<object1>}->{Instances}->{<1>}->{Counters} = {
- <1> => HASHREF
- <2> => HASHREF
- ...
- <n> => HASHREF
- }</PRE>
- <DT><STRONG><A NAME="item_Level_7">Level 7</A></STRONG><BR>
- <DD>
- <PRE>
- $hashref->{Objects}->{<object1>}->{Instances}->{<1>}->{Counters}->{<1>} = {
- Counter => VALUE
- CounterHelpTitleIndex => VALUE
- CounterNameTitleIndex => VALUE
- CounterSize => VALUE
- CounterType => VALUE
- DefaultScale => VALUE
- DetailLevel => VALUE
- Display => STRING
- }</PRE>
- <P>Depending on the <STRONG>CounterType</STRONG> there are calculations to do (see calc.html).</P>
- </DL>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Jutta M. Klebe, <A HREF="mailto:jmk@bybyte.de">jmk@bybyte.de</A></P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P>perl(1).</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Win32::PerfLib - accessing the Windows NT Performance Counter</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-