1*13124SAlexander.Kolbasov@Sun.COM# 2*13124SAlexander.Kolbasov@Sun.COM# CDDL HEADER START 3*13124SAlexander.Kolbasov@Sun.COM# 4*13124SAlexander.Kolbasov@Sun.COM# The contents of this file are subject to the terms of the 5*13124SAlexander.Kolbasov@Sun.COM# Common Development and Distribution License (the "License"). 6*13124SAlexander.Kolbasov@Sun.COM# You may not use this file except in compliance with the License. 7*13124SAlexander.Kolbasov@Sun.COM# 8*13124SAlexander.Kolbasov@Sun.COM# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*13124SAlexander.Kolbasov@Sun.COM# or http://www.opensolaris.org/os/licensing. 10*13124SAlexander.Kolbasov@Sun.COM# See the License for the specific language governing permissions 11*13124SAlexander.Kolbasov@Sun.COM# and limitations under the License. 12*13124SAlexander.Kolbasov@Sun.COM# 13*13124SAlexander.Kolbasov@Sun.COM# When distributing Covered Code, include this CDDL HEADER in each 14*13124SAlexander.Kolbasov@Sun.COM# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*13124SAlexander.Kolbasov@Sun.COM# If applicable, add the following below this CDDL HEADER, with the 16*13124SAlexander.Kolbasov@Sun.COM# fields enclosed by brackets "[]" replaced with your own identifying 17*13124SAlexander.Kolbasov@Sun.COM# information: Portions Copyright [yyyy] [name of copyright owner] 18*13124SAlexander.Kolbasov@Sun.COM# 19*13124SAlexander.Kolbasov@Sun.COM# CDDL HEADER END 20*13124SAlexander.Kolbasov@Sun.COM# 21*13124SAlexander.Kolbasov@Sun.COM 22*13124SAlexander.Kolbasov@Sun.COM# 23*13124SAlexander.Kolbasov@Sun.COM# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24*13124SAlexander.Kolbasov@Sun.COM# 25*13124SAlexander.Kolbasov@Sun.COM 26*13124SAlexander.Kolbasov@Sun.COM# 27*13124SAlexander.Kolbasov@Sun.COM# Sun::Solaris::Pg documentation 28*13124SAlexander.Kolbasov@Sun.COM# 29*13124SAlexander.Kolbasov@Sun.COM 30*13124SAlexander.Kolbasov@Sun.COM=head1 NAME 31*13124SAlexander.Kolbasov@Sun.COM 32*13124SAlexander.Kolbasov@Sun.COMSolaris::Pg - Perl interface to Processor Group kstats 33*13124SAlexander.Kolbasov@Sun.COM 34*13124SAlexander.Kolbasov@Sun.COM=head1 SYNOPSYS 35*13124SAlexander.Kolbasov@Sun.COM 36*13124SAlexander.Kolbasov@Sun.COM use Solaris::Pg; 37*13124SAlexander.Kolbasov@Sun.COM 38*13124SAlexander.Kolbasov@Sun.COM $p = Solaris::Pg->new(-cpudata=> 1, -tags=> 1, -swload=> 1); 39*13124SAlexander.Kolbasov@Sun.COM 40*13124SAlexander.Kolbasov@Sun.COM @pgs = $p->all(); 41*13124SAlexander.Kolbasov@Sun.COM 42*13124SAlexander.Kolbasov@Sun.COM @pgs_depth = $p->all_depth_first(); 43*13124SAlexander.Kolbasov@Sun.COM 44*13124SAlexander.Kolbasov@Sun.COM @pgs_breadth = $p->all_breadth_first(); 45*13124SAlexander.Kolbasov@Sun.COM 46*13124SAlexander.Kolbasov@Sun.COM @leaves = $p->leaves(); 47*13124SAlexander.Kolbasov@Sun.COM 48*13124SAlexander.Kolbasov@Sun.COM $root = $p->root; 49*13124SAlexander.Kolbasov@Sun.COM 50*13124SAlexander.Kolbasov@Sun.COM $p->update(); 51*13124SAlexander.Kolbasov@Sun.COM 52*13124SAlexander.Kolbasov@Sun.COM $leaf = $leaves[0]; 53*13124SAlexander.Kolbasov@Sun.COM 54*13124SAlexander.Kolbasov@Sun.COM $name = $p->sh_name($leaf); 55*13124SAlexander.Kolbasov@Sun.COM 56*13124SAlexander.Kolbasov@Sun.COM @names = $p->sharing_relationships(); 57*13124SAlexander.Kolbasov@Sun.COM 58*13124SAlexander.Kolbasov@Sun.COM @tags = $p->tags($leaf); 59*13124SAlexander.Kolbasov@Sun.COM 60*13124SAlexander.Kolbasov@Sun.COM $p1 = Solaris::Pg->new(-cpudata=> 1, -tags=> 1, -swload=> 1); 61*13124SAlexander.Kolbasov@Sun.COM 62*13124SAlexander.Kolbasov@Sun.COM if ($p->has_utilization()) { 63*13124SAlexander.Kolbasov@Sun.COM $utilization = $p->utilization($p1, $leaf); 64*13124SAlexander.Kolbasov@Sun.COM $capacity = $p->capacity($p1, $leaf); 65*13124SAlexander.Kolbasov@Sun.COM $accuracy = $p->accuracy($p1, $leaf); 66*13124SAlexander.Kolbasov@Sun.COM $tdelta = $p->tdelta($p1); 67*13124SAlexander.Kolbasov@Sun.COM } 68*13124SAlexander.Kolbasov@Sun.COM 69*13124SAlexander.Kolbasov@Sun.COM $sw_utilization = $p->sw_utilization($p1, $leaf);) 70*13124SAlexander.Kolbasov@Sun.COM 71*13124SAlexander.Kolbasov@Sun.COM 72*13124SAlexander.Kolbasov@Sun.COM=head1 DESCRIPTION 73*13124SAlexander.Kolbasov@Sun.COM 74*13124SAlexander.Kolbasov@Sun.COMThe Solaris::Pg module provides an interface to the Solaris PG information 75*13124SAlexander.Kolbasov@Sun.COMavailable through B<pg> and B<pg_cpu> kstats. The module provides an object 76*13124SAlexander.Kolbasov@Sun.COMoriented interface. 77*13124SAlexander.Kolbasov@Sun.COM 78*13124SAlexander.Kolbasov@Sun.COM=head1 METHODS 79*13124SAlexander.Kolbasov@Sun.COM 80*13124SAlexander.Kolbasov@Sun.COM=head2 new 81*13124SAlexander.Kolbasov@Sun.COM 82*13124SAlexander.Kolbasov@Sun.COMCreate a new Pg instance. The new() function accepts arguments in the form of a 83*13124SAlexander.Kolbasov@Sun.COMhash. The following subarguments are supported: 84*13124SAlexander.Kolbasov@Sun.COM 85*13124SAlexander.Kolbasov@Sun.COM=over 86*13124SAlexander.Kolbasov@Sun.COM 87*13124SAlexander.Kolbasov@Sun.COM=item -cpudata 88*13124SAlexander.Kolbasov@Sun.COM 89*13124SAlexander.Kolbasov@Sun.COMCollect per-CPU data from kstats if this is True. 90*13124SAlexander.Kolbasov@Sun.COM 91*13124SAlexander.Kolbasov@Sun.COM=item -tags 92*13124SAlexander.Kolbasov@Sun.COM 93*13124SAlexander.Kolbasov@Sun.COMMatch PGs to physical relationships if this is True. 94*13124SAlexander.Kolbasov@Sun.COM 95*13124SAlexander.Kolbasov@Sun.COM=item -swload 96*13124SAlexander.Kolbasov@Sun.COM 97*13124SAlexander.Kolbasov@Sun.COMCollect software CPU load if this is True. 98*13124SAlexander.Kolbasov@Sun.COM 99*13124SAlexander.Kolbasov@Sun.COM=back 100*13124SAlexander.Kolbasov@Sun.COM 101*13124SAlexander.Kolbasov@Sun.COM=head2 root 102*13124SAlexander.Kolbasov@Sun.COM 103*13124SAlexander.Kolbasov@Sun.COMReturn ID of the root of Processor Group hierarchy. 104*13124SAlexander.Kolbasov@Sun.COM 105*13124SAlexander.Kolbasov@Sun.COM=head2 all 106*13124SAlexander.Kolbasov@Sun.COM 107*13124SAlexander.Kolbasov@Sun.COMReturn list of all PGs sorted by ID. 108*13124SAlexander.Kolbasov@Sun.COM 109*13124SAlexander.Kolbasov@Sun.COM=head2 all_depth_first() 110*13124SAlexander.Kolbasov@Sun.COM 111*13124SAlexander.Kolbasov@Sun.COMReturn list of all PGs sorted by walking the PG hierarchy depth first, starting 112*13124SAlexander.Kolbasov@Sun.COMfrom root. 113*13124SAlexander.Kolbasov@Sun.COM 114*13124SAlexander.Kolbasov@Sun.COM=head2 all_breadth_first() 115*13124SAlexander.Kolbasov@Sun.COM 116*13124SAlexander.Kolbasov@Sun.COMReturn list of all PGs sorted by walking the PG hierarchy breadth first, 117*13124SAlexander.Kolbasov@Sun.COMstarting from root. 118*13124SAlexander.Kolbasov@Sun.COM 119*13124SAlexander.Kolbasov@Sun.COM=head2 cpus(PG) 120*13124SAlexander.Kolbasov@Sun.COM 121*13124SAlexander.Kolbasov@Sun.COMReturn list of all CPUs in the PG specified. The list is sorted by CPU ID. 122*13124SAlexander.Kolbasov@Sun.COM 123*13124SAlexander.Kolbasov@Sun.COM=head2 generation([PG]) 124*13124SAlexander.Kolbasov@Sun.COM 125*13124SAlexander.Kolbasov@Sun.COMReturn the generation number for the given PG. Without arguments, return the 126*13124SAlexander.Kolbasov@Sun.COMgeneration number for the whole snapshot. Different generation number means that 127*13124SAlexander.Kolbasov@Sun.COMPG configuration may have changed. 128*13124SAlexander.Kolbasov@Sun.COM 129*13124SAlexander.Kolbasov@Sun.COM=head2 parent(PG) 130*13124SAlexander.Kolbasov@Sun.COM 131*13124SAlexander.Kolbasov@Sun.COMReturn parent ID or undef if there is no parent. 132*13124SAlexander.Kolbasov@Sun.COM 133*13124SAlexander.Kolbasov@Sun.COM=head2 children(PG) 134*13124SAlexander.Kolbasov@Sun.COM 135*13124SAlexander.Kolbasov@Sun.COMReturn list of children for the PG. 136*13124SAlexander.Kolbasov@Sun.COM 137*13124SAlexander.Kolbasov@Sun.COM=head2 is_leaf(PG) 138*13124SAlexander.Kolbasov@Sun.COM 139*13124SAlexander.Kolbasov@Sun.COMReturns T iff PG is leaf. 140*13124SAlexander.Kolbasov@Sun.COM 141*13124SAlexander.Kolbasov@Sun.COM=head2 leaves 142*13124SAlexander.Kolbasov@Sun.COM 143*13124SAlexander.Kolbasov@Sun.COMReturns list of leaf PGs. 144*13124SAlexander.Kolbasov@Sun.COM 145*13124SAlexander.Kolbasov@Sun.COM=head2 level(PG) 146*13124SAlexander.Kolbasov@Sun.COM 147*13124SAlexander.Kolbasov@Sun.COMReturn the numeric level of PG in the hierarchy, starting from root which has 148*13124SAlexander.Kolbasov@Sun.COMlevel zero. 149*13124SAlexander.Kolbasov@Sun.COM 150*13124SAlexander.Kolbasov@Sun.COM=head2 sh_name(PG) 151*13124SAlexander.Kolbasov@Sun.COM 152*13124SAlexander.Kolbasov@Sun.COMReturns sharing name for the PG. 153*13124SAlexander.Kolbasov@Sun.COM 154*13124SAlexander.Kolbasov@Sun.COM=head2 sharing_relationships([PG], ...) 155*13124SAlexander.Kolbasov@Sun.COM 156*13124SAlexander.Kolbasov@Sun.COMWithout any arguments, returns the list of sharing relationships in the 157*13124SAlexander.Kolbasov@Sun.COMsnapshot. Relationships are sorted by the level in the hierarchy If any PGs are 158*13124SAlexander.Kolbasov@Sun.COMgiven on the command line, only return sharing relationships for given PGs, but 159*13124SAlexander.Kolbasov@Sun.COMstill keep them sorted. 160*13124SAlexander.Kolbasov@Sun.COM 161*13124SAlexander.Kolbasov@Sun.COM=head2 tags(PG) 162*13124SAlexander.Kolbasov@Sun.COM 163*13124SAlexander.Kolbasov@Sun.COMReturn list of strings describing physical relationships ('core', 'chip') for the given PG. 164*13124SAlexander.Kolbasov@Sun.COM 165*13124SAlexander.Kolbasov@Sun.COM=head2 update() 166*13124SAlexander.Kolbasov@Sun.COM 167*13124SAlexander.Kolbasov@Sun.COMUpdate utilization and generation data in the PG snapshot. 168*13124SAlexander.Kolbasov@Sun.COM 169*13124SAlexander.Kolbasov@Sun.COM=head2 has_utilization(PG) 170*13124SAlexander.Kolbasov@Sun.COM 171*13124SAlexander.Kolbasov@Sun.COMReturns True if given PG hasd data about hardware utilization. 172*13124SAlexander.Kolbasov@Sun.COM 173*13124SAlexander.Kolbasov@Sun.COM=head2 utilization(PGOBJ, PG) 174*13124SAlexander.Kolbasov@Sun.COM 175*13124SAlexander.Kolbasov@Sun.COMReturn numeric utilization for the time interval represented by two PG objects 176*13124SAlexander.Kolbasov@Sun.COMfor the given PG. Utilization is a difference in utilization value between two 177*13124SAlexander.Kolbasov@Sun.COMsnapshots. The given PG must belong to the same generation in both snapshots. 178*13124SAlexander.Kolbasov@Sun.COMReturns B<undef> if utilization can not be obtained. 179*13124SAlexander.Kolbasov@Sun.COM 180*13124SAlexander.Kolbasov@Sun.COM=head2 sw_utilization(PGOBJ, PG) 181*13124SAlexander.Kolbasov@Sun.COM 182*13124SAlexander.Kolbasov@Sun.COMReturn numeric software utilization for the time interval represented by two PG 183*13124SAlexander.Kolbasov@Sun.COMobjects for the given PG. Utilization is a difference in utilization value 184*13124SAlexander.Kolbasov@Sun.COMbetween two snapshots. The given PG must belong to the same generation in both 185*13124SAlexander.Kolbasov@Sun.COMsnapshots. Returns B<undef> if utilization can not be obtained. Software 186*13124SAlexander.Kolbasov@Sun.COMutilization is combined CPU load for all CPUs in the PG. Returns B<undef> if 187*13124SAlexander.Kolbasov@Sun.COMutilization can not be obtained. 188*13124SAlexander.Kolbasov@Sun.COM 189*13124SAlexander.Kolbasov@Sun.COM=head2 sw_utilization(PGOBJ, PG, CPU) 190*13124SAlexander.Kolbasov@Sun.COM 191*13124SAlexander.Kolbasov@Sun.COMReturn utilization for the PG for a given CPU in a given PG. Utilization is a 192*13124SAlexander.Kolbasov@Sun.COMdifference in utilization value between two snapshots. We can only compare 193*13124SAlexander.Kolbasov@Sun.COMutilization between PGs having the same generation ID. Returns B<undef> if 194*13124SAlexander.Kolbasov@Sun.COMutilization can not be obtained. 195*13124SAlexander.Kolbasov@Sun.COM 196*13124SAlexander.Kolbasov@Sun.COM=head2 capacity(PGOBJ, PG) 197*13124SAlexander.Kolbasov@Sun.COM 198*13124SAlexander.Kolbasov@Sun.COMReturn numeric capacity for the time interval represented by two PG objects for 199*13124SAlexander.Kolbasov@Sun.COMthe given PG. Note that the actual capacity is the maximum of all capacities 200*13124SAlexander.Kolbasov@Sun.COMacross all PGs of this type.The given PG must belong to the same generation in 201*13124SAlexander.Kolbasov@Sun.COMboth snapshots. Returns B<undef> if capacities can not be obtained. 202*13124SAlexander.Kolbasov@Sun.COM 203*13124SAlexander.Kolbasov@Sun.COM=head2 accuracy(PGOBJ, PG) 204*13124SAlexander.Kolbasov@Sun.COM 205*13124SAlexander.Kolbasov@Sun.COMReturn accuracy of utilization calculation between two snapshots The accuracy is 206*13124SAlexander.Kolbasov@Sun.COMdetermined based on the total time spent running and not running the counters. 207*13124SAlexander.Kolbasov@Sun.COMIf T1 is the time counters were running during the period and T2 is the time 208*13124SAlexander.Kolbasov@Sun.COMthey were turned off, the accuracy is T1 / (T1 + T2), expressed in percentages. 209*13124SAlexander.Kolbasov@Sun.COM 210*13124SAlexander.Kolbasov@Sun.COM=head2 tdelta(PGOBJ, PG) 211*13124SAlexander.Kolbasov@Sun.COM 212*13124SAlexander.Kolbasov@Sun.COMReturn time interval between two snapshots for the given PG. The time is expressed in seconds and is a floating-point number. 213*13124SAlexander.Kolbasov@Sun.COM 214*13124SAlexander.Kolbasov@Sun.COM=head2 EXPORT 215*13124SAlexander.Kolbasov@Sun.COM 216*13124SAlexander.Kolbasov@Sun.COMNone by default. 217*13124SAlexander.Kolbasov@Sun.COM 218*13124SAlexander.Kolbasov@Sun.COM=head1 SEE ALSO 219*13124SAlexander.Kolbasov@Sun.COM 220*13124SAlexander.Kolbasov@Sun.COML<pginfo(1)>, L<pgstat(1)> 221*13124SAlexander.Kolbasov@Sun.COM 222*13124SAlexander.Kolbasov@Sun.COM=cut 223*13124SAlexander.Kolbasov@Sun.COM 224