Lines Matching +full:sub +full:- +full:node
37 # Sun::Solaris::Kstat is used to extract per-lgroup load average.
60 # The $loads hash keeps per-lgroup load average.
71 # Parse command-line options
101 gettext("%s: Options -C, -T and -P can not be used together\n"),
108 gettext("%s: Option -T can not be used with -I, -t\n"),
115 gettext("%s: Warning: with '-T' all lgroups on the command line "),
121 printf STDERR gettext("%s: Option -I can not be used with -L\n"),
131 my $l = Sun::Solaris::Lgrp->new($opt_G ? LGRP_VIEW_OS : LGRP_VIEW_CALLER) or
136 my @lgrps = nsort($l->lgrps);
137 my $root = $l->root;
138 my @intermediates = grep { $_ != $root && !$l->isleaf($_) } @lgrps;
141 # Print everything if -a is specified or it is default without -T
172 @lgrp_list = map { $l->parents($_) } @lgrp_list if $opt_P;
173 @lgrp_list = map { $l->children($_) } @lgrp_list if $opt_C;
178 # If both -L and -c are specified, just print list of CPUs.
180 my @cpus = uniqsort(map { $l->cpus($_, LGRP_CONTENT_HIERARCHY) }
226 map { $self_latencies{$_} = $l->latency($_, $_) } @lgrps;
228 # If -T is specified, just print topology and return.
246 my $is_leaf = $l->isleaf($lgrp);
255 my @children = $l->children($lgrp);
260 my @parents = $l->parents($lgrp);
281 print "\n\t$loads->{$lgrp}" if defined ($loads->{$lgrp});
297 sub usage
300 print STDERR " [-aceGlLmrt] [-u unit] [-C|-P] [lgrp] ...\n";
301 print STDERR " \t$cmdname -I [-c] [-G] [-C|-P] [lgrp] ...\n";
302 print STDERR " \t$cmdname -T [-aceGlLmr] [-u unit]\n";
303 print STDERR " \t$cmdname -h\n\n";
307 "\t-a: Equivalent to \"%s\" without -T and to \"%s\" with -T\n"),
308 "-celLmrt", "-celLmr";
311 gettext("\t-c: Print CPU information\n"),
312 gettext("\t-C: Children of the specified lgroups\n"),
313 gettext("\t-e: Print lgroup load average\n"),
314 gettext("\t-h: Print this message and exit\n"),
315 gettext("\t-I: Print lgroup or CPU IDs only\n"),
316 gettext("\t-l: Print information about lgroup latencies\n"),
317 gettext("\t-G: Print OS view of lgroup hierarchy\n"),
318 gettext("\t-L: Print lgroup latency table\n"),
319 gettext("\t-m: Print memory information\n"),
320 gettext("\t-P: Parent(s) of the specified lgroups\n"),
321 gettext("\t-r: Print lgroup resources\n"),
322 gettext("\t-t: Print information about lgroup topology\n"),
323 gettext("\t-T: Print the hierarchy tree\n"),
324 gettext("\t-u unit: Specify memory unit (b,k,m,g,t,p,e)\n\n\n");
333 "-celmrt all";
346 sub uniq
356 sub nsort
365 sub uniqsort
371 sub round
385 sub lgrp_expand
395 push(@result, $lobj->root), next if $lgrp =~ m/^root$/i;
397 push(@result, $lobj->leaves), next if $lgrp =~ m/^leaves$/i;
410 # lgrp_tree(class, node)
412 # Build the tree of the lgroup hierarchy starting with the specified node or
413 # root if no initial node is specified. Calls itself recursively specifying each
414 # of the children as a starting node. Builds a reference to the list with the
415 # node in the end and each element being a subtree.
417 sub lgrp_tree
420 my $lgrp = shift || $c->root;
423 [ (map { lgrp_tree($c, $_) } $c->children($lgrp)), $lgrp ];
429 # pretty-print the hierarchy tree.
436 sub lgrp_pp
451 print $myprefix ? "$bar" . "-- " : "";
456 # Pretty-print the subtree with a new offset.
458 lgrp_pp($_, "| ", "$childprefix$new_prefix", --$nchildren)
463 sub lgrp_prettyprint
467 lgrp_pp($tree, '', '', scalar $tree - 1);
470 sub lgrp_print
475 my $is_interm = ($lgrp != $root && !$l->isleaf($lgrp));
495 print "\n$prefix$loads->{$lgrp}" if defined ($loads->{$lgrp});
506 sub lgrp_showcpus
511 my @cpus = $l->cpus($lgrp, $hier);
523 sub lgrp_showmemory
528 my $memory = $l->mem_size($lgrp, LGRP_MEM_SZ_INSTALLED, $hier);
530 my $freemem = $l->mem_size($lgrp, LGRP_MEM_SZ_FREE, $hier) || 0;
534 my $usedmem = memory_to_string($memory - $freemem);
546 sub lgrp_showresources
551 my @resources_cpu = nsort($l->resources($lgrp, LGRP_RSRC_CPU));
552 my @resources_mem = nsort($l->resources($lgrp, LGRP_RSRC_MEM));
565 # Consolidate consequtive ids as start-end
567 # Output: string with space-sepated cpu values with ranges
568 # collapsed as x-y
570 sub lgrp_collapse
590 $result = "$result $start-$end";
604 $result = "$result $start-$end";
616 sub print_latency_table
626 # Field width for lgroup - the width of the largest lgroup and 1 space
629 my $width = length($l->latency($root, $root)) + 1;
636 print "\n", "-" x ($lgwidth + 1);
637 map { print '-' x $width } @$lgrps1;
640 print "\n", "-" x ($lgwidth + 1);
641 map { print '-' x $width } @$lgrps1;
646 printf "%-${lgwidth}d|", $l1;
648 my $latency = $l->latency($l1, $l2);
650 printf "%${width}s", "-";
659 print "-" x ($lgwidth + 1);
660 map { print '-' x $width } @lgrps;
670 sub number_to_scaled_string
702 sub memory_to_string
706 # Zero memory - just print 0
710 # Return memory size scaled to human-readable form unless -u is
732 sub get_lav
736 my $ks = Sun::Solaris::Kstat->new(strip_strings => 1) or
740 my $lgrp_kstats = $ks->{lgrp} or
746 next unless $lgrp_kstats->{$i}->{"lgrp$i"};
747 my $lav = $lgrp_kstats->{$i}->{"lgrp$i"}->{"load average"};
750 my $scale = $lgrp_kstats->{$i}->{"lgrp$i"}->{"loadscale"} ||
752 $load->{$i} = sprintf (gettext("Load: %4.3g"), $lav / $scale);