├── .gitignore ├── MANIFEST ├── Changes ├── Makefile.PL ├── README ├── perl-Sun-Solaris-Kstat.spec └── lib └── Sun └── Solaris └── Kstat.pm /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | blib 3 | pm_to_blib 4 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | Changes 2 | Makefile.PL 3 | MANIFEST 4 | README 5 | lib/Sun/Solaris/Kstat.pm 6 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension Sun::Solaris::Kstat. 2 | 3 | 0.01 Thu Apr 7 15:30:05 2011 4 | - original version; created by h2xs 1.23 with options 5 | -AXc -n Sun::Solaris::Kstat 6 | 7 | -------------------------------------------------------------------------------- /Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 3 | # the contents of the Makefile that is written. 4 | WriteMakefile( 5 | NAME => 'Sun::Solaris::Kstat', 6 | VERSION_FROM => 'lib/Sun/Solaris/Kstat.pm', # finds $VERSION 7 | PREREQ_PM => {}, # e.g., Module::Name => 1.1 8 | ($] >= 5.005 ? ## Add these new keywords supported since 5.005 9 | (ABSTRACT_FROM => 'lib/Sun/Solaris/Kstat.pm', # retrieve abstract from module 10 | AUTHOR => 'Gunnar Beutner ') : ()), 11 | ); 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Sun::Solaris::Kstat for Linux version 0.01 2 | ========================================== 3 | 4 | This is an implementation of the Sun::Solaris::Kstat Perl module 5 | for Linux ZFS. It should behave identically to the Solaris version. 6 | 7 | INSTALLATION 8 | 9 | To install this module type the following: 10 | 11 | perl Makefile.PL 12 | make 13 | make test 14 | make install 15 | 16 | COPYRIGHT AND LICENCE 17 | 18 | Copyright (C) 2011 by Gunnar Beutner 19 | 20 | This program is free software; you can redistribute it and/or 21 | modify it under the terms of the GNU General Public License 22 | as published by the Free Software Foundation; either version 2 23 | of the License, or (at your option) any later version. 24 | 25 | This program is distributed in the hope that it will be useful, 26 | but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | GNU General Public License for more details. 29 | 30 | You should have received a copy of the GNU General Public License 31 | along with this program; if not, write to the Free Software 32 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 33 | -------------------------------------------------------------------------------- /perl-Sun-Solaris-Kstat.spec: -------------------------------------------------------------------------------- 1 | %global commit c74e8e026445540143e90bd027fb074eec698ac6 2 | %global shortcommit %(c=%{commit}; echo ${c:0:7}) 3 | %global repo_name linux-kstat 4 | 5 | Name: perl-Sun-Solaris-Kstat 6 | Version: 0.01 7 | Release: 1%{?dist} 8 | Summary: Linux-compatible kstat interface 9 | License: GPLv2+ 10 | Group: Development/Libraries 11 | URL: https://github.com/zfsonlinux/%{repo_name} 12 | Source0: https://github.com/zfsonlinux/%{repo_name}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz 13 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 14 | BuildArch: noarch 15 | BuildRequires: perl(ExtUtils::MakeMaker) 16 | Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) 17 | 18 | %description 19 | This module provides an interface for the Linux ZFS kernel module that 20 | is compatible with the Sun::Solaris::Kstat Perl module found on 21 | Solaris systems. 22 | 23 | %prep 24 | %setup -qn %{repo_name}-%{commit} 25 | 26 | %build 27 | %{__perl} Makefile.PL INSTALLDIRS=vendor 28 | make %{?_smp_mflags} 29 | 30 | %install 31 | rm -rf $RPM_BUILD_ROOT 32 | 33 | make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT 34 | 35 | find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \; 36 | find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \; 37 | 38 | %{_fixperms} $RPM_BUILD_ROOT/* 39 | 40 | %check 41 | make test 42 | 43 | %clean 44 | rm -rf $RPM_BUILD_ROOT 45 | 46 | %files 47 | %defattr(-,root,root,-) 48 | %doc Changes README 49 | %{perl_vendorlib}/* 50 | %{_mandir}/man3/* 51 | 52 | %changelog 53 | * Tue Jul 23 2013 Trey Dockendorf 0.01-1 54 | - Specfile autogenerated by cpanspec 1.78. 55 | -------------------------------------------------------------------------------- /lib/Sun/Solaris/Kstat.pm: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 Gunnar Beutner 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | 17 | package Sun::Solaris::Kstat; 18 | 19 | use strict; 20 | use warnings; 21 | 22 | require Exporter; 23 | our @ISA = qw(Exporter); 24 | 25 | our @EXPORT_OK = qw( 26 | new update 27 | ); 28 | 29 | our $VERSION = '0.01'; 30 | 31 | sub new { 32 | my $package = shift; 33 | return bless({}, $package); 34 | } 35 | 36 | sub update { 37 | my $self = shift; 38 | 39 | my $kstat_path = "/proc/spl/kstat/"; 40 | 41 | opendir(KDIR, $kstat_path) or die $!; 42 | 43 | my @modules = readdir(KDIR); 44 | my $module; 45 | foreach $module (@modules) { 46 | if ($module eq "." || $module eq "..") { 47 | next; 48 | } 49 | 50 | $self->{$module} = {}; 51 | $self->{$module}{0} = {}; 52 | 53 | opendir(MODDIR, $kstat_path . $module) or die $!; 54 | 55 | my @files = readdir(MODDIR); 56 | my $file; 57 | foreach $file (@files) { 58 | if ($file eq "." || $file eq "..") { 59 | next; 60 | } 61 | 62 | $self->{$module}{0}{$file} = {}; 63 | 64 | open FILE, $kstat_path . "/" . $module . "/" . $file or die $!; 65 | 66 | while () { 67 | if ($_ =~ /^([^ ]+) *(\d+) *(\d+)$/) { 68 | $self->{$module}{0}{$file}{$1} = $3; 69 | } 70 | } 71 | 72 | close FILE; 73 | } 74 | 75 | closedir(MODDIR); 76 | } 77 | 78 | closedir(KDIR); 79 | 80 | return 0; 81 | } 82 | 83 | 1; 84 | __END__ 85 | 86 | =head1 NAME 87 | 88 | Sun::Solaris::Kstat - Solaris-compatible kstat interface 89 | 90 | =head1 SYNOPSIS 91 | 92 | use Sun::Solaris::Kstat; 93 | my $kstat = Sun::Solaris::Kstat->new; 94 | $kstat->update(); 95 | $kstat->{"zfs"}{0}{"arcstats"}{"hits"} 96 | 97 | =head1 DESCRIPTION 98 | 99 | This module provides an interface for the Linux ZFS kernel module that is 100 | compatible with the Sun::Solaris::Kstat Perl module found on Solaris systems. 101 | 102 | =head1 SEE ALSO 103 | 104 | L 105 | 106 | =head1 AUTHOR 107 | 108 | Gunnar Beutner 109 | 110 | =head1 COPYRIGHT AND LICENSE 111 | 112 | Copyright (C) 2011 by Gunnar Beutner 113 | 114 | This program is free software; you can redistribute it and/or 115 | modify it under the terms of the GNU General Public License 116 | as published by the Free Software Foundation; either version 2 117 | of the License, or (at your option) any later version. 118 | 119 | This program is distributed in the hope that it will be useful, 120 | but WITHOUT ANY WARRANTY; without even the implied warranty of 121 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 122 | GNU General Public License for more details. 123 | 124 | You should have received a copy of the GNU General Public License 125 | along with this program; if not, write to the Free Software 126 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 127 | 128 | 129 | =cut 130 | --------------------------------------------------------------------------------