BSD-devstat

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

---
abstract: 'interface to devstat(3) API'
author:
  - 'Jun Kuriyama <kuriyama@FreeBSD.org>'
build_requires:
  ExtUtils::MakeMaker: 6.42
  Test::More: 0
configure_requires:
  ExtUtils::MakeMaker: 6.42
distribution_type: module
generated_by: 'Module::Install version 0.94'
license: perl

compstat-gen.PL  view on Meta::CPAN

#
# $Id$

use strict;
use warnings;

open(my $fh, "<", "compstat.txt") or die;

print <<END;
int
compstat(struct devstat *current, struct devstat *previous, long double etime, HV* rh)
{
    u_int64_t u[14];
    long double d[23];
    devstat_compute_statistics(current, previous, etime,
END

my ($u, $d, @u, @d) = (0, 0);
while (<$fh>) {
  chomp;
  my ($key, $type) = split(/\t+/, $_, 2);

devstat.xs  view on Meta::CPAN

    if (devstat_getdevs(self->kd, &s1) == -1) {
        croak("First devstat_getdevs() returns -1: %s", devstat_errbuf);
    }
    t.tv_sec = (int)(sec);
    t.tv_nsec = (long)(1000000000L * sec) % 1000000000L;
    nanosleep(&t, NULL);
    if (devstat_getdevs(self->kd, &s2) == -1) {
        croak("Second devstat_getdevs() returns -1: %s", devstat_errbuf);
    }
    HV *rh = (HV*)sv_2mortal((SV*)newHV());
    compstat(&d2.devices[index], &d1.devices[index], s2.snap_time - s1.snap_time, rh);
    RETVAL = rh;
OUTPUT:
    RETVAL

void
DESTROY(bsd_devstat* self)
CODE:
    bsd_devstat_free(self);

inc/Module/Install.pm  view on Meta::CPAN





# If the script that is loading Module::Install is from the future,
# then make will detect this and cause it to re-run over and over
# again. This is bad. Rather than taking action to touch it (which
# is unreliable on some platforms and requires write permissions)
# for now we should catch this and refuse to run.
if ( -f $0 ) {
	my $s = (stat($0))[9];

	# If the modification time is only slightly in the future,
	# sleep briefly to remove the problem.
	my $a = $s - time;
	if ( $a > 0 and $a < 5 ) { sleep 5 }

	# Too far in the future, throw an error.
	my $t = time;
	if ( $s > $t ) { die <<"END_DIE" }

lib/BSD/devstat.pm  view on Meta::CPAN

    require DynaLoader;
    push @ISA, 'DynaLoader';
    __PACKAGE__->bootstrap($VERSION);
};

1;
__END__

=head1 NAME

BSD::devstat - interface to devstat(3) API

=head1 SYNOPSIS

  use BSD::devstat;

  my $ds = BSD::devstat->new();
  printf "Number of devices: %d\n", $ds->numdevs;

  my $devidx = $ds->numdevs;	# this is last device.

  my $dev = $ds->devices($devidx);
  printf "%s%d block_size=%d\n", $dev->{device_name},
    $dev->{unit_number}, $dev->{block_size};

  # Stat in 2 seconds.
  my $stat = $ds->compute_statistics($devidx, 2.0);
  printf "BUSY_PCT=%.2f\n", $stat->{BUSY_PCT};

=head1 DESCRIPTION

BSD::devstat is interface to devstat(3) API.  You can grab device
statistics information which is provided by devstat(9) kernel interface
via devstat(3) userland interface.

=over

=item new()

Retrieve device statistics and store it as BSD::devstat object.

=item numdevs()

Return the number of devices which devstat(3) API provided.

=item devices($device_index)

$device_index is index for device, which can be from 0 to
($self->numdevs() - 1).
Returns hash reference.  This contains various values described in
devstat(9) manpage.  This method will croak if error occured.

=item compute_statistics($device_index, $elapse_time)

$device_index is index for device, which can be from 0 to
($self->numdevs() - 1).  $elapse_time is second (can be float number)
between two snapshots of statistics and calculation by done with these
statistics.
Returns hash reference.  This contains various values described at
devstat_compute_statistics() function in devstat(3) manpage.
This method will croak if error occured.

=back

=head1 AUTHOR

Jun Kuriyama E<lt>kuriyama@FreeBSD.orgE<gt>

=head1 SEE ALSO

devstat(3), devstat(9).

=head1 BUGS

Currently supports only FreeBSD.

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.



( run in 1.063 second using v1.01-cache-2.11-cpan-49f99fa48dc )