Sys-Statistics-Linux-0.66000750000000000000 011726272174 14553 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/INSTALL000444000000000000 71011726272174 15724 0ustar00rootroot000000000000To install the module execute the following steps: perl Makefile.PL make make test "make test" do some tests. If you get error messages then you shouldn't install the module. Take a look into the README to the TECHNICAL NOTE section for a description and send me a bug report please. Otherwise your last step is: make install and have a lot of fun with Sys::Statistics::Linux. Don't forget to take a look into the "examples" diretory. :-) Sys-Statistics-Linux-0.66/Build.PL000444000000000000 127011726272174 16211 0ustar00rootroot000000000000use strict; use warnings; use Module::Build; die 'OS unsupported! Sorry, but this system seems not to be a linux system!' unless $^O =~ /linux/i; die 'OS unsupported! Stupid! RTFM and gimme me access to /proc ;-)' unless -r '/proc'; my $build = Module::Build->new( create_readme => 1, license => 'perl', module_name => 'Sys::Statistics::Linux', dist_author => 'Jonny Schulz', sign => 0, recommends => { 'YAML::Syck' => 0, }, requires => { 'Carp' => 0, 'POSIX' => 0, 'Test::More' => 0, 'Time::HiRes' => 0, 'UNIVERSAL' => 0, }, ); $build->create_build_script; Sys-Statistics-Linux-0.66/README000444000000000000 3467111726272174 15630 0ustar00rootroot000000000000NAME Sys::Statistics::Linux - Front-end module to collect system statistics SYNOPSIS use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( sysinfo => 1, cpustats => 1, procstats => 1, memstats => 1, pgswstats => 1, netstats => 1, sockstats => 1, diskstats => 1, diskusage => 1, loadavg => 1, filestats => 1, processes => 1, ); sleep 1; my $stat = $lxs->get; DESCRIPTION Sys::Statistics::Linux is a front-end module and gather different linux system information like processor workload, memory usage, network and disk statistics and a lot more. Refer the documentation of the distribution modules to get more information about all possible statistics. MOTIVATION My motivation is very simple... every linux administrator knows the well-known tool sar of sysstat. It helps me a lot of time to search for system bottlenecks and to solve problems, but it's hard to parse the output if you want to store the statistics into a database. So I thought to develope Sys::Statistics::Linux. It's not a replacement but it should make it simpler to you to write your own system monitor. If Sys::Statistics::Linux doesn't provide statistics that are strongly needed then let me know it. TECHNICAL NOTE This distribution collects statistics by the virtual /proc filesystem (procfs) and is developed on the default vanilla kernel. It is tested on x86 hardware with the distributions RHEL, Fedora, Debian, Ubuntu, Asianux, Slackware, Mandriva and openSuSE (SLES on zSeries as well but a long time ago) on kernel versions 2.4 and/or 2.6. It's possible that it doesn't run on all linux distributions if some procfs features are deactivated or too much modified. As example the linux kernel 2.4 can compiled with the option `CONFIG_BLK_STATS' what turn on or off block statistics for devices. Don't give up if some of the modules doesn't run on your hardware! Tell me what's wrong and I will try to solve it! You just have to make the first move and to send me a mail. :-) VIRTUAL MACHINES Note that if you try to install or run `Sys::Statistics::Linux' under virtual machines on guest systems that some statistics are not available, such as `SockStats', `PgSwStats' and `DiskStats'. The reason is that not all /proc data are passed to the guests. If the installation fails then try to force the installation with cpan> force install Sys::Statistics::Linux and notice which tests fails, because this statistics maybe not available on the virtual machine - sorry. DELTAS The statistics for `CpuStats', `ProcStats', `PgSwStats', `NetStats', `DiskStats' and `Processes' are deltas, for this reason it's necessary to initialize the statistics before the data can be prepared by `get()'. These statistics can be initialized with the methods `new()', `set()' and `init()'. For any option that is set to 1, the statistics will be initialized by the call of `new()' or `set()'. The call of init() re-initialize all statistics that are set to 1 or 2. By the call of `get()' the initial statistics will be updated automatically. Please refer the section METHODS to get more information about the usage of `new()', `set()', `init()' and `get()'. Another exigence is to sleep for a while - at least for one second - before the call of `get()' if you want to get useful statistics. The statistics for `SysInfo', `MemStats', `SockStats', `DiskUsage', `LoadAVG' and `FileStats' are no deltas. If you need only one of these information you don't need to sleep before the call of `get()'. The method `get()' prepares all requested statistics and returns the statistics as a Sys::Statistics::Linux::Compilation object. The inital statistics will be updated. MANUAL PROC(5) The Linux Programmer's Manual http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html If you have questions or don't understand the sense of some statistics then take a look into this awesome documentation. OPTIONS All options are identical with the package names of the distribution in lowercase. To activate the gathering of statistics you have to set the options by the call of `new()' or `set()'. In addition you can deactivate statistics with `set()'. The options must be set with one of the following values: 0 - deactivate statistics 1 - activate and init statistics 2 - activate statistics but don't init In addition it's possible to pass a hash reference with options. my $lxs = Sys::Statistics::Linux->new( processes => { init => 1, pids => [ 1, 2, 3 ] }, netstats => { init => 1, initfile => $file, }, ); Option `initfile' is useful if you want to store initial statistics on the filesystem. my $lxs = Sys::Statistics::Linux->new( cpustats => { init => 1, initfile => '/tmp/cpustats.yml', }, diskstats => { init => 1, initfile => '/tmp/diskstats.yml', }, netstats => { init => 1, initfile => '/tmp/netstats.yml', }, pgswstats => { init => 1, initfile => '/tmp/pgswstats.yml', }, procstats => { init => 1, initfile => '/tmp/procstats.yml', }, ); Example: #!/usr/bin/perl use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( pgswstats => { init => 1, initfile => '/tmp/pgswstats.yml' } ); $lxs->get(); # without to sleep The initial statistics are stored to the temporary file: #> cat /tmp/pgswstats.yml --- pgfault: 397040955 pgmajfault: 4611 pgpgin: 21531693 pgpgout: 49511043 pswpin: 8 pswpout: 272 time: 1236783534.9328 Every time you call the script the initial statistics are loaded/stored from/to the file. This could be helpful if you doesn't run it as daemon and if you want to calculate the average load of your system since the last call. Do you understand? I hope so :) To get more information about the statistics refer the different modules of the distribution. sysinfo - Collect system information with Sys::Statistics::Linux::SysInfo. cpustats - Collect cpu statistics with Sys::Statistics::Linux::CpuStats. procstats - Collect process statistics with Sys::Statistics::Linux::ProcStats. memstats - Collect memory statistics with Sys::Statistics::Linux::MemStats. pgswstats - Collect paging and swapping statistics with Sys::Statistics::Linux::PgSwStats. netstats - Collect net statistics with Sys::Statistics::Linux::NetStats. sockstats - Collect socket statistics with Sys::Statistics::Linux::SockStats. diskstats - Collect disk statistics with Sys::Statistics::Linux::DiskStats. diskusage - Collect the disk usage with Sys::Statistics::Linux::DiskUsage. loadavg - Collect the load average with Sys::Statistics::Linux::LoadAVG. filestats - Collect inode statistics with Sys::Statistics::Linux::FileStats. processes - Collect process statistics with Sys::Statistics::Linux::Processes. METHODS new() Call `new()' to create a new Sys::Statistics::Linux object. You can call `new()' with options. This options would be passed to the method `set()'. Without options my $lxs = Sys::Statistics::Linux->new(); Or with options my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); Would do nothing my $lxs = Sys::Statistics::Linux->new( cpustats => 0 ); It's possible to call `new()' with a hash reference of options. my %options = ( cpustats => 1, memstats => 1 ); my $lxs = Sys::Statistics::Linux->new(\%options); set() Call `set()' to activate or deactivate options. The following example would call `new()' and initialize `Sys::Statistics::Linux::CpuStats' and delete the object of `Sys::Statistics::Linux::SysInfo'. $lxs->set( processes => 0, # deactivate this statistic pgswstats => 1, # activate the statistic and calls new() and init() if necessary netstats => 2, # activate the statistic and call new() if necessary but not init() ); It's possible to call `set()' with a hash reference of options. my %options = ( cpustats => 2, memstats => 2 ); $lxs->set(\%options); get() Call `get()' to get the collected statistics. `get()' returns a Sys::Statistics::Linux::Compilation object. my $lxs = Sys::Statistics::Linux->new(\%options); sleep(1); my $stat = $lxs->get(); Or you can pass the time to sleep with the call of `get()'. my $stat = $lxs->get($time_to_sleep); Now the statistcs are available with $stat->cpustats # or $stat->{cpustats} Take a look to the documentation of Sys::Statistics::Linux::Compilation for more information. init() The call of `init()' initiate all activated statistics that are necessary for deltas. That could be helpful if your script runs in a endless loop with a high sleep interval. Don't forget that if you call `get()' that the statistics are deltas since the last time they were initiated. The following example would calculate average statistics for 30 minutes: # initiate cpustats my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); while ( 1 ) { sleep(1800); my $stat = $lxs->get; } If you just want a current snapshot of the system each 30 minutes and not the average then the following example would be better for you: # do not initiate cpustats my $lxs = Sys::Statistics::Linux->new( cpustats => 2 ); while ( 1 ) { $lxs->init; # init the statistics my $stat = $lxs->get(1); # get the statistics sleep(1800); # sleep until the next run } If you want to write a simple command line utility that prints the current workload to the screen then you can use something like this: my @order = qw(user system iowait idle nice irq softirq total); printf "%-20s%8s%8s%8s%8s%8s%8s%8s%8s\n", 'time', @order; my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); while ( 1 ){ my $cpu = $lxs->get(1)->cpustats; my $time = $lxs->gettime; printf "%-20s%8s%8s%8s%8s%8s%8s%8s%8s\n", $time, @{$cpu->{cpu}}{@order}; } settime() Call `settime()' to define a POSIX formatted time stamp, generated with localtime(). $lxs->settime('%Y/%m/%d %H:%M:%S'); To get more information about the formats take a look at `strftime()' of POSIX.pm or the manpage `strftime(3)'. gettime() `gettime()' returns a POSIX formatted time stamp, @foo in list and $bar in scalar context. If the time format isn't set then the default format "%Y-%m-%d %H:%M:%S" will be set automatically. You can also set a time format with `gettime()'. my $date_time = $lxs->gettime; Or my ($date, $time) = $lxs->gettime(); Or my ($date, $time) = $lxs->gettime('%Y/%m/%d %H:%M:%S'); EXAMPLES A very simple perl script could looks like this: use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); sleep(1); my $stat = $lxs->get; my $cpu = $stat->cpustats->{cpu}; print "Statistics for CpuStats (all)\n"; print " user $cpu->{user}\n"; print " nice $cpu->{nice}\n"; print " system $cpu->{system}\n"; print " idle $cpu->{idle}\n"; print " ioWait $cpu->{iowait}\n"; print " total $cpu->{total}\n"; Set and get a time stamp: use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new(); $lxs->settime('%Y/%m/%d %H:%M:%S'); print $lxs->gettime, "\n"; If you want to know how the data structure looks like you can use `Data::Dumper' to check it: use strict; use warnings; use Sys::Statistics::Linux; use Data::Dumper; my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); sleep(1); my $stat = $lxs->get; print Dumper($stat); How to get the top 5 processes with the highest cpu workload: use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( processes => 1 ); sleep(1); my $stat = $lxs->get; my @top5 = $stat->pstop( ttime => 5 ); BACKWARD COMPATIBILITY The old options and keys - CpuStats, NetStats, etc - are still available but deprecated! It's not possible to access the statistics via Sys::Statistics::Linux::Compilation and it's not possible to call `search()' and `psfind()' if you use the old options. You should use the new options and access the statistics over the accessors $stats->cpustats or directly with $stats->{cpustats} PREREQUISITES Carp POSIX Test::More Time::HiRes UNIVERSAL EXPORTS No exports. TODOS * Are there any wishs from your side? Send me a mail! REPORTING BUGS Please report all bugs to . AUTHOR Jonny Schulz . COPYRIGHT Copyright (C) 2006-2008 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Sys-Statistics-Linux-0.66/META.yml000444000000000000 355411726272174 16175 0ustar00rootroot000000000000--- abstract: 'Front-end module to collect system statistics' author: - 'Jonny Schulz' configure_requires: Module::Build: 0.36 generated_by: 'Module::Build version 0.3607' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Sys-Statistics-Linux provides: Sys::Statistics::Linux: file: lib/Sys/Statistics/Linux.pm version: 0.66 Sys::Statistics::Linux::Compilation: file: lib/Sys/Statistics/Linux/Compilation.pm version: 0.10 Sys::Statistics::Linux::CpuStats: file: lib/Sys/Statistics/Linux/CpuStats.pm version: 0.20 Sys::Statistics::Linux::DiskStats: file: lib/Sys/Statistics/Linux/DiskStats.pm version: 0.24 Sys::Statistics::Linux::DiskUsage: file: lib/Sys/Statistics/Linux/DiskUsage.pm version: 0.14 Sys::Statistics::Linux::FileStats: file: lib/Sys/Statistics/Linux/FileStats.pm version: 0.09 Sys::Statistics::Linux::LoadAVG: file: lib/Sys/Statistics/Linux/LoadAVG.pm version: 0.08 Sys::Statistics::Linux::MemStats: file: lib/Sys/Statistics/Linux/MemStats.pm version: 0.16 Sys::Statistics::Linux::NetStats: file: lib/Sys/Statistics/Linux/NetStats.pm version: 0.21 Sys::Statistics::Linux::PgSwStats: file: lib/Sys/Statistics/Linux/PgSwStats.pm version: 0.18 Sys::Statistics::Linux::ProcStats: file: lib/Sys/Statistics/Linux/ProcStats.pm version: 0.20 Sys::Statistics::Linux::Processes: file: lib/Sys/Statistics/Linux/Processes.pm version: 0.38 Sys::Statistics::Linux::SockStats: file: lib/Sys/Statistics/Linux/SockStats.pm version: 0.09 Sys::Statistics::Linux::SysInfo: file: lib/Sys/Statistics/Linux/SysInfo.pm version: 0.13 recommends: YAML::Syck: 0 requires: Carp: 0 POSIX: 0 Test::More: 0 Time::HiRes: 0 UNIVERSAL: 0 resources: license: http://dev.perl.org/licenses/ version: 0.66 Sys-Statistics-Linux-0.66/Makefile.PL000444000000000000 124011726272174 16664 0ustar00rootroot000000000000use ExtUtils::MakeMaker; die 'OS unsupported! Sorry, but this system seems not to be a linux system!' unless $^O =~ /linux/i; die 'OS unsupported! Stupid! RTFM and gimme me access to /proc ;-)' unless -r '/proc'; WriteMakefile ( NAME => 'Sys::Statistics::Linux', VERSION_FROM => 'lib/Sys/Statistics/Linux.pm', PREREQ_PM => { 'UNIVERSAL::require' => 0, 'UNIVERSAL' => 0, 'Test::More' => 0, 'Carp' => 0, 'POSIX' => 0, 'Time::HiRes' => 0, }, INSTALLDIRS => 'site', EXE_FILES => [ ], PL_FILES => { } ); Sys-Statistics-Linux-0.66/LICENCE000444000000000000 260011726272174 15700 0ustar00rootroot000000000000Copyright (C) 2007-2008 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Sys-Statistics-Linux-0.66/MANIFEST000444000000000000 211111726272174 16041 0ustar00rootroot000000000000Build.PL ChangeLog examples/diskusage.pl examples/loadavg.pl examples/processes.pl examples/pstop.pl INSTALL lib/Sys/Statistics/Linux.pm lib/Sys/Statistics/Linux/Compilation.pm lib/Sys/Statistics/Linux/CpuStats.pm lib/Sys/Statistics/Linux/DiskStats.pm lib/Sys/Statistics/Linux/DiskUsage.pm lib/Sys/Statistics/Linux/FileStats.pm lib/Sys/Statistics/Linux/LoadAVG.pm lib/Sys/Statistics/Linux/MemStats.pm lib/Sys/Statistics/Linux/NetStats.pm lib/Sys/Statistics/Linux/PgSwStats.pm lib/Sys/Statistics/Linux/Processes.pm lib/Sys/Statistics/Linux/ProcStats.pm lib/Sys/Statistics/Linux/SockStats.pm lib/Sys/Statistics/Linux/SysInfo.pm LICENCE Makefile.PL MANIFEST This list of files META.yml README t/001-pod.t t/002-pod-coverage.t t/010-sysinfo.t t/020-cpustats.t t/030-procstats.t t/040-memstat.t t/050-pgswstats.t t/060-netstats.t t/070-sockstats.t t/080-diskstats.t t/090-diskusage.t t/100-loadavg.t t/110-filestats.t t/120-processes.t t/130-search.t t/140-psfind.t t/150-pstop.t t/examples/cpuinfo0 t/examples/cpuinfo1 t/examples/cpuinfo2 t/examples/cpuinfo3 t/examples/cpuinfo4 t/examples/cpuinfo5 Sys-Statistics-Linux-0.66/ChangeLog000444000000000000 4134011726272174 16511 0ustar00rootroot0000000000000.66 Released at 2012-03-09. - Quick fix and replaced the "defined or" operator // with || in Processes.pm for backward compability with Perl < 5.10. Thanks to all CPAN smoker for the fix test reports! 0.65 Released at 2012-03-07. - Just a full release. 0.64_2 Released at 2012-03-02. - Redesign of init() and load() of Processes.pm. 0.64_1 Released at 2012-03-02. - Debugging undef warnings from version 0.63 on lines 452, 490, 494, 501, 502. Thanks for helping! 0.63 Released at 2012-02-16. - Big sorry! The deletion of the PID was no good idea. Fixed it and check if proc->pid->io exists instead to delete the PID. 0.62 Released at 2012-02-16. - Fixed a bug in Processes.pm. Delete a PID if it's not possible to open /proc/pid/io, otherwise the warning "Use of uninitialized value in division (/) at Processes.pm line 505" is printed. 0.61 Released at 2011-09-27. - Fixed a bug in NetStats.pm. The interface name was matched with \w, what is really bad if the name of a interface contains other signs like a dot. 0.60 Released at 2011-06-22. - Just a full release. Have fun :-) 0.59_02 Released at 2011-04-16. - Fixed a little bug in Processes.pm (_init). 0.59_01 Released at 2011-04-14. - Added statistics from /proc/pid/io to Processes.pm. See RT #67459. 0.59 Released at 2010-09-28. - Added key "arch" to SysInfo.pm. 0.58 Released at 2010-09-27. - Kicked cpuinfo from SysInfo.pm. 0.57_04 Released at 2010-08-27. - Fixed pcpucount and tcpucount in SysInfo.pm. 0.57_03 Released at 2010-08-17. - Fixed the validating of params in new() in all modules that generates aggregates. - Changed SysInfo and kicked niccount. 0.57_02 Released at 2010-08-06. - Fixed some bugs in SysInfo for keys pcpucount and niccount. - Added key cpuinfo. - It's now possible to add %opts to the call of new() of each statistic module to set the path to proc. 0.57_01 Released at 2010-08-05. - Added method raw() to CpuStats, DiskStats, NetStats, PgSwStats, and ProcStats. - Added niccount, pcpucount and tcpucount to SysInfo. - Fixed issues from RT #60100 and #60098. 0.56 Released at 2009-10-07. - Just a full release. 0.55_02 Released at 2009-09-28. - Processes.pm: calculate the keys minflt, cminflt, mayflt, cmayflt, utime, stime, cutime, and cstime with sttime and uptime. 0.55_01 Released at 2009-09-03. - Processes.pm: processes that are created between the call of init() and get() are now returned. The keys minflt, cminflt, mayflt, cmayflt, utime, stime, cutime, and cstime are set to 0.00 - see RT #49363 0.54 Released at 2009-08-17. - No changes, just a full release. 0.53_01 Released at 2009-08-10. - Fixed wchan in Processes.pm - RT #48458 0.52 Released at 2009-06-05. - No changes, just a full release. 0.51_01 Released at 2009-05-29. - Fixed tests 060-netstats.t and 070-sockstats.t. - Updated the most of the other test files. - Fixed a bug in Processes.pm - actime wasn't calculated correct. - Added $RAWTIME to SysInfo.pm to get the raw time with jiffies for uptime and idletime. 0.50 Released at 2009-05-17. - ProcStats: renamed stat "procs_blocked" to "blocked" and added stat "running". 0.49 Released at 2009-03-15. - Just a full version... all tests runs without errors. 0.48_02 Released at 2009-03-11. - Fixed some tests and updated the documentation. 0.48_01 Released at 2009-03-07. - Fixed some tests. - Fixed initfile in CpuStats, DiskStats, NetStats, PgSwStats and ProcStats - if the machine was rebootet the deltas couldn't be calculated. 0.48 Released at 2009-03-07. - Fixed tests 050-pgswstats.t, 070-sockstats.t, 080-diskstats.t. If linux runs as a virtual machine than it's possible that the statistics pgswstats, sockstats and diskstats are not available. - Fixed regex in MemStats.pm - key "dirty" never matched. - Fixed Processes.pm - now all processses will be collected. - Added option initfile to PgSwStats, CpuStats, DiskStats, NetStats and ProcStats - YAML::Syck as serializer. 0.47 Released at 2009-02-10. - GRML - forget to upgrade $VERSION in Processes.pm :) 0.46 Released at 2009-02-10. - Fixed a bug in Processs.pm. If /proc//fd is empty then t/120-processes.t returns an error. 0.45 Released at 2009-02-02. - Just a full release. 0.44_03 Released at 2009-01-19. - Fixed some tests. 0.44_02 Released at 2009-01-18. - Fixed a bug: delete a process if the process doesn't exists any more and jump to the next PID with "next PID;". - Fixed some tests. 0.44_01 Released at 2009-01-13. - Added "wchan" and "fd" to Processes.pm. 0.43 Released at 2008-10-29. - Kicked UNIVERSAL::require. - Now it's possible to pass $sleep_time to get(). 0.42 Released at 2008-10-06. - Added $PAGES_TO_BYTES to Sys::Statistics::Linux::Processes. With this variable it's possible to get bytes/kilobytes instead of pages for some statistics - feature request of Marcus V. - Fixed a bug in processes. The values drs and lrs in Processes.pm were interchanged. 0.41 Released at 2008-10-01. - http://rt.cpan.org/Ticket/Display.html?id=39723 Sys::Statistics::Linux::DiskUsage - added global variables $DF_PATH and $DF_CMD. 0.40 Released at 2008-09-24. - All tests for 0.39_01 runs fine, now a full version. 0.39_01 Released at 2008-09-22. - http://rt.cpan.org/Public/Bug/Display.html?id=39451 Fixed bug in Memstats.pm for key "inactive". On earlier kernels it's Inact_dirty, Inact_laundry and Inact_clean. Thanks to Peter E. for his report. 0.38 Released at 2008-09-11. - Fixed a little bug in Processes.pm - thanks to Marcus V. for his report! Marcus reported that minflt could be negativ on Xen machines and Processes.pm croaks with the message: "value of 'minflt' is not a number". - Different code improvements in ProcStats.pm, NetStats.pm, CpuStats.pm, PgSwStats.pm. 0.37 Released at 2008-09-05. - Fixed a bug in Linux.pm for netstats/netinfo. The raw data was returned with netstats and not the deltas. 0.36 Released at 2008-05-13. - Tests for 0.35_01 all ok. Now a full release. 0.35_01 Released at 2008-05-08. - Added irq, softirq, steal to CpuStats.pm. - Fixed the calculation of total cpu utilization in CpuStats.pm. Thanks to Morton B. for his suggestion. - Key iowait is only available with kernels >= 2.6. 0.34 Released at 2008-04-08. - Timestamp of 0.33 in the future and a lot of fail reports. 0.33 Released at 2008-04-04. - Found a bug in Processes.pm. New processes were not added to $self->{init}. 0.32 Released at 2008-02-27. - DAWN! Forget to add Time::HiRes to the dependencies! 0.30 Released at 2008-02-27. - Replaced uptime() with Time::HiRes::gettimeofday(). 0.28 Released at 2008-02-11. - Full version. Jupm over 0.27 because I want to use odd numbers for developer releases in the future. - Better documentation here and there. 0.26_02 Released at 2008-02-08. - Fixed a lot of POD typos. 0.26_01 Released at 2008-02-07. - *uhm* forget to kicked cpuinfo() - Added netinfo() to get the raw data of netstats() (feature request). 0.26 Released at 2008-01-16. - Tests seems to be okay... just a full version. 0.25_02 Released at 2008-01-10. - Kicked from MemStats: hightotal, highfree, lowtotal, lowfree The reason is that 64-bit architectures by their nature has high memory support and do not need the HIGHMEM configuration directive. As a result these values are not available on any 64-bit. Yes, there exists exceptions on some distributions like RHEL4 x86_64, but are they useful? 0.25_01 Released at 2008-01-08. - Added to MemStats: swapcached, active, inactive, hightotal, highfree, lowtotal, lowfree, commitlimit and committed_as 0.25 Released at 2007-11-20. - Kicked CpuInfo.pm. The reason is that /proc/cpuinfo can be very different on various architectures. 0.24 Released at 2007-11-19. - Fixed swapusedper. - Some POD improvements. 0.23 Released at 2007-11-19. - *grml* forget to update ChangeLog :) 0.22 Released at 2007-11-19. - Added pstop() to Compilation.pm and t/150pstop.t. - Did some POD fixes in all modules. 0.21_02 Released at 2007-11-18. - Added CpuInfo.pm. 0.21_01 Released at 2007-11-18. - WHOA a lot of changes... - All options are lowercase now! The key names are now lowercase as well! For compatibilities the old options are still available. As example: CpuStats is now cpustats. - Added Sys::Statistics::Linux::Compilation - get() now returns a Sys::Statistics::Linux::Compilation object. You can access the statistics now via $stat->cpustats or $stat->{cpustats}. The adventage is object oriented access to the statistics and that the statistics are not stored into the Sys::Statistics::Linux object any more. That's a bit more memory friendly. 0.21 Released at 2007-10-15. - Skipped ipfrag in test if the key isn't defined because ipfrag is only avaiable by kernels > 2.2. 0.20 Released at 2007-10-08. - Fixed Makefile.PL. 0.19 Released at 2007-10-07. - No further changes, just a full version. 0.18_01 Released at 2007-10-06. - Testing for the current developer release of CPAN::Reporter. Makefile.PL die() if the os is not a linux and the new release of CPAN::Reporter sends a FAIL report. 0.18 Released at 2007-10-06. - Forget to update the version number of DiskUsage *grrr*. 0.17 Released at 2007-10-06. - Statistics minflt, cminflt, mayflt, cmayflt, utime, stime, cutime, and cstime from Processes.pm are now ever floats. - Sys::Statistics::Linux is taint safe now. - Did some code improvements and fixed pod typos. 0.16 Released at 2007-09-17. - Bug fixed in Processes.pm. The deltas of utime, stime and ttime weren't calculated per second. 0.15 Released at 2007-08-04. - Bug fixed in DiskStats.pm. major and minor were floats. 0.14 Released at 2007-07-30. - psfind() and search() checks now if a list is wanted. If no statistics found it return undef ... thats bad. 0.13 Released at 2007-07-12. - Forget to add os check in make file *argh* sorry! :-) 0.12 Released at 2007-07-12. - Added key nlwp to Processes. - All pods updated. 0.11_03 Released at 2007-07-10. - Added pgfault and pgmajfault to PgSwStats. - Add section MOTIVATION to pod. 0.11_02 Released at 2007-07-10. - Fixed Build.PL and Makefile.PL. 0.11_01 Released at 2007-07-10. - Kicked option -1 - does anybody need that option really? I think not! - Now the disk usage is collected with "df -kP". I hope that works on all distributions. 0.11 Released at 2007-06-19. - Fixed _diff() and replace it with _compare(). - Did some other code changes like regexes. - Kicked operators < > = ! as options for search() and psfind(). 0.10 Released at 2007-05-25. - Fixed div code parts. - Now there can be pass a process list to Processes. 0.09_18 Released at 2007-05-16. - Added ttpcks (rxpcks + txpcks) to NetStats. - Fixed a bug in DiskStats. The field for wrtbyt was wrong. - Changed method name fproc() to psfind(). 0.09_17 Released at 2007-04.27. - Fixed actime from Processes.pm. - Null values are now printed as 0.00 by ProcStats, NetStats, DiskStats and PgSwStats. 0.09_16 Released at 2007-04-21. - Fixed code in NetStats.pm, DiskStats.pm, PgSwStats.pm and ProcStats.pm. It seems to run better and better. :-) 0.09_15 Error by uploading to pause. 0.09_14 Released at 2007-04-13. - Code fixes. 0.09_13 Released at 2007-04-13. - Did some fixes in DiskStats.pm, because the error message "... no diskstats found ..." is ever issued. - Did some fixes in fproc() and search() of Linux.pm. 0.09_12 Released at 2007-04-12. - Changed search() and fproc(). Now statistics can be set as second argument. The first argument has to be the search filter. Both arguments has to be a hash refrence. 0.09_11 Released at 2007-04-12. - To much files uploaded. :-) 0.09_10 Released at 2007-04-12. - Fixed the "Can't call method _struct" bug in Linux.pm line 419. - "new" from ProcStats is float now. Did some fixes in ProcStats, NetStats, PgSwStats and DiskStats... wrong averages/s calculated. 0.09_09 Released at 2007-04-12. - Delete key "pid" from Processes() because it exists double times: $stats->{Processes}->{$pid}->{pid} = $pid - Now all values of PgSwStats, NetStats, DiskStats and ProcStats (here only the key "new") are values per second. I break this down because it's very confusing if the statistics are just add together. - I kicked IO::File and the _load() Method from some modules because they weren't really necessary. 0.09_08 Released at 2007-03-05. - Add the method fproc() to search for processes. - Add t/14fproc.t and changed other test file names. - Improve the search() method and add a bit documentation. 0.09_06 Released at 2007-02-25. - Improve the search() method. Now it's possible to search() for special devices and more. 0.09_05 Released at 2007-02-23. - Added realfreeper to MemStats. 0.09_04 Released at 2007-02-23. - The next release today. :) - Added key realfree to MemStats (free + buffers + cached). 0.09_03 Released at 2007-02-23. - Added key ttime to Processes (stime + utime). - Fixed NetStats.t and Processes.t - missed ttbyt and ttime. 0.09_02 Released at 2007-02-23. - Fixed search(). Now it returns only that statistics that matched the search string. 0.09_01 Released at 2007-02-19. - A lot of changes in Linux.pm. - Sub modules will only be loaded if they are needed now. - Added a search() method to search for values in statistics. - Now there are different options (-1, 0, 1, 2) available for the statistics. - Added key ttbyt to NetStats (total bytes rx + tx). 0.08 Released at 2007-02-13. - Added key writeback to MemStats and actualize the documentation. The new keys dirty, slab, mapped and writeback are only available by kernels from 2.6. 0.07 Released at 2007-02-12. - Added keys dirty, slab and mapped to MemStats. 0.06 Released at 2007-01-22. - Bugfix in ProcStats.pm. "count" statistics fixed. - Added t/Pod-Coverage.t. 0.05 Released at 2006-12-30. - Updated t/DiskStats.t. - Updated POD and README. 0.04 Released at 2006-12-29. - DiskStats died now if the read access to /proc/partitions was successful and if there are no statistics. The reason is that it seems to be that the linux kernel (<=2.4) is not compiled with CONFIG_BLK_STATS=y. Up to now the message "there are no initial statistics defined" was generated and this message is not very helpful if init() was called. 0.03 Released at 2006-12-28. - Updated Sys::Statistics::Linux::CpuStats. There weren't irq and softirq calculated for the uptime for each cpu. This values are only available with kernels > 2.4. That aren't new keys! Just added for calculation. Thanks to Alexey A Makeev for his report! In addition I updated the documentation for iowait and note that this statistic is only available by kernel versions higher than 2.4. - All values for CpuStats are now ever floats "%.2f", not only if the values are higher than 0. 0.02 Released at 2006-12-09. - No code changes. Just updated POD and added t/Pod.t. 0.01 Released at 2006-12-08. x.xx Thanks to Larry Wall and all other Perl developers for Perl :-) Sys-Statistics-Linux-0.66/lib000750000000000000 011726272174 15321 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/lib/Sys000750000000000000 011726272174 16077 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/lib/Sys/Statistics000750000000000000 011726272174 20231 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux.pm000444000000000000 4141011726272174 22050 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux - Front-end module to collect system statistics =head1 SYNOPSIS use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( sysinfo => 1, cpustats => 1, procstats => 1, memstats => 1, pgswstats => 1, netstats => 1, sockstats => 1, diskstats => 1, diskusage => 1, loadavg => 1, filestats => 1, processes => 1, ); sleep 1; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux is a front-end module and gather different linux system information like processor workload, memory usage, network and disk statistics and a lot more. Refer the documentation of the distribution modules to get more information about all possible statistics. =head1 MOTIVATION My motivation is very simple... every linux administrator knows the well-known tool sar of sysstat. It helps me a lot of time to search for system bottlenecks and to solve problems, but it's hard to parse the output if you want to store the statistics into a database. So I thought to develope Sys::Statistics::Linux. It's not a replacement but it should make it simpler to you to write your own system monitor. If Sys::Statistics::Linux doesn't provide statistics that are strongly needed then let me know it. =head1 TECHNICAL NOTE This distribution collects statistics by the virtual F filesystem (procfs) and is developed on the default vanilla kernel. It is tested on x86 hardware with the distributions RHEL, Fedora, Debian, Ubuntu, Asianux, Slackware, Mandriva and openSuSE (SLES on zSeries as well but a long time ago) on kernel versions 2.4 and/or 2.6. It's possible that it doesn't run on all linux distributions if some procfs features are deactivated or too much modified. As example the linux kernel 2.4 can compiled with the option C what turn on or off block statistics for devices. Don't give up if some of the modules doesn't run on your hardware! Tell me what's wrong and I will try to solve it! You just have to make the first move and to send me a mail. :-) =head1 VIRTUAL MACHINES Note that if you try to install or run C under virtual machines on guest systems that some statistics are not available, such as C, C and C. The reason is that not all /proc data are passed to the guests. If the installation fails then try to force the installation with cpan> force install Sys::Statistics::Linux and notice which tests fails, because this statistics maybe not available on the virtual machine - sorry. =head1 DELTAS The statistics for C, C, C, C, C and C are deltas, for this reason it's necessary to initialize the statistics before the data can be prepared by C. These statistics can be initialized with the methods C, C and C. For any option that is set to 1, the statistics will be initialized by the call of C or C. The call of init() re-initialize all statistics that are set to 1 or 2. By the call of C the initial statistics will be updated automatically. Please refer the section L to get more information about the usage of C, C, C and C. Another exigence is to sleep for a while - at least for one second - before the call of C if you want to get useful statistics. The statistics for C, C, C, C, C and C are no deltas. If you need only one of these information you don't need to sleep before the call of C. The method C prepares all requested statistics and returns the statistics as a L object. The inital statistics will be updated. =head1 MANUAL PROC(5) The Linux Programmer's Manual http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html If you have questions or don't understand the sense of some statistics then take a look into this awesome documentation. =head1 OPTIONS All options are identical with the package names of the distribution in lowercase. To activate the gathering of statistics you have to set the options by the call of C or C. In addition you can deactivate statistics with C. The options must be set with one of the following values: 0 - deactivate statistics 1 - activate and init statistics 2 - activate statistics but don't init In addition it's possible to pass a hash reference with options. my $lxs = Sys::Statistics::Linux->new( processes => { init => 1, pids => [ 1, 2, 3 ] }, netstats => { init => 1, initfile => $file, }, ); Option C is useful if you want to store initial statistics on the filesystem. my $lxs = Sys::Statistics::Linux->new( cpustats => { init => 1, initfile => '/tmp/cpustats.yml', }, diskstats => { init => 1, initfile => '/tmp/diskstats.yml', }, netstats => { init => 1, initfile => '/tmp/netstats.yml', }, pgswstats => { init => 1, initfile => '/tmp/pgswstats.yml', }, procstats => { init => 1, initfile => '/tmp/procstats.yml', }, ); Example: #!/usr/bin/perl use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( pgswstats => { init => 1, initfile => '/tmp/pgswstats.yml' } ); $lxs->get(); # without to sleep The initial statistics are stored to the temporary file: #> cat /tmp/pgswstats.yml --- pgfault: 397040955 pgmajfault: 4611 pgpgin: 21531693 pgpgout: 49511043 pswpin: 8 pswpout: 272 time: 1236783534.9328 Every time you call the script the initial statistics are loaded/stored from/to the file. This could be helpful if you doesn't run it as daemon and if you want to calculate the average load of your system since the last call. Do you understand? I hope so :) To get more information about the statistics refer the different modules of the distribution. sysinfo - Collect system information with Sys::Statistics::Linux::SysInfo. cpustats - Collect cpu statistics with Sys::Statistics::Linux::CpuStats. procstats - Collect process statistics with Sys::Statistics::Linux::ProcStats. memstats - Collect memory statistics with Sys::Statistics::Linux::MemStats. pgswstats - Collect paging and swapping statistics with Sys::Statistics::Linux::PgSwStats. netstats - Collect net statistics with Sys::Statistics::Linux::NetStats. sockstats - Collect socket statistics with Sys::Statistics::Linux::SockStats. diskstats - Collect disk statistics with Sys::Statistics::Linux::DiskStats. diskusage - Collect the disk usage with Sys::Statistics::Linux::DiskUsage. loadavg - Collect the load average with Sys::Statistics::Linux::LoadAVG. filestats - Collect inode statistics with Sys::Statistics::Linux::FileStats. processes - Collect process statistics with Sys::Statistics::Linux::Processes. =head1 METHODS =head2 new() Call C to create a new Sys::Statistics::Linux object. You can call C with options. This options would be passed to the method C. Without options my $lxs = Sys::Statistics::Linux->new(); Or with options my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); Would do nothing my $lxs = Sys::Statistics::Linux->new( cpustats => 0 ); It's possible to call C with a hash reference of options. my %options = ( cpustats => 1, memstats => 1 ); my $lxs = Sys::Statistics::Linux->new(\%options); =head2 set() Call C to activate or deactivate options. The following example would call C and initialize C and delete the object of C. $lxs->set( processes => 0, # deactivate this statistic pgswstats => 1, # activate the statistic and calls new() and init() if necessary netstats => 2, # activate the statistic and call new() if necessary but not init() ); It's possible to call C with a hash reference of options. my %options = ( cpustats => 2, memstats => 2 ); $lxs->set(\%options); =head2 get() Call C to get the collected statistics. C returns a L object. my $lxs = Sys::Statistics::Linux->new(\%options); sleep(1); my $stat = $lxs->get(); Or you can pass the time to sleep with the call of C. my $stat = $lxs->get($time_to_sleep); Now the statistcs are available with $stat->cpustats # or $stat->{cpustats} Take a look to the documentation of L for more information. =head2 init() The call of C initiate all activated statistics that are necessary for deltas. That could be helpful if your script runs in a endless loop with a high sleep interval. Don't forget that if you call C that the statistics are deltas since the last time they were initiated. The following example would calculate average statistics for 30 minutes: # initiate cpustats my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); while ( 1 ) { sleep(1800); my $stat = $lxs->get; } If you just want a current snapshot of the system each 30 minutes and not the average then the following example would be better for you: # do not initiate cpustats my $lxs = Sys::Statistics::Linux->new( cpustats => 2 ); while ( 1 ) { $lxs->init; # init the statistics my $stat = $lxs->get(1); # get the statistics sleep(1800); # sleep until the next run } If you want to write a simple command line utility that prints the current workload to the screen then you can use something like this: my @order = qw(user system iowait idle nice irq softirq total); printf "%-20s%8s%8s%8s%8s%8s%8s%8s%8s\n", 'time', @order; my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); while ( 1 ){ my $cpu = $lxs->get(1)->cpustats; my $time = $lxs->gettime; printf "%-20s%8s%8s%8s%8s%8s%8s%8s%8s\n", $time, @{$cpu->{cpu}}{@order}; } =head2 settime() Call C to define a POSIX formatted time stamp, generated with localtime(). $lxs->settime('%Y/%m/%d %H:%M:%S'); To get more information about the formats take a look at C of POSIX.pm or the manpage C. =head2 gettime() C returns a POSIX formatted time stamp, @foo in list and $bar in scalar context. If the time format isn't set then the default format "%Y-%m-%d %H:%M:%S" will be set automatically. You can also set a time format with C. my $date_time = $lxs->gettime; Or my ($date, $time) = $lxs->gettime(); Or my ($date, $time) = $lxs->gettime('%Y/%m/%d %H:%M:%S'); =head1 EXAMPLES A very simple perl script could looks like this: use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); sleep(1); my $stat = $lxs->get; my $cpu = $stat->cpustats->{cpu}; print "Statistics for CpuStats (all)\n"; print " user $cpu->{user}\n"; print " nice $cpu->{nice}\n"; print " system $cpu->{system}\n"; print " idle $cpu->{idle}\n"; print " ioWait $cpu->{iowait}\n"; print " total $cpu->{total}\n"; Set and get a time stamp: use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new(); $lxs->settime('%Y/%m/%d %H:%M:%S'); print $lxs->gettime, "\n"; If you want to know how the data structure looks like you can use C to check it: use strict; use warnings; use Sys::Statistics::Linux; use Data::Dumper; my $lxs = Sys::Statistics::Linux->new( cpustats => 1 ); sleep(1); my $stat = $lxs->get; print Dumper($stat); How to get the top 5 processes with the highest cpu workload: use strict; use warnings; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( processes => 1 ); sleep(1); my $stat = $lxs->get; my @top5 = $stat->pstop( ttime => 5 ); =head1 BACKWARD COMPATIBILITY The old options and keys - CpuStats, NetStats, etc - are still available but deprecated! It's not possible to access the statistics via L and it's not possible to call C and C if you use the old options. You should use the new options and access the statistics over the accessors $stats->cpustats or directly with $stats->{cpustats} =head1 PREREQUISITES Carp POSIX Test::More Time::HiRes UNIVERSAL =head1 EXPORTS No exports. =head1 TODOS * Are there any wishs from your side? Send me a mail! =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (C) 2006-2008 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux; our $VERSION = '0.66'; use strict; use warnings; use Carp qw(croak); use POSIX qw(strftime); use UNIVERSAL; use Sys::Statistics::Linux::Compilation; sub new { my $class = shift; my $self = bless { obj => { } }, $class; my @options = qw( SysInfo CpuStats ProcStats MemStats PgSwStats NetStats SockStats DiskStats DiskUsage LoadAVG FileStats Processes ); foreach my $opt (@options) { # backward compatibility $self->{opts}->{$opt} = 0; $self->{maps}->{$opt} = $opt; # new style my $lcopt = lc($opt); $self->{opts}->{$lcopt} = 0; $self->{maps}->{$lcopt} = $opt; } $self->set(@_) if @_; return $self; } sub set { my $self = shift; my $class = ref $self; my $args = ref($_[0]) eq 'HASH' ? shift : {@_}; my $opts = $self->{opts}; my $obj = $self->{obj}; my $maps = $self->{maps}; my $pids = (); foreach my $opt (keys %$args) { if (!exists $opts->{$opt}) { croak "$class: invalid option '$opt'"; } if (ref($args->{$opt})) { $opts->{$opt} = delete $args->{$opt}->{init} || 1; } elsif ($args->{$opt} !~ qr/^[012]\z/) { croak "$class: invalid value for '$opt'"; } else { $opts->{$opt} = $args->{$opt}; } if ($opts->{$opt}) { my $package = $class.'::'.$maps->{$opt}; # require module - require know which modules are loaded # and doesn't load a module twice. my $require = $package; $require =~ s/::/\//g; $require .= '.pm'; require $require; if (!$obj->{$opt}) { if (ref($args->{$opt})) { $obj->{$opt} = $package->new(%{$args->{$opt}}); } else { $obj->{$opt} = $package->new(); } } # get initial statistics if the function init() exists # and the option is set to 1 if ($opts->{$opt} == 1 && UNIVERSAL::can($package, 'init')) { $obj->{$opt}->init(); } } elsif (exists $obj->{$opt}) { delete $obj->{$opt}; } } } sub init { my $self = shift; my $class = ref $self; my $maps = $self->{maps}; foreach my $opt (keys %{$self->{opts}}) { if ($self->{opts}->{$opt} > 0 && UNIVERSAL::can(ref($self->{obj}->{$opt}), 'init')) { $self->{obj}->{$opt}->init(); } } } sub get { my ($self, $time) = @_; sleep $time if $time; my %stat = (); foreach my $opt (keys %{$self->{opts}}) { if ($self->{opts}->{$opt}) { $stat{$opt} = $self->{obj}->{$opt}->get(); if ($opt eq 'netstats') { $stat{netinfo} = $self->{obj}->{$opt}->get_raw(); } } } return Sys::Statistics::Linux::Compilation->new(\%stat); } sub settime { my $self = shift; my $format = @_ ? shift : '%Y-%m-%d %H:%M:%S'; $self->{timeformat} = $format; } sub gettime { my $self = shift; $self->settime(@_) unless $self->{timeformat}; my $tm = strftime($self->{timeformat}, localtime); return wantarray ? split /\s+/, $tm : $tm; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux000750000000000000 011726272174 21330 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/Processes.pm000444000000000000 4031711726272174 24023 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::Processes - Collect linux process statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::Processes; my $lxs = Sys::Statistics::Linux::Processes->new; # or Sys::Statistics::Linux::Processes->new(pids => \@pids) $lxs->init; sleep 1; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::Processes gathers process information from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 PROCESS STATISTICS Generated by FpidE/stat>, FpidE/status>, FpidE/cmdline> and F. Note that if F isn't readable, the key owner is set to F. ppid - The parent process ID of the process. nlwp - The number of light weight processes that runs by this process. owner - The owner name of the process. pgrp - The group ID of the process. state - The status of the process. session - The session ID of the process. ttynr - The tty the process use. minflt - The number of minor faults the process made. cminflt - The number of minor faults the child process made. mayflt - The number of mayor faults the process made. cmayflt - The number of mayor faults the child process made. stime - The number of jiffies the process have beed scheduled in kernel mode. utime - The number of jiffies the process have beed scheduled in user mode. ttime - The number of jiffies the process have beed scheduled (user + kernel). cstime - The number of jiffies the process waited for childrens have been scheduled in kernel mode. cutime - The number of jiffies the process waited for childrens have been scheduled in user mode. prior - The priority of the process (+15). nice - The nice level of the process. sttime - The time in jiffies the process started after system boot. actime - The time in D:H:M:S (days, hours, minutes, seconds) the process is active. vsize - The size of virtual memory of the process. nswap - The size of swap space of the process. cnswap - The size of swap space of the childrens of the process. cpu - The CPU number the process was last executed on. wchan - The "channel" in which the process is waiting. fd - This is a subhash containing each file which the process has open, named by its file descriptor. 0 is standard input, 1 standard output, 2 standard error, etc. Because only the owner or root can read /proc//fd this hash could be empty. cmd - Command of the process. cmdline - Command line of the process. Generated by FpidE/statm>. All statistics provides information about memory in pages: size - The total program size of the process. resident - Number of resident set size, this includes the text, data and stack space. share - Total size of shared pages of the process. trs - Total text size of the process. drs - Total data/stack size of the process. lrs - Total library size of the process. dtp - Total size of dirty pages of the process (unused since kernel 2.6). It's possible to convert pages to bytes or kilobytes. Example - if the pagesize of your system is 4kb: $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 0; # pages (default) $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4; # convert to kilobytes $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4096; # convert to bytes # or with Sys::Statistics::Linux::Processes->new(pages_to_bytes => 4096); Generated by FpidE/io>. rchar - Bytes read from storage (might have been from pagecache). wchar - Bytes written. syscr - Number of read syscalls. syscw - Numner of write syscalls. read_bytes - Bytes really fetched from storage layer. write_bytes - Bytes sent to the storage layer. cancelled_write_bytes - Refer to docs. See Documentation/filesystems/proc.txt for more (from kernel 2.6.20) =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::Processes->new; It's possible to handoff an array reference with a PID list. my $lxs = Sys::Statistics::Linux::Processes->new(pids => [ 1, 2, 3 ]); It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::Processes->new( files => { # This is the default path => '/proc', uptime => 'uptime', stat => 'stat', statm => 'statm', status => 'status', cmdline => 'cmdline', wchan => 'wchan', fd => 'fd', io => 'io', } ); =head2 init() Call C to initialize the statistics. $lxs->init; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; Note: Processes that were created between the call of init() and get() are returned as well, but the keys minflt, cminflt, mayflt, cmayflt, utime, stime, cutime, and cstime are set to the value 0.00 because there are no inititial values to calculate the deltas. =head2 raw() Get raw values. =head1 EXPORTS No exports. =head1 SEE ALSO B B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::Processes; use strict; use warnings; use Time::HiRes; use constant NUMBER => qr/^-{0,1}\d+(?:\.\d+){0,1}\z/; our $VERSION = "0.38"; our $PAGES_TO_BYTES = 0; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', uptime => 'uptime', stat => 'stat', statm => 'statm', status => 'status', cmdline => 'cmdline', wchan => 'wchan', fd => 'fd', io => 'io', }, ); if (defined $opts->{pids}) { if (ref($opts->{pids}) ne 'ARRAY') { die "the PIDs must be passed as a array reference to new()"; } foreach my $pid (@{$opts->{pids}}) { if ($pid !~ /^\d+\z/) { die "PID '$pid' is not a number"; } } $self{pids} = $opts->{pids}; } foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } if ($opts->{pages_to_bytes}) { $self{pages_to_bytes} = $opts->{pages_to_bytes}; } return bless \%self, $class; } sub init { my $self = shift; $self->{init} = $self->_init; } sub get { my $self = shift; if (!exists $self->{init}) { die "there are no initial statistics defined"; } $self->{stats} = $self->_load; $self->_deltas; return $self->{stats}; } sub raw { my $self = shift; my $stat = $self->_load; return $stat; } # # private stuff # sub _init { my $self = shift; my $file = $self->{files}; my $pids = $self->_get_pids; my $stats = { }; $stats->{time} = Time::HiRes::gettimeofday(); foreach my $pid (@$pids) { my $stat = $self->_get_stat($pid); if (defined $stat) { foreach my $key (qw/minflt cminflt mayflt cmayflt utime stime cutime cstime sttime/) { $stats->{$pid}->{$key} = $stat->{$key}; } $stats->{$pid}->{io} = $self->_get_io($pid); } } return $stats; } sub _load { my $self = shift; my $file = $self->{files}; my $uptime = $self->_uptime; my $pids = $self->_get_pids; my $stats = { }; $stats->{time} = Time::HiRes::gettimeofday(); PID: foreach my $pid (@$pids) { foreach my $key (qw/statm stat io owner cmdline wchan fd/) { my $method = "_get_$key"; my $data = $self->$method($pid); if (!defined $data) { delete $stats->{$pid}; next PID; } if ($key eq "statm" || $key eq "stat") { for my $x (keys %$data) { $stats->{$pid}->{$x} = $data->{$x}; } } else { $stats->{$pid}->{$key} = $data; } } } return $stats; } sub _deltas { my $self = shift; my $istat = $self->{init}; my $lstat = $self->{stats}; my $uptime = $self->_uptime; if (!defined $istat->{time} || !defined $lstat->{time}) { die "not defined key found 'time'"; } if ($istat->{time} !~ NUMBER || $lstat->{time} !~ NUMBER) { die "invalid value for key 'time'"; } my $time = $lstat->{time} - $istat->{time}; $istat->{time} = $lstat->{time}; delete $lstat->{time}; for my $pid (keys %{$lstat}) { my $ipid = $istat->{$pid}; my $lpid = $lstat->{$pid}; # yeah, what happends if the start time is different... it seems that a new # process with the same process-id were created... for this reason I have to # check if the start time is equal! if ($ipid && $ipid->{sttime} == $lpid->{sttime}) { for my $k (qw(minflt cminflt mayflt cmayflt utime stime cutime cstime)) { if (!defined $ipid->{$k}) { die "not defined key found '$k'"; } if ($ipid->{$k} !~ NUMBER || $lpid->{$k} !~ NUMBER) { die "invalid value for key '$k'"; } $lpid->{$k} -= $ipid->{$k}; $ipid->{$k} += $lpid->{$k}; if ($lpid->{$k} > 0 && $time > 0) { $lpid->{$k} = sprintf('%.2f', $lpid->{$k} / $time); } else { $lpid->{$k} = sprintf('%.2f', $lpid->{$k}); } } $lpid->{ttime} = sprintf('%.2f', $lpid->{stime} + $lpid->{utime}); for my $k (qw(rchar wchar syscr syscw read_bytes write_bytes cancelled_write_bytes)) { if(defined $ipid->{io}->{$k} && defined $lpid->{io}->{$k}){ if($ipid->{io}->{$k} !~ NUMBER || $lpid->{io}->{$k} !~ NUMBER){ die "invalid value for io key '$k'"; } $lpid->{io}->{$k} -= $ipid->{io}->{$k}; $ipid->{io}->{$k} += $lpid->{io}->{$k}; if ($lpid->{io}->{$k} > 0 && $time > 0) { $lpid->{io}->{$k} = sprintf('%.2f', $lpid->{io}->{$k} / $time); } else { $lpid->{io}->{$k} = sprintf('%.2f', $lpid->{io}->{$k}); } } } } else { # calculate the statistics since process creation for my $k (qw(minflt cminflt mayflt cmayflt utime stime cutime cstime)) { my $p_uptime = $uptime - $lpid->{sttime} / 100; $istat->{$pid}->{$k} = $lpid->{$k}; if ($p_uptime > 0) { $lpid->{$k} = sprintf('%.2f', $lpid->{$k} / $p_uptime); } else { $lpid->{$k} = sprintf('%.2f', $lpid->{$k}); } } for my $k (qw(rchar wchar syscr syscw read_bytes write_bytes cancelled_write_bytes)) { my $p_uptime = $uptime - $lpid->{sttime} / 100; $lpid->{io}->{$k} ||= 0; $istat->{$pid}->{io}->{$k} = $lpid->{io}->{$k}; if ($p_uptime > 0) { $lpid->{io}->{$k} = sprintf('%.2f', $lpid->{io}->{$k} / $p_uptime); } else { $lpid->{io}->{$k} = sprintf('%.2f', $lpid->{io}->{$k}); } } $lpid->{ttime} = sprintf('%.2f', $lpid->{stime} + $lpid->{utime}); $istat->{$pid}->{sttime} = $lpid->{sttime}; } } } sub _get_statm { my ($self, $pid) = @_; my $file = $self->{files}; my %stat = (); open my $fh, '<', "$file->{path}/$pid/$file->{statm}" or return undef; my @line = split /\s+/, <$fh>; if (@line < 7) { return undef; } my $ptb = $self->{pages_to_bytes} || $PAGES_TO_BYTES; if ($ptb) { @stat{qw(size resident share trs lrs drs dtp)} = map { $_ * $ptb } @line; } else { @stat{qw(size resident share trs lrs drs dtp)} = @line; } close($fh); return \%stat; } sub _get_stat { my ($self, $pid) = @_; my $file = $self->{files}; my %stat = (); open my $fh, '<', "$file->{path}/$pid/$file->{stat}" or return undef; my @line = split /\s+/, <$fh>; if (@line < 38) { return undef; } @stat{qw( cmd state ppid pgrp session ttynr minflt cminflt mayflt cmayflt utime stime cutime cstime prior nice nlwp sttime vsize nswap cnswap cpu )} = @line[1..6,9..19,21..22,35..36,38]; my $uptime = $self->_uptime; my ($d, $h, $m, $s) = $self->_calsec(sprintf('%li', $uptime - $stat{sttime} / 100)); $stat{actime} = "$d:".sprintf('%02d:%02d:%02d', $h, $m, $s); close($fh); return \%stat; } sub _get_owner { my ($self, $pid) = @_; my $file = $self->{files}; my $owner = "N/a"; open my $fh, '<', "$file->{path}/$pid/$file->{status}" or return undef; while (my $line = <$fh>) { if ($line =~ /^Uid:(?:\s+|\t+)(\d+)/) { $owner = getpwuid($1) || "N/a"; last; } } close($fh); return $owner; } sub _get_cmdline { my ($self, $pid) = @_; my $file = $self->{files}; open my $fh, '<', "$file->{path}/$pid/$file->{cmdline}" or return undef; my $cmdline = <$fh>; close $fh; if (!defined $cmdline) { $cmdline = "N/a"; } $cmdline =~ s/\0/ /g; $cmdline =~ s/^\s+//; $cmdline =~ s/\s+$//; chomp $cmdline; return $cmdline; } sub _get_wchan { my ($self, $pid) = @_; my $file = $self->{files}; open my $fh, '<', "$file->{path}/$pid/$file->{wchan}" or return undef; my $wchan = <$fh>; close $fh; if (!defined $wchan) { $wchan = defined; } chomp $wchan; return $wchan; } sub _get_io { my ($self, $pid) = @_; my $file = $self->{files}; my %stat = (); if (open my $fh, '<', "$file->{path}/$pid/$file->{io}") { while (my $line = <$fh>) { if ($line =~ /^([a-z_]+):\s+(\d+)/) { $stat{$1} = $2; } } close($fh); } return \%stat; } sub _get_fd { my ($self, $pid) = @_; my $file = $self->{files}; my %stat = (); if (opendir my $dh, "$file->{path}/$pid/$file->{fd}") { foreach my $link (grep !/^\.+\z/, readdir($dh)) { if (my $target = readlink("$file->{path}/$pid/$file->{fd}/$link")) { $stat{$pid}{fd}{$link} = $target; } } } return \%stat; } sub _get_pids { my $self = shift; my $file = $self->{files}; if ($self->{pids}) { return $self->{pids}; } opendir my $dh, $file->{path} or die "unable to open directory $file->{path} ($!)"; my @pids = grep /^\d+\z/, readdir $dh; closedir $dh; return \@pids; } sub _uptime { my $self = shift; my $file = $self->{files}; my $filename = $file->{path} ? "$file->{path}/$file->{uptime}" : $file->{uptime}; open my $fh, '<', $filename or die "unable to open $filename ($!)"; my ($up, $idle) = split /\s+/, <$fh>; close($fh); return $up; } sub _calsec { my $self = shift; my ($s, $m, $h, $d) = (shift, 0, 0, 0); $s >= 86400 and $d = sprintf('%i', $s / 86400) and $s = $s % 86400; $s >= 3600 and $h = sprintf('%i', $s / 3600) and $s = $s % 3600; $s >= 60 and $m = sprintf('%i', $s / 60) and $s = $s % 60; return ($d, $h, $m, $s); } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/FileStats.pm000444000000000000 1005011726272174 23742 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::FileStats - Collect linux file statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::FileStats; my $lxs = Sys::Statistics::Linux::FileStats->new; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::FileStats gathers file statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 FILE STATISTICS Generated by F, F and F. fhalloc - Number of allocated file handles. fhfree - Number of free file handles. fhmax - Number of maximum file handles. inalloc - Number of allocated inodes. infree - Number of free inodes. inmax - Number of maximum inodes. dentries - Dirty directory cache entries. unused - Free diretory cache size. agelimit - Time in seconds the dirty cache entries can be reclaimed. wantpages - Pages that are requested by the system when memory is short. =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::FileStats->new; It's possible to set the path to the proc filesystem. Sys::Statistics::Linux::FileStats->new( files => { # This is the default path => '/proc', file_nr => 'sys/fs/file-nr', inode_nr => 'sys/fs/inode-nr', dentries => 'sys/fs/dentry-state', } ); =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::FileStats; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.09'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', file_nr => 'sys/fs/file-nr', inode_nr => 'sys/fs/inode-nr', dentries => 'sys/fs/dentry-state', } ); foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub get { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $stats = { }; $self->{stats} = $stats; $self->_get_file_nr; $self->_get_inode_nr; $self->_get_dentries; return $stats; } sub _get_file_nr { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $stats = $self->{stats}; my $filename = $file->{path} ? "$file->{path}/$file->{file_nr}" : $file->{file_nr}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; @$stats{qw(fhalloc fhfree fhmax)} = (split /\s+/, <$fh>)[0..2]; close($fh); } sub _get_inode_nr { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $stats = $self->{stats}; my $filename = $file->{path} ? "$file->{path}/$file->{inode_nr}" : $file->{inode_nr}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; @$stats{qw(inalloc infree)} = (split /\s+/, <$fh>)[0..1]; $stats->{inmax} = $stats->{inalloc} + $stats->{infree}; close($fh); } sub _get_dentries { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $stats = $self->{stats}; my $filename = $file->{path} ? "$file->{path}/$file->{dentries}" : $file->{dentries}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; @$stats{qw(dentries unused agelimit wantpages)} = (split /\s+/, <$fh>)[0..3]; close($fh); } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/LoadAVG.pm000444000000000000 466711726272174 23262 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::LoadAVG - Collect linux load average statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::LoadAVG; my $lxs = Sys::Statistics::Linux::LoadAVG->new; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::LoadAVG gathers the load average from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 LOAD AVERAGE STATISTICS Generated by F. avg_1 - The average processor workload of the last minute. avg_5 - The average processor workload of the last five minutes. avg_15 - The average processor workload of the last fifteen minutes. =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::LoadAVG->new; It's possible to set the path to the proc filesystem. Sys::Statistics::Linux::LoadAVG->new( files => { # This is the default path => '/proc', loadavg => 'loadavg', } ); =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::LoadAVG; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.08'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', loadavg => 'loadavg', } ); foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub get { my $self = shift; my $class = ref $self; my $file = $self->{files}; my %lavg = (); my $filename = $file->{path} ? "$file->{path}/$file->{loadavg}" : $file->{loadavg}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; ( $lavg{avg_1} , $lavg{avg_5} , $lavg{avg_15} ) = (split /\s+/, <$fh>)[0..2]; close($fh); return \%lavg; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/Compilation.pm000444000000000000 2473211726272174 24336 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::Compilation - Statistics compilation. =head1 SYNOPSIS use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new( loadavg => 1 ); my $stat = $lxs->get; foreach my $key ($stat->loadavg) { print $key, " ", $stat->loadavg($key), "\n"; } # or use Sys::Statistics::Linux::LoadAVG; use Sys::Statistics::Linux::Compilation; my $lxs = Sys::Statistics::Linux::LoadAVG->new(); my $load = $lxs->get; my $stat = Sys::Statistics::Linux::Compilation->new({ loadavg => $load }); foreach my $key ($stat->loadavg) { print $key, " ", $stat->loadavg($key), "\n"; } # or foreach my $key ($stat->loadavg) { print $key, " ", $stat->loadavg->{$key}, "\n"; } =head1 DESCRIPTION This module provides different methods to access and filter the statistics compilation. =head1 METHODS =head2 new() Create a new C object. This creator is only useful if you don't call C of C. You can create a new object with: my $lxs = Sys::Statistics::Linux::LoadAVG->new(); my $load = $lxs->get; my $stat = Sys::Statistics::Linux::Compilation->new({ loadavg => $load }); =head2 Statistic methods =over 4 =item sysinfo() =item cpustats() =item procstats() =item memstats() =item pgswstats() =item netstats() =item netinfo() C provides raw data - no deltas. =item sockstats() =item diskstats() =item diskusage() =item loadavg() =item filestats() =item processes() =back All methods returns the statistics as a hash reference in scalar context. In list all methods returns the first level keys of the statistics. Example: my $net = $stat->netstats; # netstats as a hash reference my @dev = $stat->netstats; # the devices eth0, eth1, ... my $eth0 = $stat->netstats('eth0'); # eth0 statistics as a hash reference my @keys = $stat->netstats('eth0'); # the statistic keys my @vals = $stat->netstats('eth0', @keys); # the values for the passed device and @keys my $val = $stat->netstats('eth0', $key); # the value for the passed device and key Sorted ... my @dev = sort $stat->netstats; my @keys = sort $stat->netstats('eth0'); =head2 pstop() This method is looking for top processes and returns a sorted list of PIDs as an array or array reference depending on the context. It expected two values: a key name and the number of top processes to return. As example you want to get the top 5 processes with the highest cpu usage: my @top5 = $stat->pstop( ttime => 5 ); # or as a reference my $top5 = $stat->pstop( ttime => 5 ); If you want to get all processes: my @top_all = $stat->pstop( ttime => $FALSE ); # or just my @top_all = $stat->pstop( 'ttime' ); =head2 search(), psfind() Both methods provides a simple scan engine to find special statistics. Both methods except a filter as a hash reference. It's possible to pass the statistics as second argument if the data is not stored in the object. The method C scans for statistics and rebuilds the hash tree until that keys that matched your filter and returns the hits as a hash reference. my $hits = $stat->search({ processes => { cmd => qr/\[su\]/, owner => qr/root/ }, cpustats => { idle => 'lt:10', iowait => 'gt:10' }, diskusage => { '/dev/sda1' => { usageper => 'gt:80' } } }); This would return the following matches: * processes with the command "[su]" * processes with the owner "root" * all cpu where "idle" is less than 50 * all cpu where "iowait" is grather than 10 * only disk '/dev/sda1' if "usageper" is grather than 80 The method C scans for processes only and returns a array reference with all process IDs that matched the filter. Example: my $pids = $stat->psfind({ cmd => qr/init/, owner => 'eq:apache' }); This would return the following process ids: * processes that matched the command "init" * processes with the owner "apache" There are different match operators available: gt - grather than lt - less than eq - is equal ne - is not equal Notation examples: gt:50 lt:50 eq:50 ne:50 Both argumnents have to be set as a hash reference. Note: the operators < > = ! are not available any more. It's possible that in further releases could be different changes for C and C. So please take a look to the documentation if you use it. =head1 EXPORTS No exports. =head1 TODOS * Are there any wishs from your side? Send me a mail! =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . Thanks to Moritz Lenz for his suggestion for the name of this module. =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::Compilation; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.10'; # Creating the statistics accessors BEGIN { foreach my $stat (qw/sysinfo procstats memstats sockstats loadavg filestats/) { no strict 'refs'; *{$stat} = sub { use strict 'refs'; my ($self, @keys) = @_; return () unless $self->{$stat}; if (@keys) { return @{$self->{$stat}}{@keys}; } return wantarray ? keys %{$self->{$stat}} : $self->{$stat}; }; } foreach my $stat (qw/cpustats pgswstats netstats netinfo diskstats diskusage processes/) { no strict 'refs'; *{$stat} = sub { use strict 'refs'; my ($self, $sub, @keys) = @_; return () unless $self->{$stat}; if ($sub) { my $ref = $self->{$stat}; return () unless exists $ref->{$sub}; if (@keys) { return @{$ref->{$sub}}{@keys}; } else { return wantarray ? keys %{$ref->{$sub}} : $ref->{$sub}; } } return wantarray ? keys %{$self->{$stat}} : $self->{$stat}; }; } } sub new { my ($class, $stats) = @_; unless (ref($stats) eq 'HASH') { croak 'Usage: $class->new( \%statistics )'; } return bless $stats, $class; } sub search { my $self = shift; my $filter = ref($_[0]) eq 'HASH' ? shift : {@_}; my $class = ref($self); my %hits = (); foreach my $opt (keys %{$filter}) { unless (ref($filter->{$opt}) eq 'HASH') { croak "$class: not a hash ref opt '$opt'"; } # next if the object isn't loaded next unless exists $self->{$opt}; my $fref = $filter->{$opt}; my $proc = $self->{$opt}; my $subref; # we search for matches for each key that is defined # in %filter and rebuild the tree until that key that # matched the searched string foreach my $x (keys %{$fref}) { if (ref($fref->{$x}) eq 'HASH') { # if the key $proc->{eth0} doesn't exists # then we continue with the next defined filter next unless exists $proc->{$x}; $subref = $proc->{$x}; while ( my ($name, $value) = each %{$fref->{$x}} ) { if (exists $subref->{$name} && $self->_compare($subref->{$name}, $value)) { $hits{$opt}{$x}{$name} = $subref->{$name}; } } } else { foreach my $key (keys %{$proc}) { if (ref($proc->{$key}) eq 'HASH') { $subref = $proc->{$key}; if (ref $subref->{$x} eq 'HASH') { foreach my $y (keys %{$subref->{$x}}) { if ($self->_compare($subref->{$x}->{$y}, $fref->{$x})) { $hits{$opt}{$key}{$x}{$y} = $subref->{$x}->{$y}; } } } elsif (defined $subref->{$x} && $self->_compare($subref->{$x}, $fref->{$x})) { $hits{$opt}{$key}{$x} = $subref->{$x}; } } else { # must be a scalar now if (defined $proc->{$x} && $self->_compare($proc->{$x}, $fref->{$x})) { $hits{$opt}{$x} = $proc->{$x} } last; } } } } } return wantarray ? %hits : \%hits; } sub psfind { my $self = shift; my $filter = ref($_[0]) eq 'HASH' ? shift : {@_}; my $proc = $self->{processes} or return undef; my @hits = (); PID: foreach my $pid (keys %{$proc}) { my $proc = $proc->{$pid}; while ( my ($key, $value) = each %{$filter} ) { if (exists $proc->{$key}) { if (ref $proc->{$key} eq 'HASH') { foreach my $v (values %{$proc->{$key}}) { if ($self->_compare($v, $value)) { push @hits, $pid; next PID; } } } elsif ($self->_compare($proc->{$key}, $value)) { push @hits, $pid; next PID; } } } } return wantarray ? @hits : \@hits; } sub pstop { my ($self, $key, $count) = @_; unless ($key) { croak 'Usage: pstop( $key => $count )'; } my $proc = $self->{processes}; my @top = ( map { $_->[0] } reverse sort { $a->[1] <=> $b->[1] } map { [ $_, $proc->{$_}->{$key} ] } keys %{$proc} ); if ($count) { @top = @top[0..--$count]; } return wantarray ? @top : \@top; } # # private stuff # sub _compare { my ($self, $x, $y) = @_; if (ref($y) eq 'Regexp') { return $x =~ $y; } elsif ($y =~ s/^eq://) { return $x eq $y; } elsif ($y =~ s/^ne://) { return $x ne $y; } elsif ($y =~ s/^gt://) { return $x > $y; } elsif ($y =~ s/^lt://) { return $x < $y; } else { croak ref($self).": bad search() / psfind() operator '$y'"; } return undef; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/SockStats.pm000444000000000000 552011726272174 23750 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::SockStats - Collect linux socket statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::SockStats; my $lxs = Sys::Statistics::Linux::SockStats->new; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::SockStats gathers socket statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 SOCKET STATISTICS Generated by F. used - Total number of used sockets. tcp - Number of tcp sockets in use. udp - Number of udp sockets in use. raw - Number of raw sockets in use. ipfrag - Number of ip fragments in use (only available by kernels > 2.2). =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::SockStats->new; It's possible to set the path to the proc filesystem. Sys::Statistics::Linux::SockStats->new( files => { # This is the default path => '/proc', sockstat => 'net/sockstat', } ); =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::SockStats; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.09'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', sockstat => 'net/sockstat', } ); foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub get { my $self = shift; my $class = ref $self; my $file = $self->{files}; my %socks = (); my $filename = $file->{path} ? "$file->{path}/$file->{sockstat}" : $file->{sockstat}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { if ($line =~ /sockets: used (\d+)/) { $socks{used} = $1; } elsif ($line =~ /TCP: inuse (\d+)/) { $socks{tcp} = $1; } elsif ($line =~ /UDP: inuse (\d+)/) { $socks{udp} = $1; } elsif ($line =~ /RAW: inuse (\d+)/) { $socks{raw} = $1; } elsif ($line =~ /FRAG: inuse (\d+)/) { $socks{ipfrag} = $1; } } close($fh); return \%socks; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/ProcStats.pm000444000000000000 1317611726272174 24002 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::ProcStats - Collect linux process statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::ProcStats; my $lxs = Sys::Statistics::Linux::ProcStats->new; $lxs->init; sleep 1; my $stat = $lxs->get; Or my $lxs = Sys::Statistics::Linux::ProcStats->new(initfile => $file); $lxs->init; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::ProcStats gathers process statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 IMPORTANT I renamed key C to C! =head1 LOAD AVERAGE STATISTICS Generated by F and F. new - Number of new processes that were produced per second. runqueue - The number of currently executing kernel scheduling entities (processes, threads). count - The number of kernel scheduling entities that currently exist on the system (processes, threads). blocked - Number of processes blocked waiting for I/O to complete (Linux 2.5.45 onwards). running - Number of processes in runnable state (Linux 2.5.45 onwards). =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::ProcStats->new; Maybe you want to store/load the initial statistics to/from a file: my $lxs = Sys::Statistics::Linux::ProcStats->new(initfile => '/tmp/procstats.yml'); If you set C it's not necessary to call sleep before C. It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::ProcStats->new( files => { # This is the default path => '/proc', loadavg => 'loadavg', stat => 'stat', } ); =head2 init() Call C to initialize the statistics. $lxs->init; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head2 raw() Get raw values. =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::ProcStats; use strict; use warnings; use Carp qw(croak); use Time::HiRes; our $VERSION = '0.20'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', loadavg => 'loadavg', stat => 'stat', } ); if (defined $opts->{initfile}) { require YAML::Syck; $self{initfile} = $opts->{initfile}; } foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub init { my $self = shift; if ($self->{initfile} && -r $self->{initfile}) { $self->{init} = YAML::Syck::LoadFile($self->{initfile}); $self->{time} = delete $self->{init}->{time}; } else { $self->{time} = Time::HiRes::gettimeofday(); $self->{init} = $self->_load; } } sub get { my $self = shift; my $class = ref $self; if (!exists $self->{init}) { croak "$class: there are no initial statistics defined"; } $self->{stats} = $self->_load; $self->_deltas; if ($self->{initfile}) { $self->{init}->{time} = $self->{time}; YAML::Syck::DumpFile($self->{initfile}, $self->{init}); } return $self->{stats}; } sub raw { my $self = shift; my $stat = $self->_load; return $stat; } # # private stuff # sub _load { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $lavg = $self->_procs; my $filename = $file->{path} ? "$file->{path}/$file->{loadavg}" : $file->{loadavg}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; ($lavg->{runqueue}, $lavg->{count}) = (split m@/@, (split /\s+/, <$fh>)[3]); close($fh); return $lavg; } sub _procs { my $self = shift; my $class = ref $self; my $file = $self->{files}; my %stat = (); my $filename = $file->{path} ? "$file->{path}/$file->{stat}" : $file->{stat}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { if ($line =~ /^processes\s+(\d+)/) { $stat{new} = $1; } elsif ($line =~ /^procs_(blocked|running)\s+(\d+)/) { $stat{$1} = $2; } } close($fh); return \%stat; } sub _deltas { my $self = shift; my $class = ref $self; my $istat = $self->{init}; my $lstat = $self->{stats}; my $time = Time::HiRes::gettimeofday(); my $delta = sprintf('%.2f', $time - $self->{time}); $self->{time} = $time; if (!defined $istat->{new} || !defined $lstat->{new}) { croak "$class: not defined key found 'new'"; } if ($istat->{new} !~ /^\d+\z/ || $lstat->{new} !~ /^\d+\z/) { croak "$class: invalid value for key 'new'"; } my $new_init = $lstat->{new}; if ($lstat->{new} == $istat->{new} || $istat->{new} > $lstat->{new}) { $lstat->{new} = sprintf('%.2f', 0); } elsif ($delta > 0) { $lstat->{new} = sprintf('%.2f', ($new_init - $istat->{new}) / $delta ); } else { $lstat->{new} = sprintf('%.2f', $new_init - $istat->{new}); } $istat->{new} = $new_init; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/PgSwStats.pm000444000000000000 1362511726272174 23756 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::PgSwStats - Collect linux paging and swapping statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::PgSwStats; my $lxs = Sys::Statistics::Linux::PgSwStats->new; $lxs->init; sleep 1; my $stat = $lxs->get; Or my $lxs = Sys::Statistics::Linux::PgSwStats->new(initfile => $file); $lxs->init; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::PgSwStats gathers paging and swapping statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 PAGING AND SWAPPING STATISTICS Generated by F or F. pgpgin - Number of pages the system has paged in from disk per second. pgpgout - Number of pages the system has paged out to disk per second. pswpin - Number of pages the system has swapped in from disk per second. pswpout - Number of pages the system has swapped out to disk per second. The following statistics are only available by kernels from 2.6. pgfault - Number of page faults the system has made per second (minor + major). pgmajfault - Number of major faults per second the system required loading a memory page from disk. =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::PgSwStats->new; Maybe you want to store/load the initial statistics to/from a file: my $lxs = Sys::Statistics::Linux::PgSwStats->new(initfile => '/tmp/pgswstats.yml'); If you set C it's not necessary to call sleep before C. It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::PgSwStats->new( files => { # This is the default path => '/proc', stat => 'stat', vmstat => 'vmstat', } ); =head2 init() Call C to initialize the statistics. $lxs->init; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head2 raw() Get raw values. =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::PgSwStats; use strict; use warnings; use Carp qw(croak); use Time::HiRes; our $VERSION = '0.18'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', stat => 'stat', vmstat => 'vmstat', } ); if (defined $opts->{initfile}) { require YAML::Syck; $self{initfile} = $opts->{initfile}; } foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub init { my $self = shift; if ($self->{initfile} && -r $self->{initfile}) { $self->{init} = YAML::Syck::LoadFile($self->{initfile}); $self->{time} = delete $self->{init}->{time}; } else { $self->{time} = Time::HiRes::gettimeofday(); $self->{init} = $self->_load; } } sub get { my $self = shift; my $class = ref $self; if (!exists $self->{init}) { croak "$class: there are no initial statistics defined"; } $self->{stats} = $self->_load; $self->_deltas; if ($self->{initfile}) { $self->{init}->{time} = $self->{time}; YAML::Syck::DumpFile($self->{initfile}, $self->{init}); } return $self->{stats}; } sub raw { my $self = shift; my $stat = $self->_load; return $stat; } # # private stuff # sub _load { my $self = shift; my $class = ref $self; my $file = $self->{files}; my %stats = (); my $filename = $file->{path} ? "$file->{path}/$file->{stat}" : $file->{stat}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { if ($line =~ /^page\s+(\d+)\s+(\d+)$/) { @stats{qw(pgpgin pgpgout)} = ($1, $2); } elsif ($line =~ /^swap\s+(\d+)\s+(\d+)$/) { @stats{qw(pswpin pswpout)} = ($1, $2); } } close($fh); # if paging and swapping are not found in /proc/stat # then let's try a look into /proc/vmstat (since 2.6) if (!defined $stats{pswpout}) { my $filename = $file->{path} ? "$file->{path}/$file->{vmstat}" : $file->{vmstat}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { next unless $line =~ /^(pgpgin|pgpgout|pswpin|pswpout|pgfault|pgmajfault)\s+(\d+)/; $stats{$1} = $2; } close($fh); } return \%stats; } sub _deltas { my $self = shift; my $class = ref $self; my $istat = $self->{init}; my $lstat = $self->{stats}; my $time = Time::HiRes::gettimeofday(); my $delta = sprintf('%.2f', $time - $self->{time}); $self->{time} = $time; while (my ($k, $v) = each %{$lstat}) { if (!defined $istat->{$k} || !defined $lstat->{$k}) { croak "$class: not defined key found '$k'"; } if ($v !~ /^\d+\z/ || $istat->{$k} !~ /^\d+\z/) { croak "$class: invalid value for key '$k'"; } if ($lstat->{$k} == $istat->{$k} || $istat->{$k} > $lstat->{$k}) { $lstat->{$k} = sprintf('%.2f', 0); } elsif ($delta > 0) { $lstat->{$k} = sprintf('%.2f', ($lstat->{$k} - $istat->{$k}) / $delta); } else { $lstat->{$k} = sprintf('%.2f', $lstat->{$k} - $istat->{$k}); } $istat->{$k} = $v; } } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/DiskStats.pm000444000000000000 3003511726272174 23762 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::DiskStats - Collect linux disk statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::DiskStats; my $lxs = Sys::Statistics::Linux::DiskStats->new; $lxs->init; sleep 1; my $stat = $lxs->get; Or my $lxs = Sys::Statistics::Linux::DiskStats->new(initfile => $file); $lxs->init; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::DiskStats gathers disk statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 DISK STATISTICS Generated by F or F. major - The mayor number of the disk minor - The minor number of the disk rdreq - Number of read requests that were made to physical disk per second. rdbyt - Number of bytes that were read from physical disk per second. wrtreq - Number of write requests that were made to physical disk per second. wrtbyt - Number of bytes that were written to physical disk per second. ttreq - Total number of requests were made from/to physical disk per second. ttbyt - Total number of bytes transmitted from/to physical disk per second. =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::DiskStats->new; Maybe you want to store/load the initial statistics to/from a file: my $lxs = Sys::Statistics::Linux::DiskStats->new(initfile => '/tmp/diskstats.yml'); If you set C it's not necessary to call sleep before C. It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::DiskStats->new( files => { # This is the default path => '/proc', diskstats => 'diskstats', partitions => 'partitions', } ); =head2 init() Call C to initialize the statistics. $lxs->init; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head2 raw() Get raw values. =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::DiskStats; use strict; use warnings; use Carp qw(croak); use Time::HiRes; our $VERSION = '0.24'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', diskstats => 'diskstats', partitions => 'partitions', }, # -------------------------------------------------------------- # The sectors are equivalent with blocks and have a size of 512 # bytes since 2.4 kernels. This value is needed to calculate the # amount of disk i/o's in bytes. # -------------------------------------------------------------- blocksize => 512, ); if (defined $opts->{initfile}) { require YAML::Syck; $self{initfile} = $opts->{initfile}; } foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } if ($opts->{blocksize}) { $self{blocksize} = $opts->{blocksize}; } return bless \%self, $class; } sub init { my $self = shift; if ($self->{initfile} && -r $self->{initfile}) { $self->{init} = YAML::Syck::LoadFile($self->{initfile}); $self->{time} = delete $self->{init}->{time}; } else { $self->{time} = Time::HiRes::gettimeofday(); $self->{init} = $self->_load; } } sub get { my $self = shift; my $class = ref $self; if (!exists $self->{init}) { croak "$class: there are no initial statistics defined"; } $self->{stats} = $self->_load; $self->_deltas; if ($self->{initfile}) { $self->{init}->{time} = $self->{time}; YAML::Syck::DumpFile($self->{initfile}, $self->{init}); } return $self->{stats}; } sub raw { my $self = shift; my $raw = $self->_load; return $raw; } # # private stuff # sub _load { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $bksz = $self->{blocksize}; my (%stats, $fh); # ----------------------------------------------------------------------------- # one of the both must be opened for the disk statistics! # if diskstats (2.6) doesn't exists then let's try to read # the partitions (2.4) # # /usr/src/linux/Documentation/iostat.txt shortcut # # ... the statistics fields are those after the device name. # # Field 1 -- # of reads issued # This is the total number of reads completed successfully. # Field 2 -- # of reads merged, field 6 -- # of writes merged # Reads and writes which are adjacent to each other may be merged for # efficiency. Thus two 4K reads may become one 8K read before it is # ultimately handed to the disk, and so it will be counted (and queued) # as only one I/O. This field lets you know how often this was done. # Field 3 -- # of sectors read # This is the total number of sectors read successfully. # Field 4 -- # of milliseconds spent reading # This is the total number of milliseconds spent by all reads (as # measured from __make_request() to end_that_request_last()). # Field 5 -- # of writes completed # This is the total number of writes completed successfully. # Field 7 -- # of sectors written # This is the total number of sectors written successfully. # Field 8 -- # of milliseconds spent writing # This is the total number of milliseconds spent by all writes (as # measured from __make_request() to end_that_request_last()). # Field 9 -- # of I/Os currently in progress # The only field that should go to zero. Incremented as requests are # given to appropriate request_queue_t and decremented as they finish. # Field 10 -- # of milliseconds spent doing I/Os # This field is increases so long as field 9 is nonzero. # Field 11 -- weighted # of milliseconds spent doing I/Os # This field is incremented at each I/O start, I/O completion, I/O # merge, or read of these stats by the number of I/Os in progress # (field 9) times the number of milliseconds spent doing I/O since the # last update of this field. This can provide an easy measure of both # I/O completion time and the backlog that may be accumulating. # ----------------------------------------------------------------------------- my $file_diskstats = $file->{path} ? "$file->{path}/$file->{diskstats}" : $file->{diskstats}; my $file_partitions = $file->{path} ? "$file->{path}/$file->{partitions}" : $file->{partitions}; if (open $fh, '<', $file_diskstats) { while (my $line = <$fh>) { # -- -- -- F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 # $1 $2 $3 $4 -- $5 -- $6 -- $7 -- -- -- -- if ($line =~ /^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+$/) { for my $x ($stats{$3}) { # $3 -> the device name $x->{major} = $1; $x->{minor} = $2; $x->{rdreq} = $4; # Field 1 $x->{rdbyt} = $5 * $bksz; # Field 3 $x->{wrtreq} = $6; # Field 5 $x->{wrtbyt} = $7 * $bksz; # Field 7 $x->{ttreq} += $x->{rdreq} + $x->{wrtreq}; $x->{ttbyt} += $x->{rdbyt} + $x->{wrtbyt}; } } # ----------------------------------------------------------------------------- # Field 1 -- # of reads issued # This is the total number of reads issued to this partition. # Field 2 -- # of sectors read # This is the total number of sectors requested to be read from this # partition. # Field 3 -- # of writes issued # This is the total number of writes issued to this partition. # Field 4 -- # of sectors written # This is the total number of sectors requested to be written to # this partition. # ----------------------------------------------------------------------------- # -- -- -- F1 F2 F3 F4 # $1 $2 $3 $4 $5 $6 $7 elsif ($line =~ /^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) { for my $x ($stats{$3}) { # $3 -> the device name $x->{major} = $1; $x->{minor} = $2; $x->{rdreq} = $4; # Field 1 $x->{rdbyt} = $5 * $bksz; # Field 2 $x->{wrtreq} = $6; # Field 3 $x->{wrtbyt} = $7 * $bksz; # Field 4 $x->{ttreq} += $x->{rdreq} + $x->{wrtreq}; $x->{ttbyt} += $x->{rdbyt} + $x->{wrtbyt}; } } } close($fh); } elsif (open $fh, '<', $file_partitions) { while (my $line = <$fh>) { # -- -- -- -- F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 # $1 $2 -- $3 $4 -- $5 -- $6 -- $7 -- -- -- -- next unless $line =~ /^\s+(\d+)\s+(\d+)\s+\d+\s+(.+?)\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+$/; for my $x ($stats{$3}) { # $3 -> the device name $x->{major} = $1; $x->{minor} = $2; $x->{rdreq} = $4; # Field 1 $x->{rdbyt} = $5 * $bksz; # Field 3 $x->{wrtreq} = $6; # Field 5 $x->{wrtbyt} = $7 * $bksz; # Field 7 $x->{ttreq} += $x->{rdreq} + $x->{wrtreq}; $x->{ttbyt} += $x->{rdbyt} + $x->{wrtbyt}; } } close($fh); } else { croak "$class: unable to open $file_diskstats or $file_partitions ($!)"; } if (!-e $file_diskstats || !scalar %stats) { croak "$class: no diskstats found! your system seems not to be compiled with CONFIG_BLK_STATS=y"; } return \%stats; } sub _deltas { my $self = shift; my $class = ref $self; my $istat = $self->{init}; my $lstat = $self->{stats}; my $time = Time::HiRes::gettimeofday(); my $delta = sprintf('%.2f', $time - $self->{time}); $self->{time} = $time; foreach my $dev (keys %{$lstat}) { if (!exists $istat->{$dev}) { delete $lstat->{$dev}; next; } my $idev = $istat->{$dev}; my $ldev = $lstat->{$dev}; while (my ($k, $v) = each %{$ldev}) { next if $k =~ /^major\z|^minor\z/; if (!defined $idev->{$k}) { croak "$class: not defined key found '$k'"; } if ($v !~ /^\d+\z/ || $ldev->{$k} !~ /^\d+\z/) { croak "$class: invalid value for key '$k'"; } if ($ldev->{$k} == $idev->{$k} || $idev->{$k} > $ldev->{$k}) { $ldev->{$k} = sprintf('%.2f', 0); } elsif ($delta > 0) { $ldev->{$k} = sprintf('%.2f', ($ldev->{$k} - $idev->{$k}) / $delta); } else { $ldev->{$k} = sprintf('%.2f', $ldev->{$k} - $idev->{$k}); } $idev->{$k} = $v; } } } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/MemStats.pm000444000000000000 1424111726272174 23607 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::MemStats - Collect linux memory information. =head1 SYNOPSIS use Sys::Statistics::Linux::MemStats; my $lxs = Sys::Statistics::Linux::MemStats->new; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::MemStats gathers memory statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 MEMORY INFORMATIONS Generated by F. memused - Total size of used memory in kilobytes. memfree - Total size of free memory in kilobytes. memusedper - Total size of used memory in percent. memtotal - Total size of memory in kilobytes. buffers - Total size of buffers used from memory in kilobytes. cached - Total size of cached memory in kilobytes. realfree - Total size of memory is real free (memfree + buffers + cached). realfreeper - Total size of memory is real free in percent of total memory. swapused - Total size of swap space is used is kilobytes. swapfree - Total size of swap space is free in kilobytes. swapusedper - Total size of swap space is used in percent. swaptotal - Total size of swap space in kilobytes. swapcached - Memory that once was swapped out, is swapped back in but still also is in the swapfile. active - Memory that has been used more recently and usually not reclaimed unless absolutely necessary. inactive - Memory which has been less recently used and is more eligible to be reclaimed for other purposes. On earlier kernels (2.4) Inact_dirty + Inact_laundry + Inact_clean. The following statistics are only available by kernels from 2.6. slab - Total size of memory in kilobytes that used by kernel for data structure allocations. dirty - Total size of memory pages in kilobytes that waits to be written back to disk. mapped - Total size of memory in kilbytes that is mapped by devices or libraries with mmap. writeback - Total size of memory that was written back to disk. committed_as - The amount of memory presently allocated on the system. The following statistic is only available by kernels from 2.6.9. commitlimit - Total amount of memory currently available to be allocated on the system. =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::MemStats->new; It's possible to set the path to the proc filesystem. Sys::Statistics::Linux::MemStats->new( files => { # This is the default path => '/proc', meminfo => 'meminfo', } ); =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::MemStats; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.16'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', meminfo => 'meminfo', } ); foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub get { my $self = shift; my $class = ref($self); my $file = $self->{files}; my %meminfo = (); my $filename = $file->{path} ? "$file->{path}/$file->{meminfo}" : $file->{meminfo}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; # MemTotal: 1035648 kB # MemFree: 15220 kB # Buffers: 4280 kB # Cached: 47664 kB # SwapCached: 473988 kB # Active: 661992 kB # Inactive: 314312 kB # HighTotal: 130884 kB # HighFree: 264 kB # LowTotal: 904764 kB # LowFree: 14956 kB # SwapTotal: 1951856 kB # SwapFree: 1164864 kB # Dirty: 520 kB # Writeback: 0 kB # AnonPages: 908892 kB # Mapped: 34308 kB # Slab: 19284 kB # SReclaimable: 7532 kB # SUnreclaim: 11752 kB # PageTables: 3056 kB # NFS_Unstable: 0 kB # Bounce: 0 kB # CommitLimit: 2469680 kB # Committed_AS: 1699568 kB # VmallocTotal: 114680 kB # VmallocUsed: 12284 kB # VmallocChunk: 100992 kB # kernel <= 2.4 # Inact_dirty: 138632 kB # Inact_laundry: 35520 kB # Inact_clean: 7544 kB while (my $line = <$fh>) { if ($line =~ /^((?:Mem|Swap)(?:Total|Free)|Buffers|Cached|SwapCached|Active|Inactive| Dirty|Writeback|Mapped|Slab|Commit(?:Limit|ted_AS)):\s*(\d+)/x) { my ($n, $v) = ($1, $2); $n =~ tr/A-Z/a-z/; $meminfo{$n} = $v; } elsif ($line =~ /^Inact_(?:dirty|laundry|clean):\s*(\d+)/) { $meminfo{inactive} += $1; } } close($fh); $meminfo{memused} = sprintf('%u', $meminfo{memtotal} - $meminfo{memfree}); $meminfo{memusedper} = sprintf('%.2f', 100 * $meminfo{memused} / $meminfo{memtotal}); $meminfo{swapused} = sprintf('%u', $meminfo{swaptotal} - $meminfo{swapfree}); $meminfo{realfree} = sprintf('%u', $meminfo{memfree} + $meminfo{buffers} + $meminfo{cached}); $meminfo{realfreeper} = sprintf('%.2f', 100 * $meminfo{realfree} / $meminfo{memtotal}); # maybe there is no swap space on the machine if (!$meminfo{swaptotal}) { $meminfo{swapusedper} = '0.00'; } else { $meminfo{swapusedper} = sprintf('%.2f', 100 * $meminfo{swapused} / $meminfo{swaptotal}); } return \%meminfo; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/CpuStats.pm000444000000000000 1360411726272174 23622 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::CpuStats - Collect linux cpu statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::CpuStats; my $lxs = Sys::Statistics::Linux::CpuStats->new; $lxs->init; sleep 1; my $stats = $lxs->get; Or my $lxs = Sys::Statistics::Linux::CpuStats->new(initfile => $file); $lxs->init; my $stats = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::CpuStats gathers cpu statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 CPU STATISTICS Generated by F for each cpu (cpu0, cpu1 ...). F without a number is the summary. user - Percentage of CPU utilization at the user level. nice - Percentage of CPU utilization at the user level with nice priority. system - Percentage of CPU utilization at the system level. idle - Percentage of time the CPU is in idle state. total - Total percentage of CPU utilization. Statistics with kernels >= 2.6. iowait - Percentage of time the CPU is in idle state because an I/O operation is waiting to complete. irq - Percentage of time the CPU is servicing interrupts. softirq - Percentage of time the CPU is servicing softirqs. steal - Percentage of stolen CPU time, which is the time spent in other operating systems when running in a virtualized environment (>=2.6.11). =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::CpuStats->new; Maybe you want to store/load the initial statistics to/from a file: my $lxs = Sys::Statistics::Linux::CpuStats->new(initfile => '/tmp/cpustats.yml'); If you set C it's not necessary to call sleep before C. It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::CpuStats->new( files => { # This is the default path => '/proc' stat => 'stat', } ); =head2 init() Call C to initialize the statistics. $lxs->init; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stats = $lxs->get; =head2 raw() Get raw values. =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::CpuStats; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.20'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', stat => 'stat', } ); if (defined $opts->{initfile}) { require YAML::Syck; $self{initfile} = $opts->{initfile}; } foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub raw { my $self = shift; my $stat = $self->_load; return $stat; } sub init { my $self = shift; if ($self->{initfile} && -r $self->{initfile}) { $self->{init} = YAML::Syck::LoadFile($self->{initfile}); } else { $self->{init} = $self->_load; } } sub get { my $self = shift; my $class = ref $self; if (!exists $self->{init}) { croak "$class: there are no initial statistics defined"; } $self->{stats} = $self->_load; $self->_deltas; if ($self->{initfile}) { YAML::Syck::DumpFile($self->{initfile}, $self->{init}); } return $self->{stats}; } # # private stuff # sub _load { my $self = shift; my $class = ref $self; my $file = $self->{files}; my (%stats, $iowait, $irq, $softirq, $steal); my $filename = $file->{path} ? "$file->{path}/$file->{stat}" : $file->{stat}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { if ($line =~ /^(cpu.*?)\s+(.*)$/) { my $cpu = \%{$stats{$1}}; (@{$cpu}{qw(user nice system idle)}, $iowait, $irq, $softirq, $steal) = split /\s+/, $2; # iowait, irq and softirq are only set # by kernel versions higher than 2.4. # steal is available since 2.6.11. $cpu->{iowait} = $iowait if defined $iowait; $cpu->{irq} = $irq if defined $irq; $cpu->{softirq} = $softirq if defined $softirq; $cpu->{steal} = $steal if defined $steal; } } close($fh); return \%stats; } sub _deltas { my $self = shift; my $class = ref $self; my $istat = $self->{init}; my $lstat = $self->{stats}; foreach my $cpu (keys %{$lstat}) { my $icpu = $istat->{$cpu}; my $dcpu = $lstat->{$cpu}; my $uptime; while (my ($k, $v) = each %{$dcpu}) { if (!defined $icpu->{$k}) { croak "$class: not defined key found '$k'"; } if ($v !~ /^\d+\z/ || $dcpu->{$k} !~ /^\d+\z/) { croak "$class: invalid value for key '$k'"; } $dcpu->{$k} -= $icpu->{$k}; $icpu->{$k} = $v; $uptime += $dcpu->{$k}; } foreach my $k (keys %{$dcpu}) { if ($dcpu->{$k} > 0) { $dcpu->{$k} = sprintf('%.2f', 100 * $dcpu->{$k} / $uptime); } elsif ($dcpu->{$k} < 0) { $dcpu->{$k} = sprintf('%.2f', 0); } else { $dcpu->{$k} = sprintf('%.2f', $dcpu->{$k}); } } $dcpu->{total} = sprintf('%.2f', 100 - $dcpu->{idle}); } } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/DiskUsage.pm000444000000000000 625011726272174 23712 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::DiskUsage - Collect linux disk usage. =head1 SYNOPSIS use Sys::Statistics::Linux::DiskUsage; my $lxs = new Sys::Statistics::Linux::DiskUsage; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::DiskUsage gathers the disk usage with the command C. For more information read the documentation of the front-end module L. =head1 DISK USAGE INFORMATIONS Generated by F. total - The total size of the disk. usage - The used disk space in kilobytes. free - The free disk space in kilobytes. usageper - The used disk space in percent. mountpoint - The moint point of the disk. =head2 GLOBAL VARS If you want to change the path or arguments for C you can use the following variables... $Sys::Statistics::Linux::DiskUsage::DF_PATH = '/bin'; $Sys::Statistics::Linux::DiskUsage::DF_CMD = 'df -akP'; Example: use Sys::Statistics::Linux; use Sys::Statistics::Linux::DiskUsage; $Sys::Statistics::Linux::DiskUsage::DF_CMD = 'df -akP'; my $sys = Sys::Statistics::Linux->new(diskusage => 1); my $disk = $sys->get; =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::DiskUsage->new; It's possible to set the path to df. Sys::Statistics::Linux::DiskUsage->new( cmd => { # This is the default path => '/bin', df => 'df -kP 2>/dev/null', } ); =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::DiskUsage; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.14'; our $DF_PATH = undef; our $DF_CMD = undef; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( cmd => { path => '/bin', df => 'df -kP 2>/dev/null', } ); foreach my $p (keys %{ $opts->{cmd} }) { $self{cmd}{$p} = $opts->{cmd}->{$p}; } return bless \%self, $class; } sub get { my $self = shift; my $class = ref $self; my $cmd = $self->{cmd}; my $df_cmd = $DF_CMD || $cmd->{df}; my (%disk_usage); local $ENV{PATH} = $DF_PATH || $cmd->{path}; open my $fh, "$df_cmd|" or croak "$class: unable to execute '$df_cmd' ($!)"; # filter the header {my $null = <$fh>;} while (my $line = <$fh>) { next unless $line =~ /^(.+?)\s+(.+)$/; @{$disk_usage{$1}}{qw( total usage free usageper mountpoint )} = (split /\s+/, $2)[0..4]; $disk_usage{$1}{usageper} =~ s/%//; } close($fh); return \%disk_usage; } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/NetStats.pm000444000000000000 1507511726272174 23625 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::NetStats - Collect linux net statistics. =head1 SYNOPSIS use Sys::Statistics::Linux::NetStats; my $lxs = Sys::Statistics::Linux::NetStats->new; $lxs->init; sleep 1; my $stat = $lxs->get; Or my $lxs = Sys::Statistics::Linux::NetStats->new(initfile => $file); $lxs->init; my $stat = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::NetStats gathers net statistics from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 NET STATISTICS Generated by F. rxbyt - Number of bytes received per second. rxpcks - Number of packets received per second. rxerrs - Number of errors that happend while received packets per second. rxdrop - Number of packets that were dropped per second. rxfifo - Number of FIFO overruns that happend on received packets per second. rxframe - Number of carrier errors that happend on received packets per second. rxcompr - Number of compressed packets received per second. rxmulti - Number of multicast packets received per second. txbyt - Number of bytes transmitted per second. txpcks - Number of packets transmitted per second. txerrs - Number of errors that happend while transmitting packets per second. txdrop - Number of packets that were dropped per second. txfifo - Number of FIFO overruns that happend on transmitted packets per second. txcolls - Number of collisions that were detected per second. txcarr - Number of carrier errors that happend on transmitted packets per second. txcompr - Number of compressed packets transmitted per second. ttpcks - Number of total packets (received + transmitted) per second. ttbyt - Number of total bytes (received + transmitted) per second. =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::NetStats->new; Maybe you want to store/load the initial statistics to/from a file: my $lxs = Sys::Statistics::Linux::NetStats->new(initfile => '/tmp/netstats.yml'); If you set C it's not necessary to call sleep before C. It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::NetStats->new( files => { # This is the default path => '/proc', netdev => 'net/dev', } ); =head2 init() Call C to initialize the statistics. $lxs->init; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $stat = $lxs->get; =head2 raw() The same as get_raw() but it's not necessary to call init() first. =head2 get_raw() Call C to get the raw data - no deltas. =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::NetStats; use strict; use warnings; use Carp qw(croak); use Time::HiRes; our $VERSION = '0.21'; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => '/proc', netdev => 'net/dev', } ); if (defined $opts->{initfile}) { require YAML::Syck; $self{initfile} = $opts->{initfile}; } foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } return bless \%self, $class; } sub init { my $self = shift; if ($self->{initfile} && -r $self->{initfile}) { $self->{init} = YAML::Syck::LoadFile($self->{initfile}); $self->{time} = delete $self->{init}->{time}; } else { $self->{time} = Time::HiRes::gettimeofday(); $self->{init} = $self->_load; } } sub get { my $self = shift; my $class = ref $self; if (!exists $self->{init}) { croak "$class: there are no initial statistics defined"; } $self->{stats} = $self->_load; $self->_deltas; if ($self->{initfile}) { $self->{init}->{time} = $self->{time}; YAML::Syck::DumpFile($self->{initfile}, $self->{init}); } return $self->{stats}; } sub raw { my $self = shift; my $stat = $self->_load; return $stat; } sub get_raw { my $self = shift; my %raw = %{$self->{init}}; delete $raw{time}; return \%raw; } # # private stuff # sub _load { my $self = shift; my $class = ref $self; my $file = $self->{files}; my %stats = (); my $filename = $file->{path} ? "$file->{path}/$file->{netdev}" : $file->{netdev}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { next unless $line =~ /^\s*(.+?):\s*(.*)/; @{$stats{$1}}{qw( rxbyt rxpcks rxerrs rxdrop rxfifo rxframe rxcompr rxmulti txbyt txpcks txerrs txdrop txfifo txcolls txcarr txcompr )} = split /\s+/, $2; $stats{$1}{ttbyt} = $stats{$1}{rxbyt} + $stats{$1}{txbyt}; $stats{$1}{ttpcks} = $stats{$1}{rxpcks} + $stats{$1}{txpcks}; } close($fh); return \%stats; } sub _deltas { my $self = shift; my $class = ref $self; my $istat = $self->{init}; my $lstat = $self->{stats}; my $time = Time::HiRes::gettimeofday(); my $delta = sprintf('%.2f', $time - $self->{time}); $self->{time} = $time; foreach my $dev (keys %{$lstat}) { if (!exists $istat->{$dev}) { delete $lstat->{$dev}; next; } my $idev = $istat->{$dev}; my $ldev = $lstat->{$dev}; while (my ($k, $v) = each %{$ldev}) { if (!defined $idev->{$k}) { croak "$class: not defined key found '$k'"; } if ($v !~ /^\d+\z/ || $ldev->{$k} !~ /^\d+\z/) { croak "$class: invalid value for key '$k'"; } if ($ldev->{$k} == $idev->{$k} || $idev->{$k} > $ldev->{$k}) { $ldev->{$k} = sprintf('%.2f', 0); } elsif ($delta > 0) { $ldev->{$k} = sprintf('%.2f', ($ldev->{$k} - $idev->{$k}) / $delta); } else { $ldev->{$k} = sprintf('%.2f', $ldev->{$k} - $idev->{$k}); } $idev->{$k} = $v; } } } 1; Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/SysInfo.pm000444000000000000 1655511726272174 23456 0ustar00rootroot000000000000=head1 NAME Sys::Statistics::Linux::SysInfo - Collect linux system information. =head1 SYNOPSIS use Sys::Statistics::Linux::SysInfo; my $lxs = Sys::Statistics::Linux::SysInfo->new; my $info = $lxs->get; =head1 DESCRIPTION Sys::Statistics::Linux::SysInfo gathers system information from the virtual F filesystem (procfs). For more information read the documentation of the front-end module L. =head1 SYSTEM INFOMATIONS Generated by F and F, F, F, F. hostname - The host name. domain - The host domain name. kernel - The kernel name. release - The kernel release. version - The kernel version. memtotal - The total size of memory. swaptotal - The total size of swap space. uptime - The uptime of the system. idletime - The idle time of the system. pcpucount - The total number of physical CPUs. tcpucount - The total number of CPUs (cores, hyper threading). interfaces - The interfaces of the system. arch - The machine hardware name (uname -m). # countcpus is the same like tcpucount countcpus - The total (maybe logical) number of CPUs. C and C are really easy to understand. Both values are collected from C. C is the number of physical CPUs, counted by C. C is just the total number counted by C. If you want to get C and C as raw value you can set $Sys::Statistics::Linux::SysInfo::RAWTIME = 1; # or with Sys::Statistics::Linux::SysInfo->new(rawtime => 1) =head1 METHODS =head2 new() Call C to create a new object. my $lxs = Sys::Statistics::Linux::SysInfo->new; =head2 get() Call C to get the statistics. C returns the statistics as a hash reference. my $info = $lxs->get; =head1 EXPORTS No exports. =head1 SEE ALSO B =head1 REPORTING BUGS Please report all bugs to . =head1 AUTHOR Jonny Schulz . =head1 COPYRIGHT Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut package Sys::Statistics::Linux::SysInfo; use strict; use warnings; use Carp qw(croak); our $VERSION = '0.13'; our $RAWTIME = 0; sub new { my $class = shift; my $opts = ref($_[0]) ? shift : {@_}; my %self = ( files => { path => "/proc", meminfo => "meminfo", sysinfo => "sysinfo", cpuinfo => "cpuinfo", uptime => "uptime", hostname => "sys/kernel/hostname", domain => "sys/kernel/domainname", kernel => "sys/kernel/ostype", release => "sys/kernel/osrelease", version => "sys/kernel/version", netdev => "net/dev", arch => [ "/bin/uname", "-m" ], } ); foreach my $file (keys %{ $opts->{files} }) { $self{files}{$file} = $opts->{files}->{$file}; } foreach my $param (qw(rawtime cpuinfo)) { if ($opts->{$param}) { $self{$param} = $opts->{$param}; } } return bless \%self, $class; } sub get { my $self = shift; my $class = ref $self; my $file = $self->{files}; my $stats = { }; $self->{stats} = $stats; $self->_get_common; $self->_get_meminfo; $self->_get_uptime; $self->_get_interfaces; $self->_get_cpuinfo; foreach my $key (keys %$stats) { chomp $stats->{$key}; $stats->{$key} =~ s/\t+/ /g; $stats->{$key} =~ s/\s+/ /g; } return $stats; } sub _get_common { my $self = shift; my $class = ref($self); my $file = $self->{files}; my $stats = $self->{stats}; for my $x (qw(hostname domain kernel release version)) { my $filename = $file->{path} ? "$file->{path}/$file->{$x}" : $file->{$x}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; $stats->{$x} = <$fh>; close($fh); } if (-x $file->{arch}->[0] ) { my $cmd = join(" ", @{$file->{arch}}); $stats->{arch} = `$cmd`; } } sub _get_meminfo { my $self = shift; my $class = ref($self); my $file = $self->{files}; my $stats = $self->{stats}; my $filename = $file->{path} ? "$file->{path}/$file->{meminfo}" : $file->{meminfo}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { if ($line =~ /^MemTotal:\s+(\d+ \w+)/) { $stats->{memtotal} = $1; } elsif ($line =~ /^SwapTotal:\s+(\d+ \w+)/) { $stats->{swaptotal} = $1; } } close($fh); } sub _get_cpuinfo { my $self = shift; my $class = ref($self); my $file = $self->{files}; my $stats = $self->{stats}; my (%cpu, $phyid); $stats->{countcpus} = 0; my $filename = $file->{path} ? "$file->{path}/$file->{cpuinfo}" : $file->{cpuinfo}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; while (my $line = <$fh>) { if ($line =~ /^physical\s+id\s*:\s*(\d+)/) { $phyid = $1; $cpu{$phyid}{count}++; } elsif ($line =~ /^core\s+id\s*:\s*(\d+)/) { $cpu{$phyid}{cores}{$1}++; } elsif ($line =~ /^processor\s*:\s*\d+/) { # x86 $stats->{countcpus}++; } elsif ($line =~ /^# processors\s*:\s*(\d+)/) { # s390 $stats->{countcpus} = $1; last; } } close($fh); $stats->{countcpus} ||= 1; # if it was not possible to match $stats->{tcpucount} = $stats->{countcpus}; $stats->{pcpucount} = scalar keys %cpu || $stats->{countcpus}; } sub _get_interfaces { my $self = shift; my $class = ref($self); my $file = $self->{files}; my $stats = $self->{stats}; my @iface = (); my $filename = $file->{path} ? "$file->{path}/$file->{netdev}" : $file->{netdev}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; { my $head = <$fh>; } while (my $line = <$fh>) { if ($line =~ /^\s*(\w+):/) { push @iface, $1; } } close $fh; $stats->{interfaces} = join(", ", @iface); $stats->{interfaces} ||= ""; } sub _get_uptime { my $self = shift; my $class = ref($self); my $file = $self->{files}; my $stats = $self->{stats}; my $filename = $file->{path} ? "$file->{path}/$file->{uptime}" : $file->{uptime}; open my $fh, '<', $filename or croak "$class: unable to open $filename ($!)"; ($stats->{uptime}, $stats->{idletime}) = split /\s+/, <$fh>; close $fh; if (!$RAWTIME && !$self->{rawtime}) { foreach my $x (qw/uptime idletime/) { my ($d, $h, $m, $s) = $self->_calsec(sprintf('%li', $stats->{$x})); $stats->{$x} = "${d}d ${h}h ${m}m ${s}s"; } } } sub _calsec { my $self = shift; my ($s, $m, $h, $d) = (shift, 0, 0, 0); $s >= 86400 and $d = sprintf('%i',$s / 86400) and $s = $s % 86400; $s >= 3600 and $h = sprintf('%i',$s / 3600) and $s = $s % 3600; $s >= 60 and $m = sprintf('%i',$s / 60) and $s = $s % 60; return ($d, $h, $m, $s); } 1; Sys-Statistics-Linux-0.66/examples000750000000000000 011726272174 16371 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/examples/diskusage.pl000555000000000000 160011726272174 21047 0ustar00rootroot000000000000#!/usr/bin/perl use strict; use warnings; use Sys::Statistics::Linux; use Sys::Statistics::Linux::DiskUsage; $Sys::Statistics::Linux::DiskUsage::DF_CMD = 'df -hP'; my $sys = Sys::Statistics::Linux->new(diskusage => 1); my $stat = $sys->get; # $stat->diskusage returns the first level keys of the # statistic hash as a array. The first level keys are # the disk names. foreach my $disk ( $stat->diskusage ) { # Gimme the disk names print "Statistics for disk $disk:\n"; # $stat->diskusage($disk) returns the seconds level keys of # the statistics. The second level keys are the statistic keys # for the passed disk. foreach my $key ( sort $stat->diskusage($disk) ) { # Gimme the statistic keys # $stat->diskusage($disk, $key) returns the value for the passed # disk and key. printf " %-20s %s\n", $key, $stat->diskusage($disk, $key); } } Sys-Statistics-Linux-0.66/examples/processes.pl000555000000000000 76711726272174 21073 0ustar00rootroot000000000000#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Sys::Statistics::Linux; use Sys::Statistics::Linux::Processes; # the default value for the following keys are pages: # size, resident, share, trs, drs, lrs, dtp # # set PAGES_TO_BYTES to the pagesize of your system if # you want bytes instead of pages $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4096; my $sys = Sys::Statistics::Linux->new(processes => 1); sleep 1; my $stat = $sys->get(); print Dumper($stat->{processes}); Sys-Statistics-Linux-0.66/examples/loadavg.pl000555000000000000 117011726272174 20507 0ustar00rootroot000000000000#!/usr/bin/perl use strict; use warnings; use Sys::Statistics::Linux; $|++; my $header = 20; my $interval = 1; my $column = 10; my @order = qw(avg_1 avg_5 avg_15); my $h_int = $header; my $lxs = Sys::Statistics::Linux->new(loadavg => 1); while ( 1 ) { my $stats = $lxs->get->loadavg; if ($h_int == $header) { printf "%${column}s", $_ for ('date', 'time', @order); print "\n"; } my ($date, $time) = $lxs->gettime; printf "%${column}s", $_ for ($date, $time); printf "%${column}s", $stats->{$_} for @order; print "\n"; $h_int = $header if --$h_int == 0; sleep $interval; } Sys-Statistics-Linux-0.66/examples/pstop.pl000444000000000000 362511726272174 20243 0ustar00rootroot000000000000#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use Sys::Statistics::Linux; my $o_file = (); my $o_help = (); my %pstop = (); my $fh = (); my $format = "%6s %-8s %5s %5s %5s %1s %4s %5s %12s %s"; my $time = qx{date}; GetOptions( "f|file=s" => \$o_file, "h|help" => \$o_help, ); if ($o_help) { print "\nUsage: $0 [ OPTIONS ]\n\n"; print "-f, --file \n"; print " Print the output to a file instead to STDOUT.\n"; print "-h, --help\n"; print " Print the help and exit.\n\n"; exit 0; } my $sys = Sys::Statistics::Linux->new( memstats => 1, processes => { init => 1, pages_to_bytes => 4, }, ); my $stat = $sys->get(1); %pstop = map { $_ => 1 } $stat->pstop(ttime => 10), $stat->pstop(resident => 10), $stat->psfind({state => qr/[DR]/}); if ($o_file) { open $fh, ">>", $o_file or die "unable to open '$o_file'"; } else { $fh = \*STDOUT; } print $fh "$time\n"; printf $fh "$format\n", qw(PID USER VIRT RES SHR S %CPU %MEM TIME COMMAND); foreach my $pid (keys %pstop) { my $vsize = $stat->processes($pid => "vsize"); my $res = $stat->processes($pid => "resident"); my $share = $stat->processes($pid => "share"); my $owner = substr($stat->processes($pid => "owner"), 0, 8); my $size = sprintf("%.1f", $stat->processes($pid => "resident") * 100 / $stat->memstats->{memtotal}); foreach my $s ($vsize) { if ($s > 9999) { $s = int($s / 1024 / 1024) . "M"; } } foreach my $s ($res, $share) { if ($s > 9999) { $s = int($s / 1024) . "M"; } } printf $fh "$format\n", $pid, $owner, $vsize, $res, $share, $stat->processes($pid => "state"), int($stat->processes($pid => "ttime")), $size, $stat->processes($pid => "actime"), $stat->processes($pid => "cmd"); } print $fh "\n"; Sys-Statistics-Linux-0.66/t000750000000000000 011726272174 15016 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/t/030-procstats.t000444000000000000 72311726272174 17651 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-r '/proc/stat' || !-r '/proc/loadavg') { plan skip_all => "it seems that your system doesn't provide process statistics"; exit(0); } plan tests => 3; my @procstats = qw( new runqueue count ); my $sys = Sys::Statistics::Linux->new(); $sys->set(procstats => 1); sleep(1); my $stats = $sys->get; ok(defined $stats->procstats->{$_}, "checking procstats $_") for @procstats; Sys-Statistics-Linux-0.66/t/060-netstats.t000444000000000000 157611726272174 17526 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-r '/proc/net/dev') { plan skip_all => "it seems that your system doesn't provide net statistics"; exit(0); } plan tests => 36; my @netstats = qw( rxbyt rxpcks rxerrs rxdrop rxfifo rxframe rxcompr rxmulti txbyt txpcks txerrs txdrop txfifo txcolls txcarr txcompr ttpcks ttbyt ); my $sys = Sys::Statistics::Linux->new(); $sys->set(netstats => 1); sleep(1); my $stats = $sys->get; for my $dev (keys %{$stats->netstats}) { ok(defined $stats->netstats->{$dev}->{$_}, "checking netstats $_") for @netstats; last; # we check only one device, that should be enough } for my $dev (keys %{$stats->netinfo}) { ok(defined $stats->netstats->{$dev}->{$_}, "checking netstats $_") for @netstats; last; # we check only one device, that should be enough } Sys-Statistics-Linux-0.66/t/002-pod-coverage.t000444000000000000 22711726272174 20200 0ustar00rootroot000000000000use Test::More; eval "use Test::Pod::Coverage"; plan skip_all => "Test::Pod::Coverage required for testing pod coverage" if $@; all_pod_coverage_ok(); Sys-Statistics-Linux-0.66/t/010-sysinfo.t000444000000000000 135511726272174 17341 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; my @pf = qw( /proc/sys/kernel/hostname /proc/sys/kernel/domainname /proc/sys/kernel/ostype /proc/sys/kernel/osrelease /proc/sys/kernel/version /proc/cpuinfo /proc/meminfo /proc/uptime /bin/uname ); foreach my $f (@pf) { if (!-r $f) { plan skip_all => "$f is not readable"; exit(0); } } plan tests => 13; my @sysinfo = qw( hostname domain kernel release version memtotal swaptotal countcpus pcpucount tcpucount interfaces uptime idletime ); my $sys = Sys::Statistics::Linux->new(); $sys->set(sysinfo => 1); my $stat = $sys->get; ok(defined $stat->sysinfo->{$_}, "checking sysinfo $_") for @sysinfo; Sys-Statistics-Linux-0.66/t/130-search.t000444000000000000 364311726272174 17121 0ustar00rootroot000000000000use strict; use warnings; use Test::More tests => 10; use Sys::Statistics::Linux; use Data::Dumper; my $sys = Sys::Statistics::Linux->new(); $sys->set( cpustats => 1, procstats => 1, memstats => 1, diskusage => 1, ); sleep 1; my $stat = $sys->get(); # just some simple searches that should match every time my $foo = $stat->search({ cpustats => { total => 'lt:101' }, procstats => { count => 'ne:1' }, memstats => { memtotal => 'gt:1' }, diskusage => { usageper => qr/\d+/ }, }); foreach my $key (qw/cpustats procstats memstats/) { ok(exists $foo->{$key} && ref($foo->{$key}) eq 'HASH', "checking $key"); } SKIP: { if (! %{ $stat->diskusage }) { skip "df returned nothing. Might be in a chroot.", 1; } ok(exists $foo->{diskusage} && ref($foo->{diskusage}) eq 'HASH', "checking diskusage"); } my %filter = ( cpustats => { system => 'lt:52', total => 'gt:50', idle => qr/^49\.00\z/, nice => 'ne:1', user => 'eq:0.00', iowait => 'gt:0.01', } ); my %stats = ( cpustats => { cpu => { system => '51.00', total => '51.00', idle => '49.00', nice => '0.00', user => '0.00', iowait => '1.00' } } ); my $comp = Sys::Statistics::Linux::Compilation->new(\%stats); my $hits = $comp->search(\%filter); ok($hits->{cpustats}->{cpu}->{system} == $stats{cpustats}{cpu}{system}, "checking system"); ok($hits->{cpustats}->{cpu}->{total} == $stats{cpustats}{cpu}{total}, "checking total"); ok($hits->{cpustats}->{cpu}->{idle} == $stats{cpustats}{cpu}{idle}, "checking idle"); ok($hits->{cpustats}->{cpu}->{nice} == $stats{cpustats}{cpu}{nice}, "checking nice"); ok($hits->{cpustats}->{cpu}->{user} == $stats{cpustats}{cpu}{user}, "checking user"); ok($hits->{cpustats}->{cpu}->{iowait} == $stats{cpustats}{cpu}{iowait}, "checking iowait"); Sys-Statistics-Linux-0.66/t/070-sockstats.t000444000000000000 126011726272174 17666 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; my @sockstats = qw( used tcp udp raw ); my $sys = Sys::Statistics::Linux->new(); if (!-r '/proc/diskstats' || !-r '/proc/partitions' || !-r '/proc/net/sockstat') { plan skip_all => "it seems that your system doesn't provide socket statistics"; exit(0); } plan tests => 5; $sys->set(sockstats => 1); my $stats = $sys->get; ok(defined $stats->sockstats->{$_}, "checking sockstats $_") for @sockstats; SKIP: { # because ipfrag is only available by kernels > 2.2 skip "checking sockstats ipfrag", 1 if ! defined $stats->sockstats->{ipfrag}; ok(1, "checking sockstats ipfrag"); } Sys-Statistics-Linux-0.66/t/020-cpustats.t000444000000000000 71111726272174 17471 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-r '/proc/stat') { plan skip_all => "it seems that your system doesn't provide cpu statistics"; exit(0); } plan tests => 5; my @cpustats = qw( user nice system idle total ); my $sys = Sys::Statistics::Linux->new(); $sys->set(cpustats => 1); sleep(1); my $stats = $sys->get; ok(defined $stats->cpustats->{cpu}->{$_}, "checking cpustats $_") for @cpustats; Sys-Statistics-Linux-0.66/t/150-pstop.t000444000000000000 127311726272174 17020 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; for my $f ("/proc/$$/stat","/proc/$$/statm","/proc/$$/status","/proc/$$/cmdline","/proc/$$/wchan") { if (!-r $f) { plan skip_all => "$f is not readable"; exit(0); } } my $sys = Sys::Statistics::Linux->new(); $sys->set(processes => 1); sleep 1; my $stat = $sys->get; if (!scalar keys %{$stat->processes}) { plan skip_all => "processlist is empty"; exit(0); } plan tests => 1; my @top = $stat->pstop( ttime => 5 ); my $count = scalar keys %{ $stat->{processes} }; # maybe the user has no rights to read /proc/ if ($count > 5) { $count = 5; } ok(@top == $count, "checking psfind"); Sys-Statistics-Linux-0.66/t/040-memstat.t000444000000000000 173411726272174 17325 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-r '/proc/meminfo') { plan skip_all => "it seems that your system doesn't provide memory statistics"; exit(0); } my @memstats = qw( memused memfree memusedper memtotal buffers cached realfree realfreeper swapused swapfree swapusedper swaptotal swapcached active inactive ); my @memstats26 = qw(committed_as); my @memstats269 = qw(commitlimit); open my $fh, '<', '/proc/sys/kernel/osrelease' or die $!; my @rls = split /\./, <$fh>; close $fh; my $sys = Sys::Statistics::Linux->new(); $sys->set(memstats => 1); my $stats = $sys->get; if ($rls[0] < 6) { plan tests => 15; } else { push @memstats, $_ for @memstats26; if ($rls[1] < 9) { plan tests => 16; } else { plan tests => 17; push @memstats, $_ for @memstats269; } } ok(defined $stats->memstats->{$_}, "checking memstats $_") for @memstats; Sys-Statistics-Linux-0.66/t/080-diskstats.t000444000000000000 225211726272174 17664 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; my @diskstats = qw( major minor rdreq rdbyt wrtreq wrtbyt ttreq ttbyt ); my $sys = Sys::Statistics::Linux->new(); if (!-r '/proc/diskstats' || !-r '/proc/partitions') { plan skip_all => "your system doesn't provide disk statistics - /proc/diskstats and /proc/partitions is not readable"; exit(0); } # I try to set this option in an eval box first because # it could be that this test fails if the linux kernel # version is <= 2.4 and if the kernel is not compiled with # CONFIG_BLK_STATS=y eval { $sys->set(diskstats => 1) }; if ($@) { if ($@ =~ /CONFIG_BLK_STATS/) { plan skip_all => "your system seems not to be compiled with CONFIG_BLK_STATS=y! diskstats will not run on your system!"; } else { plan tests => 1; fail("$@"); } } else { plan tests => 8; $sys->set(diskstats => 1); sleep(1); my $stats = $sys->get; for my $dev (keys %{$stats->diskstats}) { ok(defined $stats->diskstats->{$dev}->{$_}, "checking diskstats $_") for @diskstats; last; # we check only one device, that should be enough } } Sys-Statistics-Linux-0.66/t/110-filestats.t000444000000000000 111311726272174 17636 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-r '/proc/sys/fs/file-nr' || !-r '/proc/sys/fs/inode-nr' || !-r '/proc/sys/fs/dentry-state') { plan skip_all => "it seems that your system doesn't provide file statistics"; exit(0); } plan tests => 10; my @filestats = qw( fhalloc fhfree fhmax inalloc infree inmax dentries unused agelimit wantpages ); my $sys = Sys::Statistics::Linux->new(); $sys->set(filestats => 1); my $stats = $sys->get; ok(defined $stats->filestats->{$_}, "checking filestats $_") for @filestats; Sys-Statistics-Linux-0.66/t/001-pod.t000444000000000000 27211726272174 16406 0ustar00rootroot000000000000use strict; use Test::More; eval "use Test::Pod"; plan skip_all => "Test::Pod required for testing POD" if $@; my @poddirs = qw( blib ); all_pod_files_ok( all_pod_files( @poddirs ) ); Sys-Statistics-Linux-0.66/t/050-pgswstats.t000444000000000000 103411726272174 17704 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; my @pgswstats = qw( pgpgin pgpgout pswpin pswpout ); my $sys = Sys::Statistics::Linux->new(); if (!-r '/proc/diskstats' || !-r '/proc/partitions' || !-r '/proc/stat' || !-r '/proc/vmstat') { plan skip_all => "it seems that your system doesn't provide paging/swapping statistics"; exit(0); } plan tests => 4; $sys->set(pgswstats => 1); sleep(1); my $stats = $sys->get; ok(defined $stats->pgswstats->{$_}, "checking pgswstats $_") for @pgswstats; Sys-Statistics-Linux-0.66/t/100-loadavg.t000444000000000000 65211726272174 17243 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-r '/proc/loadavg') { plan skip_all => "it seems that your system doesn't provide load statistics"; exit(0); } plan tests => 3; my @loadavg = qw( avg_1 avg_5 avg_15 ); my $sys = Sys::Statistics::Linux->new(); $sys->set(loadavg => 1); my $stats = $sys->get; ok(defined $stats->{loadavg}->{$_}, "checking loadavg $_") for @loadavg; Sys-Statistics-Linux-0.66/t/090-diskusage.t000444000000000000 126011726272174 17631 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; if (!-x '/bin/df') { plan skip_all => "it seems that your system doesn't provide /bin/df"; exit(0); } plan tests => 5; my @diskusage = qw( total usage free usageper mountpoint ); my $sys = Sys::Statistics::Linux->new(); $sys->set(diskusage => 1); my $stats = $sys->get; SKIP: { if (! %{ $stats->diskusage }) { skip "df returned nothing. Might be in a chroot.", 5; } for my $dev (keys %{$stats->diskusage}) { ok(defined $stats->diskusage->{$dev}->{$_}, "checking diskusage $_") for @diskusage; last; # we check only one device, that should be enough } } Sys-Statistics-Linux-0.66/t/120-processes.t000444000000000000 203211726272174 17650 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; for my $f ("/proc/$$/stat","/proc/$$/statm","/proc/$$/status","/proc/$$/cmdline","/proc/$$/wchan") { if (!-r $f) { plan skip_all => "$f is not readable"; exit(0); } } my @processes = qw( ppid nlwp owner pgrp state session ttynr minflt cminflt mayflt cmayflt stime utime ttime cstime cutime prior nice sttime actime vsize nswap cnswap cpu size resident share trs drs lrs dtp cmd cmdline wchan fd ); my $sys = Sys::Statistics::Linux->new(); $sys->set(processes => 1); sleep(1); my $stats = $sys->get; if (!scalar keys %{$stats->processes}) { plan skip_all => "processlist is empty"; exit(0); } plan tests => 35; for my $pid (keys %{$stats->processes}) { ok(defined $stats->processes->{$pid}->{$_}, "checking processes $_") for @processes; last; # we check only one process, that should be enough } Sys-Statistics-Linux-0.66/t/140-psfind.t000444000000000000 105411726272174 17132 0ustar00rootroot000000000000use strict; use warnings; use Test::More; use Sys::Statistics::Linux; for my $f ("/proc/$$/stat","/proc/$$/statm","/proc/$$/status","/proc/$$/cmdline","/proc/$$/wchan") { if (!-r $f) { plan skip_all => "$f is not readable"; exit(0); } } my $sys = Sys::Statistics::Linux->new(); $sys->set(processes => 1); sleep 1; my $stat = $sys->get; if (!scalar keys %{$stat->processes}) { plan skip_all => "processlist is empty"; exit(0); } plan tests => 1; my $foo = $stat->psfind({cmd => qr/\w/}); ok(@{$foo}, "checking psfind"); Sys-Statistics-Linux-0.66/t/examples000750000000000000 011726272174 16634 5ustar00rootroot000000000000Sys-Statistics-Linux-0.66/t/examples/cpuinfo3000444000000000000 3636611726272174 20505 0ustar00rootroot000000000000processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 0 siblings : 6 core id : 0 cpu cores : 6 apicid : 0 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.75 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 1 siblings : 6 core id : 0 cpu cores : 6 apicid : 8 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.83 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 2 siblings : 6 core id : 0 cpu cores : 6 apicid : 16 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.81 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 3 siblings : 6 core id : 0 cpu cores : 6 apicid : 24 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.67 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 0 siblings : 6 core id : 2 cpu cores : 6 apicid : 2 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.81 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 1 siblings : 6 core id : 2 cpu cores : 6 apicid : 10 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.77 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 6 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 2 siblings : 6 core id : 2 cpu cores : 6 apicid : 18 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.85 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 7 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 3 siblings : 6 core id : 2 cpu cores : 6 apicid : 26 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.84 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 8 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 0 siblings : 6 core id : 4 cpu cores : 6 apicid : 4 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.81 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 9 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 1 siblings : 6 core id : 4 cpu cores : 6 apicid : 12 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.82 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 10 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 2 siblings : 6 core id : 4 cpu cores : 6 apicid : 20 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.84 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 11 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 3 siblings : 6 core id : 4 cpu cores : 6 apicid : 28 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.84 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 12 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 0 siblings : 6 core id : 1 cpu cores : 6 apicid : 1 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.88 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 13 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 1 siblings : 6 core id : 1 cpu cores : 6 apicid : 9 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.80 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 14 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 2 siblings : 6 core id : 1 cpu cores : 6 apicid : 17 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.82 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 15 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 3 siblings : 6 core id : 1 cpu cores : 6 apicid : 25 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.84 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 16 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 0 siblings : 6 core id : 3 cpu cores : 6 apicid : 3 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.84 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 17 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 1 siblings : 6 core id : 3 cpu cores : 6 apicid : 11 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.84 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 18 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 2 siblings : 6 core id : 3 cpu cores : 6 apicid : 19 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.86 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 19 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 3 siblings : 6 core id : 3 cpu cores : 6 apicid : 27 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.77 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 20 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 0 siblings : 6 core id : 5 cpu cores : 6 apicid : 5 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.90 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 21 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 1 siblings : 6 core id : 5 cpu cores : 6 apicid : 13 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.83 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 22 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 2 siblings : 6 core id : 5 cpu cores : 6 apicid : 21 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.75 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 23 vendor_id : GenuineIntel cpu family : 6 model : 29 model name : Intel(R) Xeon(R) CPU X7460 @ 2.66GHz stepping : 1 cpu MHz : 2659.875 cache size : 16384 KB physical id : 3 siblings : 6 core id : 5 cpu cores : 6 apicid : 29 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm bogomips : 5319.82 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: Sys-Statistics-Linux-0.66/t/examples/cpuinfo1000444000000000000 1327011726272174 20470 0ustar00rootroot000000000000processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5350.94 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 1 cpu cores : 4 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.45 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 2 cpu cores : 4 apicid : 4 initial apicid : 4 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.45 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 3 cpu cores : 4 apicid : 6 initial apicid : 6 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.45 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 0 cpu cores : 4 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.44 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 1 cpu cores : 4 apicid : 3 initial apicid : 3 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.45 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 6 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 2 cpu cores : 4 apicid : 5 initial apicid : 5 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.46 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 7 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 3 cpu cores : 4 apicid : 7 initial apicid : 7 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5346.45 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: Sys-Statistics-Linux-0.66/t/examples/cpuinfo2000444000000000000 4301611726272174 20472 0ustar00rootroot000000000000processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 0 cpu cores : 6 apicid : 32 initial apicid : 32 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5856.27 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 0 cpu cores : 6 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.15 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 1 cpu cores : 6 apicid : 34 initial apicid : 34 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.15 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 1 cpu cores : 6 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.12 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 2 cpu cores : 6 apicid : 36 initial apicid : 36 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.09 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 2 cpu cores : 6 apicid : 4 initial apicid : 4 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.12 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 6 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 8 cpu cores : 6 apicid : 48 initial apicid : 48 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.10 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 7 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 8 cpu cores : 6 apicid : 16 initial apicid : 16 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.13 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 8 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 9 cpu cores : 6 apicid : 50 initial apicid : 50 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.12 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 9 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 9 cpu cores : 6 apicid : 18 initial apicid : 18 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.15 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 10 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 10 cpu cores : 6 apicid : 52 initial apicid : 52 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.18 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 11 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 10 cpu cores : 6 apicid : 20 initial apicid : 20 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.12 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 12 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 0 cpu cores : 6 apicid : 33 initial apicid : 33 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.16 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 13 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 0 cpu cores : 6 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.17 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 14 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 1 cpu cores : 6 apicid : 35 initial apicid : 35 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.13 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 15 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 1 cpu cores : 6 apicid : 3 initial apicid : 3 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.12 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 16 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 2 cpu cores : 6 apicid : 37 initial apicid : 37 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.15 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 17 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 2 cpu cores : 6 apicid : 5 initial apicid : 5 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.11 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 18 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 8 cpu cores : 6 apicid : 49 initial apicid : 49 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.10 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 19 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 8 cpu cores : 6 apicid : 17 initial apicid : 17 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.15 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 20 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 9 cpu cores : 6 apicid : 51 initial apicid : 51 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.13 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 21 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 9 cpu cores : 6 apicid : 19 initial apicid : 19 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.16 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 22 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 1 siblings : 12 core id : 10 cpu cores : 6 apicid : 53 initial apicid : 53 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.11 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: processor : 23 vendor_id : GenuineIntel cpu family : 6 model : 44 model name : Intel(R) Xeon(R) CPU X5670 @ 2.93GHz stepping : 2 cpu MHz : 2925.998 cache size : 12288 KB physical id : 0 siblings : 12 core id : 10 cpu cores : 6 apicid : 21 initial apicid : 21 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr dca sse4_1 sse4_2 popcnt lahf_lm ida bogomips : 5852.16 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: Sys-Statistics-Linux-0.66/t/examples/cpuinfo0000444000000000000 104611726272174 20445 0ustar00rootroot000000000000processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 CPU 1.80GHz stepping : 4 cpu MHz : 1796.992 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx f xsr sse sse2 ss ht tm up bogomips : 3597.32 Sys-Statistics-Linux-0.66/t/examples/cpuinfo5000444000000000000 262311726272174 20454 0ustar00rootroot000000000000processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 37 model name : Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz stepping : 2 cpu MHz : 2392.215 cache size : 6144 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc pni lahf_lm bogomips : 4784.43 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 37 model name : Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz stepping : 2 cpu MHz : 2392.215 cache size : 6144 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc pni lahf_lm bogomips : 4792.90 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: Sys-Statistics-Linux-0.66/t/examples/cpuinfo4000444000000000000 247611726272174 20461 0ustar00rootroot000000000000processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 28 model name : Intel(R) Atom(TM) CPU N270 @ 1.60GHz stepping : 2 cpu MHz : 800.000 cache size : 512 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de tsc msr pae mce ... bogomips : 3191.48 clflush size : 64 cache_alignment : 64 address sizes : 32 bits physical, 32 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 28 model name : Intel(R) Atom(TM) CPU N270 @ 1.60GHz stepping : 2 cpu MHz : 1600.000 cache size : 512 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 1 apicid : 1 initial apicid : 1 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce ... bogomips : 3191.95 clflush size : 64 cache_alignment : 64 address sizes : 32 bits physical, 32 bits virtual power management: