Section 6.13. Using the Perl Kstat API to Look at Memory Statistics


6.13. Using the Perl Kstat API to Look at Memory Statistics

You can also obtain kstat statistics through the Perl kstat API. With that approach, you can write simple scripts to collect the statistics. For example, below we display statistics for Section 6.4.2 quite easily by using the system_pages statistics.

%{$now} = %{$kstats->{0}{system_pages}}; print "$now->{pagesfree}\n"; 


Using a more elaborate script, we read the values for physmem, pp_kernel, and pagesfree and report them at regular intervals.

$ wget http://www.solarisinternals.com/si/downloads/prtmem.pl $ prtmem.pl 10 prtmem started on 04/01/2005 15:46:13 on d-mpk12-65-100, sample interval 5 seconds                    Total      Kernel       Delta        Free       Delta 15:46:18            2040         250           0         972         -12 15:46:23            2040         250           0         968          -3 15:46:28            2040         250           0         968           0 15:46:33            2040         250           0         970           1 ... 





Solaris Performance and Tools(c) Dtrace and Mdb Techniques for Solaris 10 and Opensolaris
Solaris Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris
ISBN: 0131568191
EAN: 2147483647
Year: 2007
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net