O'Reilly logo

Solaris by Brendan Gregg, Jim Mauro, Richard McDougall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix D. Sample Perl Kstat Utilities

A Simple Kstat Walker

#!/usr/bin/perl -w # # kgrep - walk the Kstat tree, grepping names. # # This is a simple demo of walking the Kstat tree in Perl. The output # is similar to a "kstat -p", however an argument can be provided to # grep the full statistic name (joined by ":"). # # USAGE: kgrep [pattern] # eg, kgrep hme0 use strict; use Sun::Solaris::Kstat; my $Kstat = Sun::Solaris::Kstat->new(); my $pattern = defined $ARGV[0] ? $ARGV[0] : "."; die "USAGE: kgrep [pattern]\n" if $pattern eq "-h"; # loop over all kstats foreach my $module (keys(%$Kstat)) { my $Modules = $Kstat->{$module}; foreach my $instance (keys(%$Modules)) { my $Instances = $Modules->{$instance}; foreach my $name (keys(%$Instances)) { my ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required