Hardware/Temperature.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Hardware/Fan.pm ↑ Summary Identify/Ssh.pm »
1 #
2 # $Id$
3 #
4 # hardware::temperature Brik
5 #
6 package Metabrik::Hardware::Temperature;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::File::Text);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 commands => {
19 cpu => [ ],
20 },
21 };
22 }
23  
24 sub cpu {
25 my $self = shift;
26  
27 my $file = "/sys/class/thermal/thermal_zone0/temp";
28 $self->brik_help_run_file_not_found('cpu', $file) or return;
29  
30 my $text = $self->read($file) or return;
31  
32 if (length($text)) {
33 chomp($text);
34 if ($text =~ /^\d+$/) {
35 return $text / 1000;
36 }
37 }
38  
39 return $self->log->error("cpu: invalid content in file [$file]");
40 }
41  
42 1;
43  
44 __END__
« Hardware/Fan.pm ↑ Summary Identify/Ssh.pm »