Solaris::Kstat

Solaris::Kstat is a Perl module to access Solaris Kstats from Perl.
Download

Solaris::Kstat Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Alan Burlison
  • Publisher web site:
  • http://search.cpan.org/~aburlison/

Solaris::Kstat Tags


Solaris::Kstat Description

Solaris::Kstat is a Perl module to access Solaris Kstats from Perl. Solaris::Kstat is a Perl module to access Solaris Kstats from Perl.SYNOPSIS use Solaris::Kstat; my $kstat = Solaris::Kstat->new(); my ($usr1, $sys1, $wio1, $idle1) = @{$kstat->{cpu_stat}{0}{cpu_stat0}}{qw(user kernel wait idle)}; print("usr sys wio idlen"); while (1) { sleep 5; if ($kstat->update()) { print("Configuration changedn"); } my ($usr2, $sys2, $wio2, $idle2) = @{$kstat->{cpu_stat}{0}{cpu_stat0}}{qw(user kernel wait idle)}; printf(" %.2d %.2d %.2d %.2dn", ($usr2 - $usr1) / 5, ($sys2 - $sys1) / 5, ($wio2 - $wio1) / 5, ($idle2 - $idle1) / 5); $usr1 = $usr2; $sys1 = $sys2; $wio1 = $wio2; $idle1 = $idle2; }This module provides a tied hash interface to the Solaris kstats library. The kstats library allows you to get access to all the stats used by sar, iostat, vmstat etc, plus a lot of others that aren't accessible through the usual utilities.Solaris categorises statistics using a 3-part key - module, instance and name. For example, the root disk stats can be found under sd.0.sd0, and the cpu statistics can be found under cpu_stat.0.cpu_stat0, as in the above example. The method Solaris::Kstats-new()> creates a new 3-layer tree of perl hashes with exactly the same structure - i.e. the stats for disk 0 can be accessed as $ks-{sd}{0}{sd0}>. The bottom (4th) layer is a tied hash used to hold the individual statistics values for a particular system resource.Creating a Solaris::Kstat object doesn't actually read all the possible statistics in, as this would be horribly slow and inefficient. Instead it creates a 3-layer structure as described above, and only reads in the individual statistics as you reference them. For example, accessing $ks-{sd}{0}{sd0}{reads} will read in all the statistics for sd0, including writes, bytes read/written, service times etc. Once you have accessed a bottom level statitics value, calling $ks->update() will automatically update all the individual values of any statistics that you have accessed.Note that there are two values per bottom-level hash that can be read without causing the full set of statistics to be read from the kernel. These are "class" which is the kstat class of the statistics and "crtime" which is the time that the kstat was created. See kstat(3K) for full details of these fields. Requirements: · Perl


Solaris::Kstat Related Software