| 1 | # | ||||||||||
| 2 | # Lustre OST/OSS subclass | ||||||||||
| 3 | # | ||||||||||
| 4 | # (C) 2010 Adrian Ulrich - <adrian.ulrich@id.ethz.ch> | ||||||||||
| 5 | # | ||||||||||
| 6 | # This program is free software; you can redistribute it and/or | ||||||||||
| 7 | # modify it under the same terms as Perl itself. | ||||||||||
| 8 | # | ||||||||||
| 9 | package Lustre::Info::MDT; | ||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use constant PROCFS_MDS => "/proc/fs/lustre/mds"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | ########################################################################## | ||||||||||
| 15 | # Creates a new MDT Object | ||||||||||
| 16 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 17 | 0 | my($classname, %args) = @_; | |||||||||
| 18 | 0 | my $self = { super=>$args{super}, mdtname=>$args{mdtname}, procpath=>PROCFS_MDS."/$args{mdtname}" }; | |||||||||
| 19 | 0 | bless($self,$classname); | |||||||||
| 20 | 0 | ▶ | return ( -d $self->{procpath} ? $self : undef ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | ########################################################################## | ||||||||||
| 24 | # Return name of MDT | ||||||||||
| 25 | 0 | ▶ | sub get_name { | ||||||||
|
Subroutine
get_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 26 | 0 | my($self) = @_; | |||||||||
| 27 | 0 | return $self->{mdtname}; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | ########################################################################## | ||||||||||
| 31 | # Return the size of this MDT | ||||||||||
| 32 | 0 | ▶ | sub get_kbytes_total { return $_[0]->_rint('kbytestotal'); } | ||||||||
|
Subroutine
get_kbytes_total: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 33 | |||||||||||
| 34 | ########################################################################## | ||||||||||
| 35 | # Return how much space is free | ||||||||||
| 36 | 0 | ▶ | sub get_kbytes_free { return $_[0]->_rint('kbytesfree'); } | ||||||||
|
Subroutine
get_kbytes_free: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 37 | |||||||||||
| 38 | ########################################################################## | ||||||||||
| 39 | # # of pre-allocated inodes (at mkfs.lustre runtime) | ||||||||||
| 40 | 0 | ▶ | sub get_files_total { return $_[0]->_rint('filestotal'); } | ||||||||
|
Subroutine
get_files_total: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | |||||||||||
| 42 | ########################################################################## | ||||||||||
| 43 | # How many files/inodes are free | ||||||||||
| 44 | 0 | ▶ | sub get_files_free { return $_[0]->_rint('filesfree'); } | ||||||||
|
Subroutine
get_files_free: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | |||||||||||
| 46 | ########################################################################## | ||||||||||
| 47 | # Returns the name of the hosting blockdevice | ||||||||||
| 48 | 0 | ▶ | sub get_blockdevice { return $_[0]->_rint('mntdev'); } | ||||||||
|
Subroutine
get_blockdevice: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 49 | |||||||||||
| 50 | ########################################################################## | ||||||||||
| 51 | # Parse and return information about the last recovery procedure | ||||||||||
| 52 | 0 | ▶ | sub get_recovery_info { | ||||||||
|
Subroutine
get_recovery_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | 0 | my($self) = @_; | |||||||||
| 54 | 0 | return $self->{super}->_parse_generic_file($self->{procpath}."/recovery_status"); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | ########################################################################## | ||||||||||
| 59 | # Return an integer | ||||||||||
| 60 | 0 | ▶ | sub _rint { | ||||||||
|
Subroutine
_rint: not called CC=2 SCAR=17.9
| |||||||||||
| 61 | 0 | my($self,$procfile) = @_; | |||||||||
| 62 | 0 | ▶ | open(PF, $self->{procpath}."/$procfile") or return -1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | my $num = <PF>; chomp($num); | |||||||||
| 64 | 0 | close(PF); | |||||||||
| 65 | 0 | return $num; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | 1 | 1; | |||||||||
| 70 | __END__ | ||||||||||