stat(3)

NAME
Linux::stat - parse /proc/stat

SYNOPSIS

  use Linux::stat;
  my $stat = Linux::stat->new( [ stat => "path to /proc/stat" ] );
  my $hashref = $stat->stat();
or

  my $hashref = Linux::stat::stat( [ "path to /proc/stat" ] );

DESCRIPTION
Linux::stat is a simple Perl module which parses /proc/stat file. Info is arranged in hash reference with descriptive keys.

Linux::stat was written on RedHat Linux 7.2, kernel 2.4.7 and tested on RedHat 6.2, kernel 2.2.14. It is expected to work with other versions as well, but this depends on Linux configuration and kernel version.

Output data can be easily previewed with Data::VarPrint package, available at CPAN.

Output fields (some of these are unavailable on kernels older than 2.4): Timestamp (number of seconds since epoch) when the system was booted Context switch, used by Linux job scheduler; for more info check Linux kernel sources: kernel/sched.c (look for kstat.context_swtch) Overall and per-CPU time: user, nice, system, idle Disks I/O (for each partition): Overall disk I/O info; same fields as in disks (of course, except for disk and major) Number for interrupts for each IRQ Total number of interrupts (same as sum of all numbers in interrupts) Not parsed, just added to hash Number of pages read Number of pages written Number of pages read from swap Number of pages written to swap Number of processes run since boot System uptime in seconds (same as sum of all four times for cpu)

All not-recognized fields are just passed on without parsing.

OPTIONS
Currently, the only option available is stat which is path to /proc/stat in case this changes for some reason.

FILES
/proc/stat CPU, disk and some other information

REQUIRES
Perl 5.000

SEE ALSO
perl(1)

AUTHOR
Vedran Sego, vsego@math.hr