~ubuntu-branches/ubuntu/natty/munin/natty

« back to all changes in this revision

Viewing changes to plugins/node.d/hddtemp_smartctl.in

  • Committer: Bazaar Package Importer
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2009-12-04 15:48:53 UTC
  • mto: (8.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20091204154853-ovbff1s1jo6s4q95
Tags: upstream-1.4.1
ImportĀ upstreamĀ versionĀ 1.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
 
91
91
use strict;
92
92
 
93
 
my $smartctl = exists $ENV{smartctl} ? $ENV{smartctl} : undef;
 
93
my $smartctl = exists $ENV{smartctl} ? $ENV{smartctl} : '';
94
94
 
95
95
# If the envvar is not set, look for smartctl
96
 
# first, try $PATH
97
 
$smartctl = `which smartctl 2>/dev/null` unless $smartctl;
98
 
chomp $smartctl;
99
 
$smartctl = undef unless -x $smartctl;
100
 
 
101
 
# Still not found? Check obvious places
102
 
my @dirs = qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin);
103
 
until ($smartctl or @dirs == 0) {
104
 
  my $dir = shift @dirs;
105
 
  my $path = $dir.'/smartctl';
106
 
  $smartctl = $path if -x $path;
 
96
if (!$smartctl) {
 
97
   # Still not found? Check obvious places
 
98
    my @dirs = split(':',$ENV{PATH});
 
99
    push (@dirs, qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin) );
 
100
    
 
101
    until ($smartctl or @dirs == 0) {
 
102
        my $dir = shift @dirs;
 
103
        my $path = $dir.'/smartctl';
 
104
        $smartctl = $path if -x $path;
 
105
    }
107
106
}
108
107
 
109
108
# Check version of smartctl to determine --nocheck capabilities
110
109
my $use_nocheck = 0;
111
 
if (`$smartctl --version` =~ / version (\d+\.\d+) /i) {
112
 
  $use_nocheck = $1 >= 5.37;
 
110
if ($smartctl and `$smartctl --version` =~ / version (\d+\.\d+) /i) {
 
111
    $use_nocheck = $1 >= 5.37;
113
112
}
114
113
 
115
114
# hdparm is used as a fallback
116
 
my $hdparm = `which hdparm`;
 
115
my $hdparm = `which hdparm 2>/dev/null`;
117
116
 
118
117
my @drives;
119
118